VM adapter: compile works, env isolation needed
adapter-sx.sx compiles to 25 code objects (4044 bytes bytecode). vm-load-module loads it. But replacing Lambda values in env.bindings with NativeFn wrappers breaks the CEK machine for non-aser functions. Root cause: shared env.bindings between CEK and VM. The CEK needs Lambda values (for closure merging). The VM needs NativeFn wrappers. Both can't coexist in the same env. Fix needed: VM adapter gets its own globals table (with compiled closures). The aser-slot command routes directly to the VM with its own globals, not through the CEK with shared env. Disabled vm-load-module. Pages render correctly via CEK. Also: OP_CALL_PRIM now logs primitive name + argc in error messages for easier debugging. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -333,13 +333,16 @@ class OcamlBridge:
|
||||
_logger.info("Loaded %d definitions from .sx files into OCaml kernel (%d skipped)",
|
||||
count, skipped)
|
||||
|
||||
# Compile adapter-sx.sx to bytecode and load as VM module.
|
||||
# All aser functions become NativeFn VM closures in the
|
||||
# kernel env. The CEK calls them as NativeFn → VM executes.
|
||||
try:
|
||||
await self._compile_adapter_module()
|
||||
except Exception as e:
|
||||
_logger.warning("VM adapter compilation skipped: %s", e)
|
||||
# VM adapter compilation: compile adapter-sx.sx to bytecode,
|
||||
# load as VM module so aser runs compiled.
|
||||
# DISABLED: vm-load-module replaces env bindings with NativeFn
|
||||
# wrappers that break when the CEK machine calls other env
|
||||
# functions during page eval. Need to isolate VM execution
|
||||
# from CEK env to avoid cross-contamination.
|
||||
# try:
|
||||
# await self._compile_adapter_module()
|
||||
# except Exception as e:
|
||||
# _logger.warning("VM adapter compilation skipped: %s", e)
|
||||
except Exception as e:
|
||||
_logger.error("Failed to load .sx files into OCaml kernel: %s", e)
|
||||
self._components_loaded = False # retry next time
|
||||
|
||||
Reference in New Issue
Block a user