mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-15 08:10:17 +02:00
increase range of relative jumps by aligning blocks to 8-byte boundaries
* libguile/objcodes.c (OBJCODE_COOKIE): Bump again, as our jump offsets are now multiplied by 8. * libguile/vm-i-system.c (BR): Interpret the 16-bit offset as a relative jump to the nearest 8-byte-aligned block -- increasing relative jump range from +/-32K to +/-240K. (mvra): Do the same for the mvra jump. * libguile/vm.c (really_make_boot_program): Align the mvra. * module/language/assembly.scm (align-block): New export, for aligning blocks. * module/language/assembly/compile-bytecode.scm (write-bytecode): Emit jumps to the nearest 8-byte-aligned block. Effectively our range is 18 bits in either direction. I would like to do this differently -- have long-br and long-br-if, and all the other br instructions go to 8 bits only. But the assembler doesn't have an appropriate representation to allow me to do this yet, so for now this is what we have. * module/language/assembly/decompile-bytecode.scm (decode-load-program): Decode the 19-bit jumps.
This commit is contained in:
parent
28b119ee3d
commit
e5dc27b86d
7 changed files with 39 additions and 26 deletions
|
@ -24,7 +24,7 @@
|
|||
#:use-module (system vm instruction)
|
||||
#:use-module ((srfi srfi-1) #:select (fold))
|
||||
#:export (byte-length
|
||||
addr+ align-program align-code
|
||||
addr+ align-program align-code align-block
|
||||
assembly-pack assembly-unpack
|
||||
object->assembly assembly->object))
|
||||
|
||||
|
@ -63,17 +63,24 @@
|
|||
|
||||
(define *program-alignment* 8)
|
||||
|
||||
(define *block-alignment* 8)
|
||||
|
||||
(define (addr+ addr code)
|
||||
(fold (lambda (x len) (+ (byte-length x) len))
|
||||
addr
|
||||
code))
|
||||
|
||||
(define (code-alignment addr alignment header-len)
|
||||
(make-list (modulo (- alignment
|
||||
(modulo (+ addr header-len) alignment))
|
||||
alignment)
|
||||
'(nop)))
|
||||
|
||||
(define (align-block addr)
|
||||
(code-alignment addr *block-alignment* 0))
|
||||
|
||||
(define (align-code code addr alignment header-len)
|
||||
`(,@(make-list (modulo (- alignment
|
||||
(modulo (+ addr header-len) alignment))
|
||||
alignment)
|
||||
'(nop))
|
||||
`(,@(code-alignment addr alignment header-len)
|
||||
,code))
|
||||
|
||||
(define (align-program prog addr)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue