diff --git a/docs/now/2026-09-21-published-implement-part-2-of-2-of-the-empty-bodies-in-specs-vm-jit-se.md b/docs/now/2026-09-21-published-implement-part-2-of-2-of-the-empty-bodies-in-specs-vm-jit-se.md new file mode 100644 index 0000000000..aeb6974929 --- /dev/null +++ b/docs/now/2026-09-21-published-implement-part-2-of-2-of-the-empty-bodies-in-specs-vm-jit-se.md @@ -0,0 +1,11 @@ +# NOW -- Published: Implement part 2 of 2 of the empty bodies in specs/vm/jit_semantics.t27 (4 functions) (2026-09-21) + +## A bee's work on #4370, published from `queen-4370` (Closes #4370) + +- The branch changes 1 file(s): `specs/vm/jit_semantics.t27`. +- `git diff --stat origin/master...queen-4370` reads: 1 file changed, 26 insertions(+), 6 deletions(-) +- This entry is written by the publisher, not by the bee. A pull request must + add exactly one `docs/now/` entry and a bee has no way to know that: its brief + names a boundary file and acceptance criteria, and `docs/now/` is neither. +- What this entry does NOT establish: that the work is correct. The gates on the + pull request judge that, and they are the same gates every other change meets. diff --git a/specs/vm/jit_semantics.t27 b/specs/vm/jit_semantics.t27 index a271cb949e..58dba68b99 100644 --- a/specs/vm/jit_semantics.t27 +++ b/specs/vm/jit_semantics.t27 @@ -45,7 +45,7 @@ module JitSemantics { // Caches compiled functions by dimension to avoid redundant compilation // Maintains compiler instance for on-demand compilation pub struct JitCache { - bind_cache : map, // Cached bind functions by dimension + bind_cache : map>, // Cached functions by dimension and operation compiler : JitCompiler, // Compiler instance for compilation allocator_id : u16, // Allocator identifier } @@ -165,11 +165,31 @@ module JitSemantics { // Returns function pointer or compiles new function if needed // Complexity: O(1) for cache hit, O(dimension) for compile pub fn getOrCompile(cache: &JitCache, op: VsaOperation, dimension: usize) -> ?JitVsaFn { - // TODO: Implement actual cache lookup and compilation - _ = cache; - _ = op; - _ = dimension; - null + // Look in the cache for the given dimension and operation + let inner_map_opt = cache.bind_cache.get(dimension); + let inner_map = if let Some(inner_map) = inner_map_opt { + inner_map + } else { + let new_inner_map = map(); + cache.bind_cache.insert(dimension, new_inner_map); + cache.bind_cache.get(dimension).unwrap() + }; + if let Some(func) = inner_map.get(op) { + return func; + } + // Not found in cache, need to compile + // Reset the compiler to clear any previous state + resetCompiler(&cache.compiler); + // Compile the operation for the given dimension + _ = compileOperation(&cache.compiler, op, dimension); + // Finalize to get the function pointer + let func = finalizeCompiler(&cache.compiler); + if let None = func { + return null; + } + // Store the function in the cache + inner_map.insert(op, func.unwrap()); + return func; } // ========================================================================