Route member-expression identifier-object reads through identifier caches#2660
Merged
Conversation
…ches JintMemberExpression.EvaluateInternal resolved an identifier base with a raw environment-chain walk on every evaluation, predating the slot/global caches that JintIdentifierExpression.GetValue now has. Computed writes (a[i] = v), compound writes and updates all pay that walk per evaluation. Reuse the identifier node's own caches instead; keep the raw walk only for eval/arguments bases so arguments[i] reads do not trigger materialization and keep the frame's JsArguments poolable. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
lahma
enabled auto-merge (squash)
July 13, 2026 09:35
This was referenced Jul 15, 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.
Summary
JintMemberExpression.EvaluateInternalresolves an identifier base (aina[i] = v,a[i] += x,a[i]++,obj[m](),delete obj.prop) by callingJintEnvironment.TryGetIdentifierEnvironmentWithBindingValuedirectly — a full environment-chain walk with virtualTryGetBindingprobes on every evaluation. That call predates the slot/global/nested-chain caches thatJintIdentifierExpression.GetValuehas since grown; the read paths (GetValue,GetCalleeForCall,TryAssignFast) were upgraded to those caches long ago, this branch never was.This PR routes the identifier-object read through
identifierExpression.GetValue(context)so it hits the identifier node's own caches (hop-0 slot reads, validated global descriptors), with one carve-out:arguments/evalbases keep the raw walk, becauseGetValuerunsMaterializeIfArguments, which would permanently opt the frame'sJsArgumentsout of pooling forarguments[i]readers and detach mapped-index reads from the parameter map. Aliases (var a = arguments) already materialize at assignment time, so the carve-out only needs to cover the direct name.Found via ETW sampling (ultra @ 8190 Hz) of a steady-state SunSpider mix, where the raw walk accounted for a large share of
TryGetIdentifierEnvironmentWithBindingValue's 3.3% self time andEvaluateInternal's 2.6%.Semantics notes
ReferenceErrorthrough the identicalengine.GetValue(unresolvable reference)path.EvaluateInternalwith the message the member read path (GetValue) already throws for the same code; no test asserts the old message on this path.with/ObjectEnvironment and eval-injected bindings behave identically: the identifier caches refuse to crossObjectEnvironments and HasBinding-probe hopped intermediate envs, falling back to the same full walk.Benchmarks (default jobs, back-to-back A/B on same machine)
Allocations unchanged on every row.
ETW re-profile of a function-wrapped SunSpider mix (fixed work, 45 iterations): total 15,687 → 13,617 ms (−13.2%);
JintMemberExpression.EvaluateInternalself 401 → 267 ms (−34%). The function-wrapped shape (identifier bases in slots — typical of real code in functions) benefits more than the global-scope BDN scripts.Gates
🤖 Generated with Claude Code