diff --git a/plans/jit-cache-architecture.md b/plans/jit-cache-architecture.md index 09900550..bce541c2 100644 --- a/plans/jit-cache-architecture.md +++ b/plans/jit-cache-architecture.md @@ -164,13 +164,22 @@ gets the same API for free. ## Rollout -**Phase 1: Tiered compilation (1-2 days)** -- Add `l_call_count` to lambda type -- Wire counter increment in `cek_call_or_suspend` -- Add `jit-set-threshold!` primitive -- Default threshold = 1 (no change in behavior) -- Bump default to 4 once test suite confirms stability -- Verify: HS conformance full-suite run completes without JIT saturation +**Phase 1: Tiered compilation — IMPLEMENTED (commit b9d63112)** +- ✅ `l_call_count : int` field on lambda type (sx_types.ml) +- ✅ Counter increment + threshold check in cek_call_or_suspend Lambda case (sx_vm.ml) +- ✅ Module-level refs in sx_types: `jit_threshold` (default 4), `jit_compiled_count`, + `jit_skipped_count`, `jit_threshold_skipped_count`. Refs live in sx_types so + sx_primitives can read them without creating an import cycle. +- ✅ Primitives: `jit-stats`, `jit-set-threshold!`, `jit-reset-counters!` (sx_primitives.ml) +- Verified: 4771/1111 OCaml run_tests, identical to baseline — no regressions. + +**WASM rollout note:** The native binary has Phase 1 active. The browser +WASM (`shared/static/wasm/sx_browser.bc.js`) needs to be rebuilt, but the +new build uses a different value-wrapping ABI ({_type, __sx_handle} for +numbers) incompatible with the current test runner (`tests/hs-run-filtered.js`). +For now the test tree pins the pre-rewrite WASM. Resolving the ABI gap +is a separate task — either update the test runner to unwrap, or expose +a value-marshalling helper from the kernel. **Phase 2: LRU cache (3-5 days)** - Extract `Lambda.l_compiled` into central `sx_jit_cache.ml`