diff options
author | Andy Wingo <wingo@pobox.com> | 2009-10-25 12:41:48 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2009-10-25 13:12:27 +0100 |
commit | 8b652112048ae2c482993897cdf40c5d9a67a8d2 (patch) | |
tree | 77a6913933bdfe702de01eb12c245509cccd5721 | |
parent | df435c83072a79d9fdacbc57d9925ab7c0be5deb (diff) | |
download | guile-8b652112048ae2c482993897cdf40c5d9a67a8d2.tar.gz |
assembly/disassembly support for br-if-nargs-*
* module/language/assembly/compile-bytecode.scm (write-bytecode): Handle
br-if-nargs compilation.
* module/language/assembly/decompile-bytecode.scm (decode-load-program):
And decompile them nicely as well.
* module/language/assembly/disassemble.scm (code-annotation): And,
present the disassembly if br-if-nargs-* nicely.
-rw-r--r-- | module/language/assembly/compile-bytecode.scm | 3 | ||||
-rw-r--r-- | module/language/assembly/decompile-bytecode.scm | 4 | ||||
-rw-r--r-- | module/language/assembly/disassemble.scm | 2 |
3 files changed, 9 insertions, 0 deletions
diff --git a/module/language/assembly/compile-bytecode.scm b/module/language/assembly/compile-bytecode.scm index d92821cc9..e6fc5bc2a 100644 --- a/module/language/assembly/compile-bytecode.scm +++ b/module/language/assembly/compile-bytecode.scm @@ -137,6 +137,9 @@ ((br-if-not-eq ,l) (write-break l)) ((br-if-null ,l) (write-break l)) ((br-if-not-null ,l) (write-break l)) + ((br-if-nargs-ne ,hi ,lo ,l) (write-byte hi) (write-byte lo) (write-break l)) + ((br-if-nargs-lt ,hi ,lo ,l) (write-byte hi) (write-byte lo) (write-break l)) + ((br-if-nargs-gt ,hi ,lo ,l) (write-byte hi) (write-byte lo) (write-break l)) ((mv-call ,n ,l) (write-byte n) (write-break l)) (else (cond diff --git a/module/language/assembly/decompile-bytecode.scm b/module/language/assembly/decompile-bytecode.scm index 6c929cb33..555ee12d7 100644 --- a/module/language/assembly/decompile-bytecode.scm +++ b/module/language/assembly/decompile-bytecode.scm @@ -42,6 +42,8 @@ (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 (br-nargs-instruction? x) + (memq x '(br-if-nargs-ne br-if-nargs-lt br-if-nargs-gt))) (define (bytes->s24 a b c) (let ((x (+ (ash a 16) (ash b 8) c))) @@ -84,6 +86,8 @@ (pmatch exp ((,br ,rel1 ,rel2 ,rel3) (guard (br-instruction? br)) (lp (cons `(,br ,(ensure-label rel1 rel2 rel3)) out))) + ((,br ,hi ,lo ,rel1 ,rel2 ,rel3) (guard (br-nargs-instruction? br)) + (lp (cons `(,br ,hi ,lo ,(ensure-label rel1 rel2 rel3)) out))) ((mv-call ,n ,rel1 ,rel2 ,rel3) (lp (cons `(mv-call ,n ,(ensure-label rel1 rel2 rel3)) out))) (else diff --git a/module/language/assembly/disassemble.scm b/module/language/assembly/disassemble.scm index ae2d32787..2c0ad4fcb 100644 --- a/module/language/assembly/disassemble.scm +++ b/module/language/assembly/disassemble.scm @@ -132,6 +132,8 @@ (list "~a element~:p" (apply make-int16 args))) ((br br-if br-if-eq br-if-not br-if-not-eq br-if-not-null br-if-null) (list "-> ~A" (assq-ref labels (car args)))) + ((br-if-nargs-ne br-if-nargs-lt br-if-nargs-gt) + (list "-> ~A" (assq-ref labels (caddr args)))) ((object-ref) (and objs (list "~s" (vector-ref objs (car args))))) ((local-ref local-boxed-ref local-set local-boxed-set) |