VM aser-slot routing: isolated globals, inner code extraction, debug
aser-slot now routes through the VM when adapter is compiled: - compile_adapter: compiles each define body, extracts inner code from OP_CLOSURE wrapper, stores as NativeFn in separate globals - vm_adapter_globals: isolated from kernel env (no cross-contamination) - aser-slot checks vm_adapter_globals, calls VM aser directly Status: 2/12 adapter functions compile and run on VM. 6 fail during OCaml-side compilation with "index out of bounds" — likely from set-nth! silent failure on ListRef during bytecode jump patching. Debug output shows outer code structure is correct (4 bytes, 1 const). Inner code_from_value conversion needs fixing for nested closures. Also: vm-compile-adapter command inside _ensure_components lock (fixes pipe desync from concurrent requests). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -330,19 +330,15 @@ class OcamlBridge:
|
||||
skipped += 1
|
||||
_logger.warning("OCaml load skipped %s: %s",
|
||||
filepath, e)
|
||||
# Compile adapter to VM after all files loaded (inside lock)
|
||||
try:
|
||||
await self._send('(vm-compile-adapter)')
|
||||
await self._read_until_ok(ctx=None)
|
||||
_logger.info("VM adapter compiled — aser runs on bytecode VM")
|
||||
except OcamlBridgeError as e:
|
||||
_logger.warning("VM adapter compilation skipped: %s", e)
|
||||
_logger.info("Loaded %d definitions from .sx files into OCaml kernel (%d skipped)",
|
||||
count, skipped)
|
||||
|
||||
# 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