perf: class accessors validated by shape facts, called directly (#10498) - #11784
Conversation
A read or store site whose key the receiver inherits as a compiled class accessor answers it from shape facts: the receiver ShapeId (key not own, prototype identity names the holder), the holder ShapeId (the key is an accessor lane) and the lane value against the primed pair. The emitted read and store towers call the getter/setter directly; the collecting miss entries ask the same entry first. The class -> declared-prototype registry link is write-once: a replacement or generic-origin redirect retires the displaced prototype ShapeId, so the accessor sites drop the global class_lookup_surface_generation, proto_validity and vtable_generation compares.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
⛔ Files ignored due to path filters (2)
📒 Files selected for processing (20)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthroughClass accessor read and store sites now use receiver and holder shape facts and cached accessor pairs to call compiled getters and setters. Prototype replacement retires the displaced prototype’s ShapeId. Runtime and code-generation tests and a regression scenario file cover the changed paths. ChangesClass accessor paths
Priority: ➖ Normal Estimated code review effort: 4 (Complex) | ~45 minutes Change: Refactor · Severity of issue fixed: Medium Sequence Diagram(s)sequenceDiagram
participant PropertyReadSite
participant AccessorCache
participant HolderObject
participant CompiledGetter
PropertyReadSite->>AccessorCache: Load cached entry
AccessorCache-->>PropertyReadSite: Return shape facts, pair, and getter
PropertyReadSite->>HolderObject: Check holder shape and accessor lane
HolderObject-->>PropertyReadSite: Return shape and lane value
PropertyReadSite->>CompiledGetter: Call getter when guards pass
sequenceDiagram
participant StoreSite
participant SetterCache
participant HolderObject
participant CompiledSetter
StoreSite->>SetterCache: Load cached entry
SetterCache-->>StoreSite: Return shape facts, pair, and setter
StoreSite->>HolderObject: Check holder shape and accessor lane
HolderObject-->>StoreSite: Return shape and lane value
StoreSite->>CompiledSetter: Call setter when guards pass
Suggested reviewers: Merge Risk: ⚪ Minimal · up to No actionable merge-blocking risk was established for the class accessor changes; the PR is mergeable after normal checks. Security Architecture ReviewSecurity architecture risk: 🟠 High · up to The new accessor fast paths read cached heap objects before checking whether workers have started. Cached getter references stop being maintained after worker startup, so the late check may allow stale native-memory reads. Ordinary prototype invalidation and accessor eligibility have supporting safeguards, but they do not resolve this lifecycle risk. Retained concerns
Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Linked Issues checkExplanation For Full details: Docstring CoverageExplanation Docstring coverage is 67.24% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 58 functions across 19 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
🛠️ Fix failing CI checks 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…mpiled class declares as a getter The read site gets the gating the store site has had since the setter half: the runtime admits a getter entry only for an accessor some compiled class declares, so a read of any other name carried an arm it could never take. The compiled tsc workload drops 7.8 MB (181.5 MB to 173.7 MB). Refs #11784
Closes #10498. Class accessor sites are validated by shape facts only. The global-counter checks are gone:
class_lookup_surface_generation, proto_validity, vtable_generation andaccessor_link_still_current.Instructions per op
How the site validates
A class's link to its declared prototype is now written once. Replacing it, or a generic-origin redirect, gives the displaced prototype a fresh ShapeId. The per-hit pair decode and the handle scopes are removed. The emitted read and store paths gain an inline accessor arm on 64-bit targets. The inline setter arm takes Number values only; anything else goes to the runtime miss path, which keeps the value rooted.
js_register_class_generic_originis reclassified from Leaf to Reenters. The Linux gc_call_effects table is regenerated, and the Windows row is edited to match; macOS was already Reenters.Tests
test_gap_class_accessor_shape_facts.tscovers two-level inheritance, subclass override, runtimedefineProperty, delete, shadowing,setPrototypeOf, static and object-literal accessors, getter-only/setter-only, throwing accessors, and heap values. It matches node on main, on this PR, and on this PR under forced evacuation with the verifier.verify_accessor_arm. 11 codegen tests that pinned the old block structure are updated.Verification (on ebc858c; this branch is the same commit replayed onto f6c873d, a CI-only change)
manifest_consistency, which fails on main since perf: batch corked sockets and streamline interpreter scope access #11757).--checkpass.Follow-ups, not in this PR
ObjectMeta.accessor_key_bitsstays, pending the ObjectMeta rework in perf(gc): reduce retained arena RSS and redundant GC work #11781.Summary by CodeRabbit
Performance
Bug Fixes