ReviewOS

zig-utils/zig-js

Compiler: lower derived and field constructor activations

#746
Closed chris opened this 9 days ago ·
9 days ago

Parents: #465, #498 Discovered by: #745 Related: #743, #744 Children: #747 (base, complete), #748 (derived, complete)

Resolution

Required bytecode now owns complete base and derived class-constructor activations. Base instance elements execute before parameter initialization; derived activations start with an unbound this cell, bind exactly once through super(), then install brands and run instance elements. Complete shapes no longer carry plain_policy_class_constructor_semantics; incomplete nested lowering remains causal and fail-closed.

Progress

  • #747: base constructor instance-element prefix, private brands, computed names, field lexical context, moving-GC/OOM/no-GIL evidence — d9d480d0
  • #748: derived super() activation, post-super elements, lexical arrows, native-tier completion, and exact return rules — afb9ce2c

Implemented scope

  • Explicit uninitialized derived this, exact super() initialization, repeated/missing-super errors, alternate object returns, and constructor completion in VM activations.
  • Public/private fields, auto-accessors, private method/accessor brands, computed names, and instance initializer order exactly once for base and derived constructors.
  • Exact new.target, live constructor prototype lookup, superclass capture before argument effects, default direct forwarding, abrupt completion/finally, recursion/reentry, moving GC, OOM restoration, and shared no-GIL execution.
  • Derived completion at bytecode, baseline-native, optimizer-entry, and OSR exits without disabling native eligibility.
  • Causal direct-eval rejection in automatic mode and a hard required-mode failure with no interpreter fallback.

Acceptance

  • Forced tree-walker and required bytecode agree on base/derived constructors, super() errors, alternate object returns, new.target, public/private fields, brands, computed names, and initializer order.
  • Exceptions/finally, recursion/reentry, moving GC, OOM restoration, debugger/termination accounting, shared no-GIL, and TSan preserve exact activation state.
  • Admission inventory removes the constructor-policy barrier only for fully covered shapes and keeps unsupported class forms causal and fail-closed.
  • Full units, class/private-field Test262, threadfuzz, ABI/docs gates, and exact nonzero before -> after accounting pass with zero regressions.
  • Conventional commits landed directly on main and cross-link #465, #498, and #745.

Evidence

  • Test262 class statements: 4,367 -> 4,367 pass; class expressions: 4,059 -> 4,059 pass; 0 failures and 0 flips.
  • Full units: 1,895 pass, 1 skip, 0 fail/leak.
  • Threadfuzz: 400 normal + 400 TSan, 0 failures; derived and shared no-GIL TSan witnesses pass.
  • Home public ABI 50/50, Home private 447/447, Bun private 437/437; C API fixtures pass.
  • Docs link audit: 277 files; manifest-checked docs build: 50 pages.
9 days ago

#745 has landed on main as feat(compiler): lower parameter construction defaults (#745). Its required-bytecode witness confirmed this issue is the remaining causal boundary for derived and field-initializing constructor callees: those constructors do not yet own a bytecode chunk and remain rejected by plain_policy_class_constructor_semantics. #745 does not add a fallback or interpreter callback for them.

9 days ago

#747 is complete in d9d480d0: base constructors now compile their complete instance-element prefix before parameter initialization, including public/private fields, auto-accessors, computed Symbol/string names, brands, lexical field context, moving-GC/OOM restoration, and shared no-GIL execution.

Exact evidence is 8,426 → 8,426 relevant Test262 class cases with 0 failures/0 flips; full units are 1,891 pass, 1 skip, 0 fail/leak; frontend 25/25; threadfuzz 400/0 normal and TSan.

The remaining #746 boundary is now specifically derived-constructor activation semantics: uninitialized this, exact super() initialization/repetition/missing errors, derived return rules, and running the already-covered instance-element machinery immediately after successful super().

9 days ago

Completed by d9d480d0 (#747) and afb9ce2c (#748). The constructor-policy barrier is removed for complete base and derived activations; unsupported nested lowering remains explicit and fail-closed.

Sign in to comment on this issue.