mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-15 16:20:17 +02:00
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.
This commit is contained in:
parent
6cf4830798
commit
94ff26b96b
11 changed files with 101 additions and 201 deletions
|
@ -65,11 +65,13 @@
|
|||
(write-byte (logand (ash x -8) 255))
|
||||
(write-byte (logand (ash x -16) 255))
|
||||
(write-byte (logand (ash x -24) 255)))
|
||||
(define (write-uint32 x) (case byte-order
|
||||
((1234) (write-uint32-le x))
|
||||
((4321) (write-uint32-be x))
|
||||
(else (error "unknown endianness" byte-order))))
|
||||
(define (write-uint32 x)
|
||||
(case byte-order
|
||||
((1234) (write-uint32-le x))
|
||||
((4321) (write-uint32-be x))
|
||||
(else (error "unknown endianness" byte-order))))
|
||||
(define (write-wide-string s)
|
||||
(write-loader-len (* 4 (string-length s)))
|
||||
(string-for-each (lambda (c) (write-uint32 (char->integer c))) s))
|
||||
(define (write-loader-len len)
|
||||
(write-byte (ash len -16))
|
||||
|
@ -133,14 +135,11 @@
|
|||
;; `scm_c_make_objcode_slice ()'.
|
||||
(write-bytecode meta write get-addr '()))))
|
||||
((make-char32 ,x) (write-uint32-be x))
|
||||
((load-unsigned-integer ,str) (write-loader str))
|
||||
((load-integer ,str) (write-loader str))
|
||||
((load-number ,str) (write-loader str))
|
||||
((load-string ,str) (write-sized-loader str))
|
||||
((load-symbol ,str) (write-sized-loader str))
|
||||
((load-keyword ,str) (write-sized-loader str))
|
||||
((load-string ,str) (write-loader str))
|
||||
((load-wide-string ,str) (write-wide-string str))
|
||||
((load-symbol ,str) (write-loader str))
|
||||
((load-array ,bv) (write-bytevector bv))
|
||||
((define ,str) (write-sized-loader str))
|
||||
((br ,l) (write-break l))
|
||||
((br-if ,l) (write-break l))
|
||||
((br-if-not ,l) (write-break l))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue