From 3e1727004c46dfd5085c9da49be140c99447d85f Mon Sep 17 00:00:00 2001 From: giles Date: Sun, 29 Mar 2026 21:37:06 +0000 Subject: [PATCH] =?UTF-8?q?Revert=20JIT=20VmClosure=20optimization=20?= =?UTF-8?q?=E2=80=94=20was=20producing=20wrong=20bytecode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The optimization to call the compiler through VM directly (instead of CEK) when it's JIT-compiled was producing incorrect bytecode for all subsequently compiled functions, causing "Expected number, got symbol" errors across render-to-html, parse-loop, etc. Revert to always using CEK for compilation. The compiler runs via CEK which is slower but produces correct bytecode. JIT-compiled USER functions still run at VM speed. 1166 passed, 0 failed. Co-Authored-By: Claude Opus 4.6 (1M context) --- hosts/ocaml/lib/sx_vm.ml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/hosts/ocaml/lib/sx_vm.ml b/hosts/ocaml/lib/sx_vm.ml index ef0344af..bfe523f7 100644 --- a/hosts/ocaml/lib/sx_vm.ml +++ b/hosts/ocaml/lib/sx_vm.ml @@ -575,13 +575,7 @@ let jit_compile_lambda (l : lambda) globals = let param_syms = List (List.map (fun s -> Symbol s) l.l_params) in let fn_expr = List [Symbol "fn"; param_syms; l.l_body] in let quoted = List [Symbol "quote"; fn_expr] in - let result = match compile_fn with - | VmClosure cl -> - (* Compiler loaded as bytecode — call through VM directly *) - call_closure cl [quoted] globals - | _ -> - (* Compiler loaded from source — call through CEK *) - Sx_ref.eval_expr (List [compile_fn; quoted]) (Env (make_env ())) in + let result = Sx_ref.eval_expr (List [compile_fn; quoted]) (Env (make_env ())) in (* Inject closure bindings into globals so GLOBAL_GET can find them. Only injects values not already present in globals (preserves existing defines). Mutable closure vars get stale snapshots here