summaryrefslogtreecommitdiff
path: root/module/language/assembly/decompile-bytecode.scm
diff options
context:
space:
mode:
authorAndy Wingo <wingo@oblong.net>2009-08-12 16:33:49 +0200
committerAndy Wingo <wingo@oblong.net>2009-08-12 16:34:05 +0200
commit94ff26b96b555f0263fab2221cd55801119ffddd (patch)
tree6911dde6ef41d2b87eb9cfa6b857e7692bc21ac1 /module/language/assembly/decompile-bytecode.scm
parent6cf48307989d2552f2215ef8406ea92745d2d3e9 (diff)
downloadguile-94ff26b96b555f0263fab2221cd55801119ffddd.tar.gz
rework the vm support for wide strings
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump. * libguile/vm-engine.c (vm_error_bad_wide_string_length): New error case. * libguile/vm-i-loader.c (load-unsigned-integer, load-integer) (load-keyword): Remove these instructions. The former two are obsoleted by make-int64/make-uint64, the latter via make-keyword. (load-string): Only handle narrow strings. (load-symbol): Only handle narrow symbols. The wide case is handled via make-symbol. (load-wide-string): New instruction, for wide strings. * libguile/vm-i-system.c (define): Move here from loaders.c, as now it just takes a sym on the stack. (make-keyword, make-symbol): New instructions. * module/language/assembly.scm: Remove removed instructions. No more width byte in load-string etc. * module/language/assembly/compile-bytecode.scm (write-bytecode): Adapt to change in instruction set. * module/language/glil/compile-assembly.scm (glil->assembly): Compile define by pushing the sym then emitting (define). (dump-object): Dump narrow and wide strings differently. Use make-keyword and make-symbol as appropriate. * module/language/tree-il/compile-glil.scm (flatten): When compiling a ref to a primitive (not a call), first see if the primitive is actually bound in the root module. (That's not the case with e.g. bytevector-u8-ref). * module/system/xref.scm (program-callee-rev-vars): Don't parse out "nexts". * test-suite/tests/asm-to-bytecode.test ("compiler"): Adapt to bytecode format change.
Diffstat (limited to 'module/language/assembly/decompile-bytecode.scm')
-rw-r--r--module/language/assembly/decompile-bytecode.scm27
1 files changed, 6 insertions, 21 deletions
diff --git a/module/language/assembly/decompile-bytecode.scm b/module/language/assembly/decompile-bytecode.scm
index a05db537d..8cdebcfd0 100644
--- a/module/language/assembly/decompile-bytecode.scm
+++ b/module/language/assembly/decompile-bytecode.scm
@@ -96,16 +96,6 @@
(lp (cons exp out))))))))))
(define (decode-bytecode pop)
- (define (get1 bytes-per-char)
- (if (= bytes-per-char 1)
- (pop)
- (let* ((a (pop))
- (b (pop))
- (c (pop))
- (d (pop)))
- (if (= byte-order 1234)
- (+ (ash d 24) (ash c 16) (ash b 8) a)
- (+ (ash a 24) (ash b 16) (ash c 8) d)))))
(and=> (pop)
(lambda (opcode)
(let ((inst (opcode->instruction opcode)))
@@ -117,29 +107,24 @@
;; the negative length indicates a variable length
;; instruction
(let* ((make-sequence
- (if (eq? inst 'load-array)
+ (if (or (memq inst '(load-array load-wide-string)))
make-bytevector
make-string))
(sequence-set!
- (if (eq? inst 'load-array)
+ (if (or (memq inst '(load-array load-wide-string)))
bytevector-u8-set!
(lambda (str pos value)
(string-set! str pos (integer->char value)))))
(len (let* ((a (pop)) (b (pop)) (c (pop)))
(+ (ash a 16) (ash b 8) c)))
- (bytes-per-count
- (if (or (eq? inst 'load-string)
- (eq? inst 'load-symbol)
- (eq? inst 'load-keyword)
- (eq? inst 'define))
- (pop)
- 1))
(seq (make-sequence len)))
(let lp ((i 0))
(if (= i len)
- `(,inst ,seq)
+ `(,inst ,(if (eq? inst 'load-wide-string)
+ (utf32->string seq)
+ seq))
(begin
- (sequence-set! seq i (get1 bytes-per-count))
+ (sequence-set! seq i (pop))
(lp (1+ i)))))))
(else
;; fixed length