Skip to content

Perf: add a baseline native-code tier for hot bytecode functions #52

Description

@chrisbbreuer

Parent: #44
Related: #46, #47, #48

Motivation

After operand-stack, property-IC, and numeric remainder fast paths, the arithmetic profile attributes about 94% of samples to the bytecode runChunk dispatch loop. The accepted matrix still shows multi-fold JSC leads across arithmetic, properties, arrays, and recursive calls. A baseline native-code tier is the logical path to eliminate per-opcode dispatch while retaining the interpreter as the semantic fallback.

Backward compatibility is not a constraint; correctness, GC safety, and deterministic fallback are.

Scope

  • hotness counters and deterministic tier-up policy for plain bytecode functions;
  • a minimal baseline code generator for supported numeric/local/control-flow opcodes;
  • calls, returns, stack checks, exceptions, and GC safepoints with explicit runtime stubs;
  • monomorphic property IC loads/stores with shape guards and safe fallback;
  • executable-memory ownership with W^X transitions and teardown;
  • architecture/OS capability detection with a complete interpreter fallback;
  • incremental opcode coverage driven by the fair JSC matrix, not benchmark-specific source recognition.

Acceptance criteria

  • Document native frame layout, Value representation, calling convention, safepoint/root map, exception transfer, and invalidation rules before implementation.
  • Add differential tests that run every supported compiled function through both baseline native code and the bytecode VM and compare values, throws, side effects, and GC reachability.
  • Never execute stale IC assumptions: guard shapes/prototypes and fall back or invalidate on mutation.
  • Preserve precise GC, stack limits, closures/upvalues, arguments, direct eval, generators/async fallback, and no-GIL ownership rules.
  • Keep unsupported opcodes/functions on the bytecode VM without observable semantic differences.
  • Pass focused semantic, GC, no-GIL, and suppression-free TSan validation.
  • Produce symbolized profiles showing dispatch removal on arithmetic/properties/arrays/recursion.
  • Beat JSC in every directly comparable benchmark row, together with workload-specific work in Perf: beat JSC on arithmetic and property-access kernels #46-Perf: beat JSC on recursive and general function-call throughput #48.
  • Document build/runtime support and expose a deterministic disable switch for validation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions