Three primitives + a wrapper, all portable across hosts:
with-jit-threshold N body... — temporarily set threshold, restore on exit
with-jit-budget N body... — temporarily set LRU budget
with-fresh-jit body... — clear cache before & after body
jit-report — human-readable stats string for logging
jit-disable! / jit-enable! — convenience around set-budget! 0
The host (OCaml here, will be JS/Python eventually) only needs to provide
the underlying primitives (jit-stats, jit-set-threshold!, jit-set-budget!,
jit-reset-cache!, jit-reset-counters!). The ergonomics live in shared SX.
Used together with Phase 1 (tiered compilation) and Phase 2 (LRU eviction)
to give application developers fine-grained control over the JIT cache:
isolated test runs use with-fresh-jit, hot benchmark sections use
with-jit-threshold 1, memory-constrained pages use jit-set-budget! to
cap the cache.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>