[mono-move] Chained field access fusion - #20249
Merged
Merged
Conversation
Contributor
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
vineethk
force-pushed
the
vk/chained-field-fusion
branch
2 times, most recently
from
July 22, 2026 19:06
fceccc9 to
d55336f
Compare
vineethk
marked this pull request as ready for review
July 22, 2026 19:07
vineethk
requested review from
calintat,
georgemitenkov and
vgao1996
as code owners
July 22, 2026 19:07
vineethk
force-pushed
the
vk/chained-field-fusion
branch
from
July 23, 2026 14:09
d55336f to
bd474d4
Compare
georgemitenkov
approved these changes
Jul 26, 2026
vineethk
force-pushed
the
vk/chained-field-fusion
branch
from
July 27, 2026 15:02
bd474d4 to
c746e0c
Compare
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit c746e0c. Configure here.
vineethk
force-pushed
the
vk/chained-field-fusion
branch
2 times, most recently
from
July 28, 2026 00:15
410f5de to
e2ba9f2
Compare
vineethk
enabled auto-merge (squash)
July 28, 2026 00:17
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
vineethk
force-pushed
the
vk/chained-field-fusion
branch
from
July 28, 2026 01:05
e2ba9f2 to
f77a71e
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Contributor
mono-move benchmark gate4 regression(s) beyond ±3% noise band
|
Contributor
✅ Forge suite
|
Contributor
✅ Forge suite
|
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.




Chained Field Access Fusion
Overview
This PR teaches the mono-move specializer to recognize chains of struct field borrows — patterns like
&s.a.b.cfollowed by a read or write — and collapse each chain into a single fused instruction. Where the interpreter previously executed one micro-op per field step (each computing an address, materializing a reference, and dispatching back through the run loop), a fused chain now executes as one micro-op that folds the entire path into a single precomputed offset.Main Changes
New fused IR instructions
The stackless IR gains a family of field chain instructions covering the useful combinations of root (a local, or an existing reference) and terminal action (borrow immutably, borrow mutably, read the value out, or write a value in). Each carries the full field path, so downstream phases see the whole access as one unit. Borrow chains deliberately preserve the immutable/mutable distinction, because a mutable borrow of a local creates a hidden-write channel that later optimization passes (coalescing, copy propagation) must be able to see.
The fusion pass
A new pass runs during destacking, before slot allocation. It scans each block for runs of single-use field borrows that feed directly into one another and ends each run at its terminal use. Key properties:
Enum variant-field access rework
Enum field access micro-ops were restructured into two tiers:
All offsets are precomputed as object-relative (the enum tag header is folded in at construction), so the interpreter does no offset arithmetic beyond a single add.
Runtime and gas
Testing
Note
Medium Risk
Touches interpreter memory access (unaligned u64), enum tag dispatch, and optimization soundness for mut-borrow chains; broad differential coverage mitigates regressions but VM semantics changes warrant careful review.
Overview
Adds pre-slot-allocation fusion that collapses depth-≥2 inline struct field borrow runs (single-use intermediates, terminal read/write/borrow, gap-tolerant sinking) into new
*FieldChainstackless IR, then lowers them to one micro-op with a summed offset. Coalescing/copy-prop gain sharedmut_local_borrow_targetguards (includingMutBorrowLocalFieldChain).Enum variant fields are split into uniform
HeapReadOffset/HeapWriteOffsetvs tag-dispatchedEnum*VariantFieldByTagops; divergent by-value access no longer uses a scratch fat pointer.Move8/ heap 8-byte moves use unaligned loads/stores for 4-aligned size-8 slots.Gas metering matches pre-fusion borrow/read/write costs for chains; differential tests cover struct chains, enum paths, abort order, and generics.
Reviewed by Cursor Bugbot for commit f77a71e. Bugbot is set up for automated code reviews on this repo. Configure here.