quickjs-jit 0.14.1

JIT-enabled high level bindings to the QuickJS JavaScript engine
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
# M3: generic native entry overhead (in progress)

The next performance target after M2 is the generic `CALL` boundary. Numeric
direct calls already bypass that boundary; the `generic-call-entry` probe uses
a short `(Int32, Bool)` callee to keep the generic path measurable.

## Implemented: one idle C entry handle

QuickJS can retain one idle pc=0 entry handle per runtime. A cache hit transfers
ownership out of the cache into the active invocation. Recursive calls acquire
their own handles. A successful return can move a handle back into the cache;
replacement, a non-DONE exit, or an epoch mismatch releases it. Detach releases
the idle handle before destroying the backend. OSR handles are never cached.
Cache population is suppressed across release callbacks, so a reentrant
release cannot leave another backend-owned handle behind during detach or
overwrite one during eviction. Entry identity is captured before acquisition;
active exits retain their original generation after a reentrant retirement.

This bounds retained idle code to one artifact, including when the application
stops calling JavaScript. Its execution pin remains charged to the code cache.
Idle retention does not retain arguments, locals, stack pointers, or JavaScript
function objects. Function identity and generation must match on every hit.

The optional `entry_cache_epoch` backend query opts into this ownership contract.
It must be pure. Zero disables caching; an invalidated nonzero epoch must never
be reactivated. The production backend invalidates its epoch before maintenance
can install, demote, retire, or reclaim code, and on the direct-refresh path
outside maintenance. Changed feedback or pending coordinator work disables a
hit until acquisition runs maintenance. Epoch exhaustion permanently disables
caching. ABI minor 20 and the extended vtable fingerprint reject old layouts;
the execution-frame and helper ABI layouts are unchanged.
DEOPT also invalidates immediately: side-exit accounting can demote optimizing
code before periodic maintenance, while another recursive frame is still live.

Cached entries still call the production trampoline, validate their frames,
record return feedback, and run exact `native_enter`/`native_exit` callbacks.
Per-function tier attribution persists across cache hits, while each active
invocation retains its tier in the recursive timing stack. The new
`native_acquisitions` metric counts successfully acquired handles independently
from `native_entries`, making reuse visible in benchmark evidence. Historical
benchmark JSON without this optional field remains readable.

## Verification

The cache lifecycle test failed before the C cache was implemented (two
acquisitions for two calls) and passed afterward (one acquisition). Coverage
also checks epoch changes, disabling the cache, suspension/resumption, detach,
recursive active-pin isolation, GC during recursion, invalidation while outer
frames remain active, and function-generation changes. Review identified and
regression tests reproduced immediate-demotion invalidation and reentrant-release
leaks; both fixes passed a second independent read-only review. An additional
test reproduced active-exit generation misattribution and passes with captured
entry identity.

The production generic-call probe verifies the checksum, exactly 1,000 generic
`CALL` helpers, at least 1,001 native entries, and fewer than 100 acquisitions
for a steady batch. This distinguishes entry reuse from a benchmark silently
switching to direct calls or the interpreter.

Relevant commands:

```sh
cargo fmt --all -- --check
cargo clippy --all --all-targets --features full-async,bindgen -- -D warnings
cargo test -p quickjs-jit-sys --test jit_patch
cargo test -p quickjs-jit-runtime --features compiler,test-support --tests
cargo test --manifest-path benchmarks/Cargo.toml --bins
```

Local verification so far: 506 debug runtime tests before the review fixes;
197 targeted runtime tests after those fixes; 11 patch tests; 24 benchmark
tests; full-workspace Clippy and formatting. The current native-boundary and
Tier 1 call suites also pass AddressSanitizer (39 tests) using nightly,
`CC=clang`, `RUSTFLAGS=-Zsanitizer=address`, `-Zbuild-std`, and native
`x86_64-unknown-linux-gnu`. LeakSanitizer required running outside the filesystem
sandbox to inspect threads. The final full release runtime suite passes all
508 tests across 37 test groups.

## Remaining work

### Native return handoff

The production trampoline now hands a native return type to `native_exit`
through an inline `Mutex<Option<PendingNativeReturn>>`, replacing the per-call
HashMap entry and allocated VecDeque. The pending value retains the exact
function identity and generation. It does not retain a JavaScript value.

The single-slot bound follows the actual C ordering: the trampoline publishes
only after the native body returns and then immediately returns to C; C invokes
`native_exit`, which consumes the observation before processing feedback or
calling `release_entry`. An inner recursive return is consumed before its outer
native body can finish. No JavaScript reentry or allocation occurs between
publication and consumption. A debug assertion detects an unconsumed handoff;
identity mismatch leaves the observation intact for the matching consumer.

The identity/type/recursive-order unit test passed before and after this
behavior-preserving change. Independent review found no path allowing multiple
pending returns. Verification after this change: 117 focused tests, the full
509-test release runtime suite, 39 AddressSanitizer tests, and full-workspace
Clippy. Three-version paired comparisons against M2 and the cache-only binary
pin worker processes to P-core CPU 0. The completed generic-call result is in
[`m3-native-return-generic-paired.json`](../benchmarks/results/m3-native-return-generic-paired.json),
with the same 5/30/10 sampling policy and embedded reproduction driver.

| Requested mode | Speed relative to cache-only binary | Speed relative to M2 |
| --- | ---: | ---: |
| Tier 1 | 1.058x (5.6%–6.1% faster) | 1.200x |
| Forced Tier 2 (actually Tier 1) | 1.070x (6.6%–7.3% faster) | 1.283x |
| Automatic (actually Tier 1) | 1.076x (7.4%–7.9% faster) | 1.319x |

The parenthesized intervals are paired 95% confidence intervals. The interpreter
is statistically tied with the cache-only binary: between 0.9% slower and 0.8%
faster. Against M2 it is 1.014x speed, with a 0.3%–2.2% faster interval. This
addresses the wide interpreter interval for this focused workload; it does not
prove broader startup, reload, or tail-latency acceptance. The completed
[`direct-call control`](../benchmarks/results/m3-native-return-call-heavy-paired.json)
is statistically tied with M2 in all four modes. Its lowest speed confidence
bound is 0.980x M2's speed (about 2.0% slower), staying within the 5% steady-state
regression threshold. Against cache-only, the Tier 1 result is 1.004x speed;
other modes are tied. The completed
[`recursive control`](../benchmarks/results/m3-native-return-fibonacci-recursive-paired.json)
is 1.112x M2 speed in Tier 1 (9.8%–12.2% faster), and 1.059x cache-only speed
(4.6%–6.9% faster). Other modes are statistically tied. Automatic mode has zero
native entries in every fresh-process sample for all three binaries, so this
mode provides interpreter-path control evidence only. The
[`scalar-loop control`](../benchmarks/results/m3-native-return-scalar-loop-paired.json)
is tied with M2 in interpreter and Tier 1 modes; Tier 2 is 1.019x M2 speed
(1.0%–3.8% faster), and automatic mode is 1.037x (3.2%–4.3% faster). Against
cache-only, automatic mode is 1.032x (2.5%–3.6% faster). All four workload runs
completed with matching checksums, balanced entries/exits, and unchanged binary
and script hashes. These controls show no material steady-state regression;
startup, reload, tail latency, and clean-source acceptance remain unverified.

The paired diagnostic comparison is recorded in
[`m3-entry-cache-paired.json`](../benchmarks/results/m3-entry-cache-paired.json),
including executable hashes, exact driver source, host information, all raw
worker outputs, and throughput windows. It alternates the preserved M2 binary
and the candidate binary, with five discarded warmup processes, 30 fresh-process
pairs, ten one-second-minimum throughput windows per engine/mode, and 10,000
paired bootstrap resamples. Throughput counts whole fresh worker processes,
including setup and warmup, rather than isolated JavaScript calls.

| Requested mode | Candidate speed relative to M2 binary | Paired 95% interval |
| --- | ---: | --- |
| Tier 1 | 1.144x | 13.9%–14.7% faster |
| Forced Tier 2 (actually Tier 1 here) | 1.207x | 20.2%–21.8% faster |
| Automatic (actually Tier 1 here) | 1.228x | 22.3%–23.2% faster |
| Interpreter | 0.982x, statistically tied | Between 16.1% slower and 6.2% faster |

Every checksum matches, native entries/exits balance, and candidate samples
record no fallbacks or deoptimizations. The median acquired-handle fraction is
3.6% of native entries in Tier 1 and 3.2% in the other JIT modes. These counters
include warmup; the integration test separately verifies steady-batch reuse.

This first-stage run is dirty-tree diagnostic evidence, not the clean-source
benchmark acceptance gate. Its wide interpreter interval is superseded for this
focused workload by the pinned follow-up above. The pinned call-heavy, recursive, and numeric controls above are complete;
these focused controls do not establish the full benchmark acceptance matrix. Even
with the first-stage improvement, automatic mode was only about 0.15x the
candidate interpreter's speed on this generic-call probe.

Per-call hot probes, epoch queries, frame validation, return feedback, timing,
and entry/exit callbacks remain. This change removes repeated handle acquisition
and release on cache hits, including their allocation and pin bookkeeping; it
does not yet remove all C/Rust callbacks from the generic call path. Measure the
remaining costs before choosing the next step. Cross-platform CI and sanitizer
coverage beyond the local AddressSanitizer run remain necessary before merge.
### CALL feedback buffer reuse

`ProductionBackend::record_feedback` now reuses a backend-owned `Vec` for CALL
argument/result types. Consumers finish synchronously, copy the enum values,
and do not reenter JavaScript or retain the slice. The buffer clears before each
event, preserves arbitrary arity and order, and validates the entire event
before changing feedback. It retains capacity for the largest observed event
until the backend is dropped; it contains no JavaScript values or GC roots.

A thread-local allocation counter in the unit-test build observed 400 allocation
or reallocation calls for 100 stable 32-type CALL events before this change,
and zero afterward. Both function-entry and call-site events are covered.
The semantic test checks wide mixed arguments, return-slot separation, exact
callee identity, whole-event rejection on an invalid final type, and a shorter
subsequent event. Independent review found no actionable issues.

Final code verification: 511 release runtime tests, 39 AddressSanitizer tests,
and full-workspace Clippy passed. Earlier paired reports identify the pre-buffer
binary by its hash; they are not timings of this final incremental change.


The final buffer-reuse paired diagnostic is archived in
[`m3-call-feedback-generic-paired.json`](../benchmarks/results/m3-call-feedback-generic-paired.json).
Relative to M2, automatic mode is 1.359x speed (32.1%–49.3% faster, paired 95%
interval). Relative to the pre-buffer version, its result is statistically tied:
between 3.6% slower and 14.0% faster. All four modes are tied against that
incremental baseline; the zero-allocation regression proves the allocation
reduction, while this timing run does not establish its incremental speedup.
The same 5/30/10 sampling, unchanged executable/script hashes, checksum agreement,
and balanced native entries/exits were verified.

PR #18's coverage job exposed a formatting mismatch between bundled and fresh
bindgen output for the new callback type (line wrapping and a trailing comma;
no type or offset difference). The exact bindgen-enabled ABI test failed locally
before correcting all ten bundles. The complete 15-test bindgen ABI suite then
passed. This adds fresh-bindgen execution to the final verification coverage;
the earlier release suite without `bindgen` did not exercise that comparison.


### Complete clean-source matrix

The complete 22-workload, four-mode matrix was measured from clean source
`4d0a35bafa321766c5f4be44fd2258309ac384f5` on P-core CPU 0. It is archived as
[`raw evidence`](../benchmarks/results/m3-clean-matrix.json),
[`generated report`](../benchmarks/results/m3-clean-matrix.md), and
[`launch provenance`](../benchmarks/results/m3-clean-matrix-launch.json).
Every workload/mode has 5 discarded warmups, 30 fresh-process samples and 10
one-second-minimum throughput windows. All 2,640 retained latency samples match
their interpreter checksum and balance native entries/exits. The unchanged
binary SHA-256, clean source revision and complete workload set were checked.
The reporter accepted the evidence and generated its report; its exit status 1
indicates failed performance gates, not invalid or incomplete measurement data.

The complete acceptance gate does **not** pass:

- Forced Tier 2 compute geometric-mean speed is 3.17x–3.23x the interpreter,
  below the required 5x lower bound.
- At least one designated kernel exceeds the 10x lower bound: the iterative
  Fibonacci interval is 38.35x–39.29x interpreter speed. Every strict sample has
  its required native tier, and automatic profitability-policy evidence passes.
- Automatic startup speed is 0.393x–0.406x interpreter startup speed; definition
  reload speed is 0.841x–0.877x. Both fail the 5% regression gate. Aggregate P99
  latency passes (27.0%–35.0% lower latency); this does not establish real host
  rendering or reload performance.
- Real `gpui-shell` evidence remains absent from this matrix.

These are paired 95% intervals. The raw report retains the original latency
ratios for phase gates; the speed values above invert those intervals.
This run compares JIT modes with the interpreter in the final binary, not with
M2. The earlier revision-paired diagnostics establish the M2 comparison.
Generic-call automatic mode remains only about 0.12x the interpreter's speed,
and property-heavy about 0.06x. Entry acquisition/allocation reductions are
measurable progress but do not complete native-call overhead or broad acceptance.
Remaining per-call callbacks, frame validation and profiling still need work.

The report's missing-entry label was clarified after measurement: Tier1/Tier2
columns require the requested tier, while automatic accepts either native tier.
A forced Tier 2 worker that entered only Tier 1 must not be labeled as having
no native entries at all. Only explanatory wording changed; every metric and
gate result was checked against the original generated report.


### Helper PC validation cursor

The next profile isolated repeated instruction-boundary scans in
`qjsjit_validate_helper_frame`: 36.08% of self sampled cycles in the enlarged
Tier 1 generic-call probe. Patch 0011 keeps one validated bytecode offset per
private `JSFunctionBytecode`. Forward queries resume decoding at that proven
boundary, backward queries start at zero, and generation invalidation resets
the cursor. Both function creation paths zero-initialize it. Published bytecode
instruction lengths do not change; any future mutation of those lengths must
reset this field before the changed bytecode is used.

The range check still precedes reuse. Successful instruction boundaries are
accepted before inspecting their opcode, preserving the previous behavior even
for malformed opcodes at that boundary. End-of-buffer acceptance still depends
on `allow_end` and is not cached. No frame identity, stack-map, exception, GC,
slot ownership, or public ABI checks are removed.

The new helper integration test visits every decoded boundary forward,
backward, and repeatedly, including the end; rejects every operand byte and
out-of-range PCs; and checks borrowed argument ownership after rejection. It
passes on both implementations. A deliberate mutation accepting operand PCs
fails this test; restoring boundary validation passes. The candidate passes
512 release runtime tests, 55 AddressSanitizer/LeakSanitizer tests, 15
bindgen-enabled ABI tests, 11 patch tests, and full-workspace Clippy. Independent
review found no remaining safety issue.

The follow-up profile reduces helper-frame validation to 18.24% of self sampled
cycles. This is diagnostic attribution, not an overall speed claim: it includes
setup, compilation and warmup, and uses a profiling-only script with 100 times
the normal loop iterations. Commands, both worker outputs, script source,
binary hashes and symbol reports are in
[`m3-pc-cursor-profile.json`](../benchmarks/results/m3-pc-cursor-profile.json).
Hashing, feedback observation and tier-state queries remain substantial costs.


The unchanged registered scripts were measured with 5 discarded warmups, 30
rotating paired fresh processes per mode, 10 one-second-minimum throughput
windows per engine/mode, and 10,000 paired bootstrap resamples on CPU 0. These
are dirty-source revision diagnostics; the earlier clean-source matrix does
not measure patch 0011. The archived driver key `entry_cache` now identifies
the complete pre-cursor version, including return handoff and CALL feedback
reuse, not the earlier cache-only stage. Some local verification overlapped on
CPUs 2–15; focused latency repeats below ran after those processes completed.

| Workload / mode | Speed relative to pre-cursor version | Paired 95% interval |
|---|---:|---:|
| Generic call / Tier 1 | 1.135x | 1.133x–1.137x |
| Generic call / requested Tier 2, actually Tier 1 | 1.033x | 1.032x–1.036x |
| Generic call / automatic, actually Tier 1 | 1.007x | 1.005x–1.009x |
| Direct call / Tier 1 | 2.226x | 2.216x–2.252x |
| Recursive Fibonacci / Tier 1 | 1.108x | 1.106x–1.111x |

Generic-call automatic mode is 1.356x M2 speed in this run (35.3%–35.9%
faster). Interpreter comparisons are statistically tied for all four probes;
automatic recursion has zero native entries and is only an interpreter-path
control. All checksums agree and native entries/exits balance. Exact binaries,
script hashes, patch source, driver source and raw measurements are archived:

- [Generic calls]../benchmarks/results/m3-pc-cursor-generic-call-entry-paired.json
- [Direct calls]../benchmarks/results/m3-pc-cursor-call-heavy-paired.json
- [Recursive Fibonacci]../benchmarks/results/m3-pc-cursor-fibonacci-recursive-paired.json
- [Scalar loop]../benchmarks/results/m3-pc-cursor-scalar-loop-paired.json

There is a small measured tradeoff in other modes. The initial direct-call
Tier 2/automatic results were 0.979x/0.986x pre-cursor speed. A separate
60-pair latency repeat finds Tier 2 statistically tied (between 2.2% slower and
0.5% faster), but automatic still 0.979x speed (1.3%–3.3% slower). Scalar-loop
Tier 2 is 0.982x speed initially and 0.985x on repeat (1.1%–2.2% slower);
automatic scalar-loop timing is tied on both runs (repeat range: 1.0% slower
to 0.1% faster). These decreases are within the existing 5% tolerance in these
probes, but their cause has not been isolated and they must not be described
as no regression. Both repeats, including raw samples and executable hashes,
are archived as [direct-call repeat](../benchmarks/results/m3-pc-cursor-call-heavy-recheck.json)
and [scalar-loop repeat](../benchmarks/results/m3-pc-cursor-scalar-loop-recheck.json).
The broader performance acceptance gate and real host evidence remain open.


### Native execution timing stack

After PR #18 merged as `a38bd01`, profiling still attributed substantial
cycles to hash lookups on native enter and exit. The active timing records now
use one `Vec<(FunctionKey, Instant, Tier)>` rather than a hash map of per-function
vectors. Each enter pushes its original key and tier; a matching exit consumes
the top record. An empty or mismatched exit leaves other active records intact.
Counters, clock reads, return feedback, profitability accounting and exact
metric publication remain in place.

C brackets every actual native entry with a synchronous enter/exit pair,
including OSR, recursion and all exit kinds. Release callbacks occur after exit
accounting, and any reentry completes its own nested pair. Invalidation retains
the captured identity; retirement must not discard active timing records.
Suspension/detach reject active backend depth. Numeric direct calls bypass both
callbacks, so they cannot introduce unmatched timing records. Independent
lifecycle and implementation reviews found no remaining issue.

The allocation regression measures only the timing-record insertion for 100
sequential distinct functions after warming one active slot. The old map
allocated/reallocated 105 times; the stack allocates zero times. Profile creation
on exit is intentionally outside that measurement. Additional tests preserve
original recursive tiers through retirement, OSR/retry/deopt/exception exits,
and unmatched/empty callback handling. The candidate passes 515 release runtime
tests, 87 AddressSanitizer/LeakSanitizer tests, and full-workspace Clippy.

The enlarged Tier 1 diagnostic profile is archived in
[`m3-timing-stack-profile.json`](../benchmarks/results/m3-timing-stack-profile.json).
It records sampled attribution and reproduction inputs, not a speed acceptance
result. The remaining feedback tables, tier-state queries, helper validation,
clock reads and metric publication are still significant costs.


### Tier 2 benchmark readiness correction

The initial timing-stack control exposed a benchmark defect: forced Tier 2
started timing after any Tier 2 entry, including a leaf whose caller was still
being compiled. In the direct-call diagnostic, 11 of 30 candidate samples and
4 of 30 pre-stack samples exceeded 1 ms; the remaining samples were near
0.32 ms. Those broad, bimodal intervals cannot establish settled steady-state
performance. The original raw evidence remains archived in
`m3-timing-stack-*-paired.json`, with the exact old harness source and this
limitation attached. Its native counters include warmup and must not be read
as steady-state entry deltas.

`call-heavy.js` now declares four required publications for forced Tier 2:
two baseline and two optimizing artifacts. Readiness also requires actual
Tier 2 execution and drained worker/snapshot queues. An unrelated blacklist
cannot bypass the explicit requirement. Both optimized modes execute bounded
settling iterations with unchanged publication and snapshot-request counts.
The explicit forced-Tier2 path checks readiness again after the OSR probe and
rejects compilation during timing before any post-timing drain can hide it.
Unsupported probes without the declaration remain eligible for bounded fallback.

The leaf-only readiness regression fails before the fix. The corrected harness
passes all 28 benchmark tests, including a real direct-call test whose ten
1,000-iteration invocations add only 10–20 Tier 2 entries after settling, with
no new publication, fallback or retry. The two new forced-Tier2 tests also pass
AddressSanitizer/LeakSanitizer. Independent review caught the changed script's
stale lock hash; that hash was updated. An audit also corrected three existing
stale local hashes (property-heavy, float64-dense and arrays-typed), without
changing those workload bodies. Historical reports retain their original
provenance; their recorded hashes were not rewritten.

Both the merged `a38bd01` runtime and the timing-stack runtime were rebuilt
with the same corrected harness for fresh paired measurements. In the new
30-pair direct-call Tier 2 comparison, all 60 samples were between 0.315 and
0.405 ms; none exceeded 1 ms. The two runtimes are statistically tied on this
path. Use the corrected-harness reports for current performance conclusions.


The corrected-harness comparison uses five discarded warmups, 30 fresh paired
processes, ten one-second-minimum throughput windows per engine/mode, and
10,000 paired bootstrap resamples on CPU 0. Engine order alternates independently
of mode order: each engine runs first 15 times per latency mode and five times
per throughput mode. An earlier two-engine run had coupled rotations that
failed to balance order; the final reports replace that run. All checksums agree and native
entries/exits balance. The baseline is the merged M3 runtime (`a38bd01`), not
M2. These are dirty-source diagnostics; they do not replace the full clean-source
acceptance matrix.

| Workload / mode | Timing-stack speed relative to merged M3 | Paired 95% interval |
|---|---:|---:|
| Generic call / Tier 1 | 1.016x | 0.627x–1.040x (tied) |
| Generic call / requested Tier 2, actually Tier 1 | 1.006x | 1.002x–1.010x |
| Generic call / automatic, actually Tier 1 | 1.011x | 1.000094x–1.015646x |
| Recursive Fibonacci / Tier 1 | 1.029x | 0.907x–1.184x (tied) |
| Scalar loop / Tier 2 | 1.011x | 1.002x–1.024x |
| Scalar loop / automatic | 1.007x | 1.002x–1.015x |

All direct-call modes, all recursive modes, and all interpreter comparisons
are statistically tied. Direct-call Tier 2 is between 0.3% slower and 0.5%
faster. Generic Tier 1 has substantial long tails in both engines and is tied
between 37.3% slower and 4.0% faster; recursive Tier 1 is tied between 9.3%
slower and 18.4% faster. Their causes have not been isolated, and the earlier
narrow Tier 1 improvement intervals are not supported by this final run.
The generic automatic interval only narrowly excludes parity. Scalar-loop
improvements are controls and do not establish a timing-stack-specific cause.
Automatic recursion again has zero native entries and is only an
interpreter-path control. These measurements do not establish an overall
speedup or no-regression result. The fresh runtime comparison, balanced
execution orders, and exact harness source are archived together:

- [Generic calls]../benchmarks/results/m3-timing-stack-settled-generic-call-entry-paired.json
- [Direct calls]../benchmarks/results/m3-timing-stack-settled-call-heavy-paired.json
- [Recursive Fibonacci]../benchmarks/results/m3-timing-stack-settled-fibonacci-recursive-paired.json
- [Scalar loop]../benchmarks/results/m3-timing-stack-settled-scalar-loop-paired.json

The per-call bookkeeping target remains active. Repeated coordinator tier-state
queries and repeated B-tree searches in feedback observation are the next
identified costs; no implementation of those follow-ups is included here.


### Feedback and tier-query consolidation

The follow-up to timing-stack commit `35edb4c` uses a single B-tree entry
lookup in `observe_type` and `observe_call`. Type capacity is checked only for
vacant entries; occupied feedback still widens at capacity. Rejected entries
retain saturating drop accounting without advancing the lattice version.
Call feedback remains independent of type capacity and continues growing
argument slots after arity/type megamorphism. Each admitted lattice change
retains its exact wrapping version update and generation-specific identity.

`record_hot` captures baseline tier state once after maintenance, which can
publish code. Feedback observation cannot mutate that state, and a successful
direct refresh returns immediately. This removes up to two repeated queries
without caching across callbacks or publication boundaries.

Three new characterization tests cover occupied-at-capacity updates, repeated
vacant rejection, exact stable/widened versions, generation separation,
zero-capacity call admission, and continued slot growth. Deliberately rejecting
occupied entries at capacity and stopping at megamorphic arity each make the
corresponding regression fail. All 518 release runtime tests and 82 targeted
AddressSanitizer/LeakSanitizer tests pass, along with workspace Clippy.
Independent review found no remaining correctness issue.

The five final paired comparisons use merged M3 `a38bd01` as baseline and
identical corrected harnesses. The candidate combines timing-stack and lookup
changes; these figures do not isolate the contribution of either change.
Each mode has five discarded warmups, 30 fresh-process pairs, ten throughput
windows of at least one second per engine, and 10,000 paired bootstrap
resamples. Engine order is independently balanced (15/15 latency, 5/5 windows)
on CPU 0. Checksums, native entry/exit balance, source and executable hashes
were audited before archiving.

| Workload / mode | Speed relative to a38bd01 | Paired 95% interval |
|---|---:|---:|
| Generic call / Tier 1 | 1.193x | 1.190x–1.197x |
| Generic call / requested Tier 2, actually Tier 1 | 1.163x | 1.160x–1.165x |
| Generic call / automatic, actually Tier 1 | 1.181x | 1.175x–1.185x |
| Recursive Fibonacci / Tier 1 | 1.187x | 1.183x–1.189x |
| Scalar loop / Tier 2 | 1.035x | 1.028x–1.038x |
| Scalar loop / automatic | 1.041x | 1.037x–1.047x |

All interpreter, direct-call and property-access comparisons are statistically
tied. Direct-call Tier 2 ranges from 1.9% slower to 0.2% faster; property
automatic from 0.2% slower to 0.2% faster. Scalar Tier 1 is also tied, between
2.3% slower and 0.6% faster. Automatic recursion still has zero native entries
and is an interpreter-path control. The scalar speed changes have no isolated
causal attribution. These dirty-source revision diagnostics do not replace the
complete clean-source matrix or prove an overall no-regression result.

Raw paired reports, throughput samples and exact driver/harness source:

- [Generic calls]../benchmarks/results/m3-feedback-lookups-generic-call-entry-paired.json
- [Direct calls]../benchmarks/results/m3-feedback-lookups-call-heavy-paired.json
- [Recursive Fibonacci]../benchmarks/results/m3-feedback-lookups-fibonacci-recursive-paired.json
- [Scalar loop]../benchmarks/results/m3-feedback-lookups-scalar-loop-paired.json
- [Property access]../benchmarks/results/m3-feedback-lookups-property-heavy-paired.json

### Property helper profile and next change

The [property profile](../benchmarks/results/m3-property-helper-profile.json)
uses the same kernel with 40,000 iterations instead of 2,000, retaining Int32
arithmetic. This is diagnostic sampling including setup and warmup, not a
performance acceptance result. Self attribution is 55.82% helper-frame
validation, 7.02% shape guard, 6.74% Free, and 3.95% MaterializeOwner. The worker
records 15 Tier 2 entries, zero deopts/retries/fallbacks, and balanced entry/exit
counts; these counters include warmup.

Optimized property access currently materializes borrowed stack aliases before
every shape guard and releases the temporary owners afterward. The guard can
instead inspect an already-rooted argument/local slot for a narrowly proven
borrowed receiver. This next change is not implemented yet. It must admit only
live stacks made entirely of immediate primitives or valid argument/local
aliases, synchronize canonical arguments/locals and PC, and expose an empty
operand stack during the nonallocating/nonreentrant shape guard. Any OwnedSlot
or Unknown provenance must retain existing lowering. On guard exception the
empty stack is cleanup-safe; on shape/value-tag miss the existing full
materialization bridge must reconstruct the original pre-operation stack.
Success can avoid temporary ownership while preserving each exact shape and
generation check. Do not replace this with a pointer-only cache across effects.

Required follow-up coverage includes steady helper counts, shape and value-tag
misses below another receiver alias, safe guard-rejection cleanup, alias
reassignment, deeper owned values, and the existing polymorphic/stress-GC tests.
The original objective still requires this property work and a fresh complete
matrix; the lookup cleanup is not completion of the broader performance target.