fix(runtime): a built-in callee receives the primitive this, not a ToObject wrapper - #11524
Merged
Merged
Conversation
…ToObject wrapper (#11509) ECMA-262 §10.3.1: a built-in function's [[Call]] does not run OrdinaryCallBindThis; it receives thisArg unchanged and coerces itself. call_primitive_closure_value still boxed a primitive receiver for every non-strict callee, built-ins included, minting a String wrapper with an own index property per UTF-16 code unit. Re-lands the intent of #9800's 32f150b without its per-instance builtin_closure_length side-table lookup: built-in-ness is a new BUILTIN kind bit on the closure BODY record (next to STRICT and NON_CONSTRUCTOR), set once per thunk by the prototype-method installers, and checked in the same single body-record lookup the call site already made for strictness.
|
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 configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (7)
✨ 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 |
proggeramlug
pushed a commit
that referenced
this pull request
Sep 27, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HEisA6oPsnE1XGzWNxLWoW
proggeramlug
force-pushed
the
claude/lucid-faraday-215csd
branch
from
September 27, 2026 12:50
d6a1c21 to
fe87b15
Compare
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.
Summary
call_primitive_closure_valuewrapped a primitive receiver withjs_object_coercefor every non-strict callee, built-ins included. ECMA-262 §10.3.1 says a built-in's[[Call]]receivesthisArgunchanged and does its own coercion. This re-lands the intent of #9800's32f150b22on currentmain, without the per-instance side table.Changes
closure/registry.rs: adds aBUILTINkind bit to the existing per-bodyClosureBodyRecordflags, next toSTRICTand perf:new Promise(executor)is 43–80× slower than Node, 11× slower thanPromise.resolve(per-promise name/length side-table metadata + global epoch bumps) #10521'sNON_CONSTRUCTOR. Also adds:register_closure_body_builtin(func_ptr), which sets the bit once per thunk bodybody_receives_primitive_this(func_ptr), which answersSTRICT | BUILTINfrom one body-record lookupnative_call_method.rs: the call site uses that single lookup. It previously made one lookup for strictness, so the hot path does no extra work.install_proto_method,install_proto_method_rest_with_lengthandprimitive_proto_method_closure_value. That covers the String, Number, Boolean, BigInt, Symbol and Object prototype methods.32f150b22, this does not usebuiltin_closure_length, which is a ptr-keyed per-closure side table. No new table and no per-closure entries.changelog.d/fragment. No version bump.Related issue
Closes #11509
Test plan
#[test] builtin_callee_gets_the_primitive_receiver_and_a_user_callee_the_wrapperinnative_call_method/code_point_at_dispatch_tests.rs. It is behavioural and checks both directions using the boxed-primitive wrapper counter:install_proto_methodgets the raw string, returns the right answer, and creates no wrappera built-in callee must receive the primitive, not a ToObject wrapper). With the fix restored it passes.RUST_TEST_THREADS=1 cargo test --release -p perry-runtime --lib code_point_at_dispatch: 3 passed.cargo fmt --all -- --check,check_file_size.sh,raw_handle_debt.py,addr_class_inventory.py,gc_runtime_root_holders.py,gc_rekeyed_key_tables.py.main: in progress. This environment can't install LLVM 22 (apt.llvm.org is blocked), so I'm running it locally with a subprocess-clang compiler build on both arms. I'll post the results here.Checklist
fix:prefix conventionGenerated by Claude Code