diff options
author | Andy Wingo <wingo@pobox.com> | 2009-09-17 14:58:31 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2009-10-16 15:56:11 +0200 |
commit | 97fcf583b7239ea17dbb73eae9438d21136eb2db (patch) | |
tree | f92ae6b6b840255fe58289b9ed3824aac3cbd0c5 /module/language/assembly/decompile-bytecode.scm | |
parent | f95f82f8e183f2744740bdc950dba9c856e09094 (diff) | |
download | guile-97fcf583b7239ea17dbb73eae9438d21136eb2db.tar.gz |
jumps encoded using 24 bits, not 19; blocks no longer aligned
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump.
* libguile/vm-i-system.c (FETCH_OFFSET, BR): Labels are no longer 8-byte
aligned; instead, jumps are encoded into 3 bytes instead of 2.
(br, br-if, br-if-not, br-if-eq, br-if-not-eq, br-if-null)
(br-if-not-null, mv-call): Adapt for new length of br instructions (3
bytes instead of 2).
* libguile/vm.c (really_make_boot_program): Adapt hand-coded bytecode
for new offset regime.
* module/language/assembly.scm (align-block): No alignment necessary.
* module/language/assembly/compile-bytecode.scm (write-bytecode): Write
out breaks as 24-bit relative jumps.
* module/language/assembly/decompile-bytecode.scm (decode-load-program):
Decompile break instructions.
Diffstat (limited to 'module/language/assembly/decompile-bytecode.scm')
-rw-r--r-- | module/language/assembly/decompile-bytecode.scm | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/module/language/assembly/decompile-bytecode.scm b/module/language/assembly/decompile-bytecode.scm index 511c6ccc6..915e101b8 100644 --- a/module/language/assembly/decompile-bytecode.scm +++ b/module/language/assembly/decompile-bytecode.scm @@ -43,11 +43,11 @@ (define (br-instruction? x) (memq x '(br br-if br-if-not br-if-eq br-if-not-eq br-if-null br-if-not-null))) -(define (bytes->s16 a b) - (let ((x (+ (ash a 8) b))) - (if (zero? (logand (ash 1 15) x)) +(define (bytes->s24 a b c) + (let ((x (+ (ash a 16) (ash b 8) c))) + (if (zero? (logand (ash 1 23) x)) x - (- x (ash 1 16))))) + (- x (ash 1 24))))) ;; FIXME: this is a little-endian disassembly!!! (define (decode-load-program pop) @@ -60,9 +60,8 @@ (%unused-pad (begin (pop) (pop) (pop) (pop))) (labels '()) (i 0)) - (define (ensure-label rel1 rel2) - (let ((where (+ (logand i (lognot #x7)) - (* (bytes->s16 rel1 rel2) 8)))) + (define (ensure-label rel1 rel2 rel3) + (let ((where (+ i (bytes->s24 rel1 rel2 rel3)))) (or (assv-ref labels where) (begin (let ((l (gensym ":L"))) @@ -87,9 +86,9 @@ (else (let ((exp (decode-bytecode sub-pop))) (pmatch exp - ((,br ,rel1 ,rel2) (guard (br-instruction? br)) - (lp (cons `(,br ,(ensure-label rel1 rel2)) out))) - ((mv-call ,n ,rel1 ,rel2) + ((,br ,rel1 ,rel2 ,rel3) (guard (br-instruction? br)) + (lp (cons `(,br ,(ensure-label rel1 rel2 rel3)) out))) + ((mv-call ,n ,rel1 ,rel2 ,rel3) (lp (cons `(mv-call ,n ,(ensure-label rel1 rel2)) out))) (else (lp (cons exp out)))))))))) |