Skip to content

VM: quicken monomorphic Number arithmetic sites #734

Description

@chrisbbreuer

Parents: #498, #461
Related: #481, #493, #659

Problem

Ordinary bytecode already computes Number/Number binary operations inline, but every execution still merges instruction-local optimizer profile atomics, rechecks the full operand-kind decision, and enters one large generic opcode switch. A stable numeric site never publishes a VM-owned specialized dispatch state, while the generated quickening inventory therefore correctly keeps arithmetic-dispatch unsupported. On restricted hosts this cost remains permanent because no native tier can replace the site.

Scope

  • Freeze explicit single-context no-JIT/required-bytecode benchmark and attribution modes; native publication must remain provably zero.
  • Add representative stable Number arithmetic rows covering add/subtract/multiply/divide/remainder/power, relational/equality, bitwise, and shifts, plus BigInt, string-concatenation, object-coercion, exceptional, and Number-to-polymorphic controls.
  • Add one instruction-indexed, race-free adaptive arithmetic state table owned by each immutable Chunk. Stable Number sites may publish a Number-specialized state after a bounded observation threshold; unsupported/polymorphic sites publish an explicit generic state.
  • Preserve bytecode immutability. A specialized miss must execute the exact ordinary operation once, record the changed operand kinds, and dequicken without replaying coercions or effects.
  • Preserve Number edge cases, BigInt mixing errors, ToPrimitive ordering, string concatenation, Symbol errors, shifts, NaN/signed zero/infinity, debugger/step/watchdog accounting, exception/finally resumption, moving GC, OOM, and optimizer guard correctness.
  • Keep metadata bounded at one compact atomic state per instruction and expose exact hit/miss/dequickening counters for tests and attribution.

No-workaround rules

No source/workload recognizer, benchmark-only branch, disabled profiling globally, mutable bytecode rewriting under shared execution, assumed Number inputs, skipped coercions, cached results, hidden warmup, executable mappings in no-JIT mode, or tree-walker callback presented as quickening. No stacks, queues, jobs, Promise, microtask, Worker-lifecycle, or Map/Set iterator changes.

Acceptance

  • Benchmark-first rows preserve exact checksums, bytecode admission, opcode counts, and allocation replay with native publication zero.
  • Stable Number sites quicken after the declared threshold; polymorphic/unsupported sites remain generic and one miss dequickens exactly once without effect replay.
  • Forced tree-walker, ordinary VM, quickening-off, and quickening-on results match across every operator/control, including exceptions, steps, debugger, OOM, and termination.
  • Per-site state publication is race-free under no-GIL/TSan, bounded under attacker-sized bytecode, and reset by Chunk teardown.
  • Full units, focused TSan/threadfuzz, relevant arithmetic/coercion Test262, docs/inventory gates, and exact before -> after accounting pass.
  • Exact-parent no-JIT evidence demonstrates reduced dispatch/profile work without regressing polymorphic controls or claiming native-tier throughput.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestjitBytecode, baseline JIT, optimizer, and code generationperformanceMeasured runtime, memory, scaling, or build performanceruntimeJavaScript runtime and builtin implementation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions