diff options
author | Andy Wingo <wingo@pobox.com> | 2009-07-26 14:01:56 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2009-07-26 14:01:56 +0200 |
commit | e5dc27b86d0eaa470f92cdaa9f4ed2a961338c49 (patch) | |
tree | c8c46f9c5995fd22c42f072faefacd7d075193fb /libguile | |
parent | 28b119ee3da0f4b14cb87e638794d22843778cda (diff) | |
download | guile-e5dc27b86d0eaa470f92cdaa9f4ed2a961338c49.tar.gz |
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.
Diffstat (limited to 'libguile')
-rw-r--r-- | libguile/objcodes.c | 2 | ||||
-rw-r--r-- | libguile/vm-i-system.c | 20 | ||||
-rw-r--r-- | libguile/vm.c | 2 |
3 files changed, 13 insertions, 11 deletions
diff --git a/libguile/objcodes.c b/libguile/objcodes.c index 728dd8d13..91691a70a 100644 --- a/libguile/objcodes.c +++ b/libguile/objcodes.c @@ -50,7 +50,7 @@ /* The objcode magic header. */ #define OBJCODE_COOKIE \ - "GOOF-0.8-" OBJCODE_ENDIANNESS "-" OBJCODE_WORD_SIZE "---" + "GOOF-0.9-" OBJCODE_ENDIANNESS "-" OBJCODE_WORD_SIZE "---" /* The length of the header must be a multiple of 8 bytes. */ verify (((sizeof (OBJCODE_COOKIE) - 1) & 7) == 0); diff --git a/libguile/vm-i-system.c b/libguile/vm-i-system.c index b2cdca5be..726112c8a 100644 --- a/libguile/vm-i-system.c +++ b/libguile/vm-i-system.c @@ -426,7 +426,7 @@ VM_DEFINE_INSTRUCTION (34, long_toplevel_set, "long-toplevel-set", 2, 1, 0) * branch and jump */ -/* offset must be a signed short!!! */ +/* offset must be a signed 16 bit int!!! */ #define FETCH_OFFSET(offset) \ { \ int h = FETCH (); \ @@ -436,10 +436,10 @@ VM_DEFINE_INSTRUCTION (34, long_toplevel_set, "long-toplevel-set", 2, 1, 0) #define BR(p) \ { \ - signed short offset; \ + scm_t_int16 offset; \ FETCH_OFFSET (offset); \ if (p) \ - ip += offset; \ + ip += ((scm_t_ptrdiff)offset) * 8 - (((unsigned long)ip) % 8); \ NULLSTACK (1); \ DROP (); \ NEXT; \ @@ -447,9 +447,9 @@ VM_DEFINE_INSTRUCTION (34, long_toplevel_set, "long-toplevel-set", 2, 1, 0) VM_DEFINE_INSTRUCTION (35, br, "br", 2, 0, 0) { - int h = FETCH (); - int l = FETCH (); - ip += (signed short) (h << 8) + l; + scm_t_int16 offset; + FETCH_OFFSET (offset); + ip += ((scm_t_ptrdiff)offset) * 8 - (((unsigned long)ip) % 8); NEXT; } @@ -812,10 +812,12 @@ VM_DEFINE_INSTRUCTION (46, call_nargs, "call/nargs", 0, 0, 1) VM_DEFINE_INSTRUCTION (47, mv_call, "mv-call", 3, -1, 1) { SCM x; - signed short offset; + scm_t_int16 offset; + scm_t_uint8 *mvra; nargs = FETCH (); FETCH_OFFSET (offset); + mvra = ip + ((scm_t_ptrdiff)offset) * 8 - ((unsigned long)ip) % 8; x = sp[-nargs]; @@ -828,7 +830,7 @@ VM_DEFINE_INSTRUCTION (47, mv_call, "mv-call", 3, -1, 1) CACHE_PROGRAM (); INIT_ARGS (); NEW_FRAME (); - SCM_FRAME_DATA_ADDRESS (fp)[1] = (SCM)(SCM_FRAME_RETURN_ADDRESS (fp) + offset); + SCM_FRAME_DATA_ADDRESS (fp)[1] = (SCM)mvra; ENTER_HOOK (); APPLY_HOOK (); NEXT; @@ -853,7 +855,7 @@ VM_DEFINE_INSTRUCTION (47, mv_call, "mv-call", 3, -1, 1) len = scm_length (values); PUSH_LIST (values, SCM_NULLP); PUSH (len); - ip += offset; + ip = mvra; } NEXT; } diff --git a/libguile/vm.c b/libguile/vm.c index 527598b86..cc5e4f924 100644 --- a/libguile/vm.c +++ b/libguile/vm.c @@ -226,7 +226,7 @@ really_make_boot_program (long nargs) SCM u8vec; /* Make sure "bytes" is 64-bit aligned. */ scm_t_uint8 text[] = { scm_op_mv_call, 0, 0, 1, - scm_op_make_int8_1, + scm_op_make_int8_1, scm_op_nop, scm_op_nop, scm_op_nop, scm_op_halt }; struct scm_objcode *bp; SCM ret; |