ReviewOS

zig-utils/zig-js

Runtime: add unboxed representation selection across hot tiers

#470
Open chris opened this 9 days ago ·
9 days ago

Parent: #459 Depends on: #469

Goal

Add representation selection and unboxed value pipelines across VM/native frames so numeric, Boolean, string, object, and typed-data hot paths avoid repeated NaN-box tagging/coercion.

Scope

  • Extend profiles and SSA types beyond Number-only sites: int32, uint32, double, Boolean, nullish, interned/flat string, ordinary object/array, typed-array view, BigInt where sound, and unions.
  • Select unboxed local/temporary representations, explicit conversions, and phi representations with overflow/NaN/-0/infinity semantics.
  • Keep values unboxed across inlined calls and loops; box only at observable storage, generic runtime, deopt, debug, or host boundaries.
  • Add architecture-neutral register classes and spill/map metadata for integer, FP, SIMD, and managed values.
  • Specialize common ToNumber/ToString/ToPropertyKey/equality paths without bypassing user coercion.

No-workaround rules

  • No 32-bit truncation of general Numbers, canonicalization that loses NaN/-0 behavior, guessed string/object identity, or unrooted managed pointer.
  • A representation mismatch deoptimizes before observable work with exact reconstruction.

Acceptance

  • Differential edge suites cover overflow, -0, NaN payload behavior where observable, infinities, BigInt mixing, Symbols, throwing coercions, and representation-changing loops.
  • Stack maps and deopt materialize exact boxed Values after GC relocation.
  • No-GIL profile merges and guards are race-safe under TSan.
  • Profiles show reduced conversions/tag checks/spills on declared #460 rows, with code-size and compilation-cost accounting.
  • Original #44 and full correctness gates remain green.

Foundation

The current 8-byte NaN-boxed Value stays the canonical observable/storage representation; numeric optimizer guards and frame maps landed under #431/#432/#437.

9 days ago

Closed representation-proof leaf #702 in 538233bd: one-word ValueNB now mirrors production StringData classification, semantic WTF-8 projection, and flat-aware numeric parsing. Forced-flat, optimized, sanitizer, and full-unit gates pass with zero failures/leaks.

Sign in to comment on this issue.