refactor(compile): extract per-receiver branches from EmitGetProperty (#1242)#1244
Merged
Conversation
…#1242) Slice 15 self-contained, disjoint receiver arms out of the 2,028-line EmitGetProperty god-method into named Emit<Receiver>GetBranch helpers in a new sibling partial (RuntimeEmitter.Objects.GetPropertyBranches.cs). Each helper mirrors the already-factored EmitProxyGetPropertyCheck shape: it emits the receiver-type test itself, runs the branch body + `ret` on a match, and otherwise falls through to a caller-supplied `notMatch` label. The dispatch table in EmitGetProperty now reads as a flat sequence of `EmitXGetBranch(il, …, notX); MarkLabel(notX)` arms. Extracted arms: namespace, $Object, Map, Set, Dictionary, $Array, List, object[], String, $Buffer, $Stats, $TSFunction, $BoundTSFunction, $CJSModule, $RegExp. EmitGetProperty drops from ~2,028 to ~960 lines. The interdependent arms deferred in #1141/#1242 stay inline: the System.Type/class-instance pair (shared base-walk jump target), the three-way Promise dispatch, the typed-array family, the bound-callable multi-check, and the primitive-prototype fall-throughs. Pure mechanical move — no behaviour change. Each arm was extracted incrementally and verified with `--compile … --verify` plus an output diff against a pre-refactor compiled baseline. Gate: xUnit 15404/0, Test262 22/0/4skip (interp + compiled), TSConformance 31/0, IL --verify clean. Standalone constraint preserved (no new metadata tokens; existing Ldtoken/GetMethodFromHandle late-binding retained). Part of #1094.
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.
Closes #1242. Part of #1094.
What
Follow-up to #1141 / PR #1241, which split
RuntimeEmitter.Objects.Properties.csat the file level but deliberately left the 2,028-lineEmitGetPropertygod-method intact. This PR extracts the per-receiver branches inside that method intoEmit<Receiver>GetBranch(il, …)helpers, the original #1141 ask.15 self-contained, disjoint receiver arms move into a new sibling partial
Compilation/RuntimeEmitter.Objects.GetPropertyBranches.cs. Each helper mirrors the already-factoredEmitProxyGetPropertyCheck/EmitProxyDeleteCheckshape:reton a match,notMatchlabel.The dispatch table in
EmitGetPropertynow reads as a flat sequence ofEmitXGetBranch(il, …, notX); MarkLabel(notX)arms sitting right beside the existing proxy-check call.Extracted arms: namespace,
$Object, Map, Set, Dictionary,$Array, List,object[], String,$Buffer,$Stats,$TSFunction,$BoundTSFunction,$CJSModule,$RegExp.EmitGetPropertydrops from ~2,028 → ~960 lines.What was left inline (deferred, per the incremental plan)
The genuinely interdependent arms #1242 flagged as risky stay inline:
System.Type/ class-instance pair (they share the base-walk-loop jump targetclassInstanceLabel),$Promisesubclass /$Promise),$ArrayBuffer/$SharedArrayBuffer/$DataView/TypedArray share a gated block),$BoundArrayMethod/$BoundMapMethod/$BoundSetMethod/$BoundAnyFunction),These remain candidates for later increments.
Safety
Pure mechanical move — no behaviour change. The larger arms (
$Object,$RegExp, Dictionary) were relocated with a line-preserving script rather than retyped, so their local functions and comments carry over verbatim. Each arm was extracted incrementally, one receiver type at a time, and verified with--compile … --verify(IL validation) plus an output diff against a pre-refactor compiled baseline; every increment matched.No new metadata-token references are introduced — the moved IL keeps its existing
Ldtoken/GetMethodFromHandlelate-binding, so compiled standalone DLLs gain noSharpTS.dlldependency.Gate
dotnet test(xUnit): 15404 / 0 failed / 0 skipped--verify: clean on the emittedGetProperty