Repository navigation
perf: function-valued stores served by the store IC with a body check (ConstFn key-add) - #11798
Merged
Merged
Conversation
added 4 commits
October 3, 2026 10:55
…ord (#10507) `new F()` and `x instanceof F` on a plain `function` went through every exotic-callee probe (builtins by code pointer, bound, proxy, native-module exports), three hash tables keyed by address (FUNCTION_CLASS_IDS, CLASS_PROTOTYPE_OBJECTS, the own-symbol table) and two shape interns per construction. - perry-abi: FN_COMPILED_BODY marks every info perry-codegen renders, so an ordinary compiled function is a fact of its body, decided once. - Construction reads F.prototype through F's ShapeId (a per-agent ShapeId to slot cache) and replays the birth record kept on the prototype object (ObjectMeta::instance_birth: class id and birth ShapeId, minted by the first ordinary construction, cleared when that class's registered prototype moves), then enters the body directly. - instanceof with an ordinary compiled F is one shape compare when x's ShapeId names F.prototype, else OrdinaryHasInstance's prototype walk for an object of no compiled class: an object created before F.prototype was reassigned is no longer an instance. A bound function answers for its target. - A method call whose name a class also declares sends receivers of no such class to the method site (direct call of an inherited F.prototype method) instead of the own-property probe and the by-name dispatcher. Instructions per op (issue repro): new F 5,048 -> 1,898, instanceof 2,809 -> 425, decimal.js-shaped x.plus(i) 15,848 -> 5,003. tsc -1.43%, Zod -0.13%, outputs equal to node.
A ConstFn lane (a slot holding a closure of one static body) was refused by both halves of the static-key store site: the key-add memo and the existing-key word. Every function-valued store therefore took the runtime miss (~2,800 instructions per key-add on the #10507 decimal row). The site gains a fifth word naming its one ConstFn body (claimed once by the primary agent, never changed). A key-add memo whose successor's lane is ConstFn carries a guard flag (bit 14), and an existing-key word or way for a ConstFn slot carries bit 62. The emitted hit then admits only a closure of the site body: POINTER tag above the handle band, GcHeader kind CLOSURE and not forwarded, ClosureHeader::info equal to the site word, and not a rebindable `this` clone. Any other value takes the miss, whose checked funnel deprecates the lane. The runtime memo (packed_add_try) applies the same admission. ABI: perry-abi PACKED_SET_SITE_WORDS / PACKED_SET_CONSTFN_INFO_WORD and the two flag bits, pinned by packed_set_site_layout_matches_codegen.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing (29)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
This was referenced Oct 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Function-valued stores (
this.k = F,o.cb = fn) no longer miss the store IC on every store. Stacked on #11787; retarget to main after it merges.Instructions per op
new C()storingthis.k = Cthis.cb = fn, 16 closures of one bodyo.cb = fnoverwriteA function-valued key-add now costs about 156 instructions more than a number key-add, down from about 2,985.
How it works
tsc and Zod (n=5; output matches node)
Verification
assert_constfn_body_compare, because no current JS program can observe it.Limits: one body per site, so a site alternating two bodies still misses for the second. Arrows that capture
thistake the slow path. Class-field stores were not measured.