[JSC] GreedyRegAlloc: Add loop-aware live range splitting (disabled by default)#64182
Merged
Conversation
Collaborator
|
EWS run on previous version of this PR (hash 43a7a4a) Details |
Collaborator
|
EWS run on previous version of this PR (hash 1bce483) Details |
kmiller68
approved these changes
May 5, 2026
Contributor
kmiller68
left a comment
There was a problem hiding this comment.
r=me on second patch too.
1bce483 to
d5fd1d5
Compare
Collaborator
|
EWS run on current version of this PR (hash d5fd1d5) Details |
…y default) https://bugs.webkit.org/show_bug.cgi?id=312905 rdar://175260380 Reviewed by Keith Miller. Add loop-aware live range splitting to the greedy register allocator. When a tmp's live range crosses a loop boundary, split it into a loop portion and a non-loop portion. This allows the two portions to be allocated independently, reducing interference between the loop body and the surrounding code. For example, a tmp live across a loop but unused inside it can be split so that the loop portion is spilled, freeing a register for the loop body. Similarly, a tmp that conflicts with others outside the loop may get a register inside it after splitting. A new CFG normalization pass (ensureDedicatedLoopEntryExitBlocks) ensures non-critical entry edges and dedicated exit blocks so that fixup code can be safely inserted at loop boundaries. Entry/exit fixups use Shuffle instructions to handle potential register cycles when multiple tmps are split around the same loop. The feature is off by default (airGreedyRegAllocSplitAroundLoops). The mechanism is working and passes tests, but improvements to the splitting policy and integration with the allocator's priority-driven allocation order are needed to realize the potential. Test: Source/JavaScriptCore/b3/air/testair.cpp JSTests/stress/regalloc-loop-splitting.js * JSTests/stress/regalloc-loop-splitting.js: Added. (clobber): (test): * Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj: * Source/JavaScriptCore/Sources.txt: * Source/JavaScriptCore/b3/air/AirAllocateRegistersByGreedy.cpp: (JSC::B3::Air::Greedy::Cost::subtractSaturating): (JSC::B3::Air::Greedy::LiveRange::contains const): (JSC::B3::Air::Greedy::LiveRange::overlaps const): (JSC::B3::Air::Greedy::AroundLoopSplitMetadata::AroundLoopSplitMetadata): (JSC::B3::Air::Greedy::AroundLoopSplitMetadata::dump const): (JSC::B3::Air::Greedy::GreedyAllocator::dump const): (JSC::B3::Air::Greedy::GreedyAllocator::forEachBlockInLiveRange): (JSC::B3::Air::Greedy::GreedyAllocator::findBlockIndexContainingPoint): (JSC::B3::Air::Greedy::GreedyAllocator::findBlockContainingPoint): (JSC::B3::Air::Greedy::GreedyAllocator::rewriteCoalescedTmps): (JSC::B3::Air::Greedy::GreedyAllocator::addSplitTmp): (JSC::B3::Air::Greedy::GreedyAllocator::trySplit): (JSC::B3::Air::Greedy::GreedyAllocator::analyzeLoop): (JSC::B3::Air::Greedy::GreedyAllocator::ensureLoopAnalysis): (JSC::B3::Air::Greedy::GreedyAllocator::chooseLoopForSplit): (JSC::B3::Air::Greedy::GreedyAllocator::trySplitAroundLoop): (JSC::B3::Air::Greedy::GreedyAllocator::trySplitAroundClobbers): (JSC::B3::Air::Greedy::GreedyAllocator::insertFixupCode): (JSC::B3::Air::Greedy::GreedyAllocator::insertSplitAroundLoopFixupCode): (JSC::B3::Air::allocateRegistersByGreedy): (JSC::B3::Air::Greedy::LiveRange::overlaps): Deleted. * Source/JavaScriptCore/b3/air/AirCode.cpp: * Source/JavaScriptCore/b3/air/AirCode.h: * Source/JavaScriptCore/b3/air/AirEnsureDedicatedLoopEntryExitBlocks.cpp: Added. (JSC::B3::Air::ensureDedicatedLoopEntryExitBlocks): * Source/JavaScriptCore/b3/air/AirEnsureDedicatedLoopEntryExitBlocks.h: Added. * Source/JavaScriptCore/b3/air/AirRegisterAllocatorStats.h: * Source/JavaScriptCore/b3/air/testair.cpp: * Source/JavaScriptCore/runtime/OptionsList.h: Canonical link: https://commits.webkit.org/312693@main
d5fd1d5 to
899099b
Compare
Collaborator
|
Committed 312693@main (899099b): https://commits.webkit.org/312693@main Reviewed commits have been landed. Closing PR #64182 and removing active labels. |
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.
🛠 ios-apple
899099b
d5fd1d5