Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 899099b0cc049f98cb5be085e0e1b82a7533c4c0
      
https://github.com/WebKit/WebKit/commit/899099b0cc049f98cb5be085e0e1b82a7533c4c0
  Author: Dan Hecht <[email protected]>
  Date:   2026-05-06 (Wed, 06 May 2026)

  Changed paths:
    A JSTests/stress/regalloc-loop-splitting.js
    M Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
    M Source/JavaScriptCore/Sources.txt
    M Source/JavaScriptCore/b3/air/AirAllocateRegistersByGreedy.cpp
    M Source/JavaScriptCore/b3/air/AirCode.cpp
    M Source/JavaScriptCore/b3/air/AirCode.h
    A Source/JavaScriptCore/b3/air/AirEnsureDedicatedLoopEntryExitBlocks.cpp
    A Source/JavaScriptCore/b3/air/AirEnsureDedicatedLoopEntryExitBlocks.h
    M Source/JavaScriptCore/b3/air/AirRegisterAllocatorStats.h
    M Source/JavaScriptCore/b3/air/testair.cpp
    M Source/JavaScriptCore/runtime/OptionsList.h

  Log Message:
  -----------
  [JSC] GreedyRegAlloc: Add loop-aware live range splitting (disabled by 
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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to