GlobalObject joins the builtin-shape system via hybrid shape+overflow storage#2595
Merged
Merged
Conversation
… storage Finishes the built-in shapes rollout by flipping its largest remaining dictionary host - GlobalObject, 71 entries built per realm - and introduces the mechanism that makes the flip viable: a hybrid mode where a builtin-shaped host gains new own string properties in a side dictionary while the shape keeps serving its slots. Script-created globals (var/function bindings, host SetValue) and prototype extensions no longer deopt the shape; integer-like keys and deletes/redefines of shape names still do (own-key order). Read and enumeration surfaces consult dictionary-then-shape; the global identifier-binding cache learns shape-slot descriptors (materialization is identity-stable and version-neutral, while slot redefines and deopts bump the version). BuildEngine -60% time / -52% alloc, EvaluateSimple -51%/-49%, minimal script Execute -28%/-40% (prepared -45%/-45%); GlobalAccess/Stopwatch/SunSpider neutral. Full test262 green. Also fixes SetPropertyUnlikely (non-JsString keys) bypassing shape handling by writing straight to the raw dictionary. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S2U2y9voMQV9rvCkYeQbka
lahma
enabled auto-merge (squash)
July 7, 2026 09:57
This was referenced Jul 13, 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.
Hybrid shape+overflow storage for builtin-shaped hosts; GlobalObject joins the shape system
Finishes the built-in shapes rollout (#2580, #2581, #2582) by flipping its largest remaining dictionary host —
GlobalObject, 71 entries built per realm — and introduces the mechanism that makes the flip viable: a hybrid mode where a builtin-shaped host can gain new own properties in a side dictionary while the shape keeps serving its slots.Why hybrid
A shaped global without hybrid storage deopts on the first top-level
var(every script-created global adds an own property the fixed layout can't express). Paying shape initialization and an immediate deopt-rebuild made evaluate-style workloads sharply worse in an earlier attempt at this flip (Evaluate("1")+72%), which is why it was parked. With hybrid mode the shape survives script-created globals, so both the construction win and the evaluate win land:Results (BenchmarkDotNet default jobs, .NET 10)
BuildEngineEvaluateSimpleExecuteExecute_ParsedScriptNo-regression gates:
GlobalAccessBenchmarks: GlobalVarLoop/GlobalUpdateLoop neutral in A/B and reversed-order B/A; LocalVarLoop neutral at--launchCount 5(single-launch deltas were PGO mode-locking — both sides alternate ~38.5/~41.5 ms launch modes).StopwatchBenchmark: classic neutral-or-better; modern prepared +1.1% at--launchCount 3, within the noise of sibling rows that flip sign between runs.date-format-xparb−7.8% (it extendsDate.prototype, which now stays shaped). The one outlier,controlflow-recursive+11% in the single-launch pair, disappears at--launchCount 5: baseline 67.86 ms vs this PR 67.72 ms with fully overlapping launch distributions (the original baseline reading of 64.5 ms is not reproduced by any of its own five launches).Semantics
For a host in builtin-shape mode:
var/assignment,Engine.SetValue, prototype extension likeDate.prototype.format = ...): joins the hybrid side dictionary; shape stays live. Own-key order remains correct because every addition post-dates every shape name (shape names, then dictionary, then symbols).LazyBuiltinSlotDescriptor.parseInt = 5,Object.definePropertyon an existing slot): in-place slot replace + version bump, no deopt.Every read/enumeration surface consults dictionary-then-shape:
GetOwnProperty,GetOwnProperties, own-key enumeration,ProbeOwnProperty, the member-expression inline caches (validated by_propertiesVersion, which hybrid additions bump), and the global-environment binding protocol (TryGetBinding/GetBindingValue/CanDeclareGlobalVar/CreateGlobalVarBinding/SetFromMutableBinding). The global identifier-binding cache now also learns shape-slot descriptors — materialization is identity-stable and never bumps the version, while any slot redefine/deopt does, so the existing validation scheme covers them.GlobalObject's three non-declarative entries (parseInt/parseFloat— spec identity withNumber.parseInt/parseFloat— and theglobalThisself-reference) fill reserved[JsInstanceSlot]s with the same lazy descriptors as before.Also fixes a latent hole on the same path:
SetPropertyUnlikely(non-JsStringkeys) wrote straight to the raw dictionary, bypassing shape handling; it now routes through the mode-awareSetProperty(Key).Testing
Jint.Tests,Jint.Tests.PublicInterfacegreen (net10.0 + net472)var/function/lexical global-binding semantics are heavily covered thereglobalThis, key order (shape names before additions),var Arrayresolving to the slot in place, non-configurablevarsurvivingdelete🤖 Generated with Claude Code
https://claude.ai/code/session_01S2U2y9voMQV9rvCkYeQbka