Rebuild WASM: bytecode with pending_cek snapshot fix

All .sxbc recompiled with fixed sx_vm.ml. 32/32 WASM tests, 4/4
bytecode regression tests. hs-repeat-times correctly does 6 io-sleep
suspensions in bytecode mode.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-08 21:44:58 +00:00
parent ddc48c6d48
commit 5e708e1b20
24 changed files with 379 additions and 110 deletions

View File

@@ -137,18 +137,21 @@
code-from-value
(fn
(v)
"Convert a compiler output dict to a vm-code object."
"Convert a compiler output dict to a vm-code dict. Idempotent — if v\n already has vm-code keys (vc-bytecode), returns as-is."
(if
(not (dict? v))
(make-vm-code 0 16 (list) (list))
(let
((bc-raw (get v "bytecode"))
(bc (if (nil? bc-raw) (list) bc-raw))
(consts-raw (get v "constants"))
(consts (if (nil? consts-raw) (list) consts-raw))
(arity-raw (get v "arity"))
(arity (if (nil? arity-raw) 0 arity-raw)))
(make-vm-code arity (+ arity 16) bc consts)))))
(if
(has-key? v "vc-bytecode")
v
(let
((bc-raw (get v "bytecode"))
(bc (if (nil? bc-raw) (list) bc-raw))
(consts-raw (get v "constants"))
(consts (if (nil? consts-raw) (list) consts-raw))
(arity-raw (get v "arity"))
(arity (if (nil? arity-raw) 0 arity-raw)))
(make-vm-code arity (+ arity 16) bc consts))))))
(define vm-closure? (fn (v) (and (dict? v) (has-key? v "vm-code"))))
(define *active-vm* nil)
(define *jit-compile-fn* nil)
@@ -297,27 +300,32 @@
vm-global-get
(fn
(vm frame name)
"Look up a global: globals table → closure env → primitives → HO wrappers"
"Look up a global: closure env → globals table → primitives → HO forms"
(let
((globals (vm-globals-ref vm)))
((closure-env (get (frame-closure frame) "vm-closure-env")))
(if
(has-key? globals name)
(get globals name)
(nil? closure-env)
(let
((closure-env (-> frame frame-closure closure-env)))
((globals (vm-globals-ref vm)))
(if
(nil? closure-env)
(has-key? globals name)
(get globals name)
(cek-try
(fn () (get-primitive name))
(fn (e) (vm-resolve-ho-form vm name)))
(fn (e) (vm-resolve-ho-form vm name)))))
(let
((found (env-walk closure-env name)))
(if
(nil? found)
(let
((found (env-walk closure-env name)))
((globals (vm-globals-ref vm)))
(if
(nil? found)
(has-key? globals name)
(get globals name)
(cek-try
(fn () (get-primitive name))
(fn (e) (vm-resolve-ho-form vm name)))
found))))))))
(fn (e) (vm-resolve-ho-form vm name)))))
found))))))
(define
vm-resolve-ho-form
(fn