Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: b642ae17aade250ba31a0d480fb8b9698e329e69
      
https://github.com/WebKit/WebKit/commit/b642ae17aade250ba31a0d480fb8b9698e329e69
  Author: Dan Hecht <[email protected]>
  Date:   2026-02-06 (Fri, 06 Feb 2026)

  Changed paths:
    M Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
    M Source/JavaScriptCore/b3/air/AirAllocateRegistersByGreedy.cpp
    M Source/JavaScriptCore/b3/air/AirAllocateStackByGraphColoring.cpp
    A Source/JavaScriptCore/b3/air/AirPhaseStats.h
    M Source/JavaScriptCore/b3/air/AirRegisterAllocatorStats.h
    A Source/JavaScriptCore/b3/air/AirStackAllocatorStats.h
    M Source/JavaScriptCore/runtime/OptionsList.h

  Log Message:
  -----------
  [JSC] Proactively coalesce spill slots during register allocation
https://bugs.webkit.org/show_bug.cgi?id=307107
rdar://169740614

Reviewed by Yusuke Suzuki.

B3 Air stack allocator already does spill slot coalescing before allocation.
However, this coalescing can be very expensive in terms of CPU and memory
when there are a lot of spill slots that can be coalesced with high degrees
of interference since the full interference graph is built first (since
this is needed for the coalescing step), then updated as slots are
coalesced. This leads to a lot of memory allocation churn and memory traffic.

The greedy register allocator already develops a plan for coalescing
Tmps in order to coalesce registers. It first comes up with maximal
groups (for some definition of maximal based on its heuristics) and then
splits them up while running the register allocation loop to try to pack
them into registers.

We can leverage these original groups to coalesce any Tmps that didn't
end up fitting into registers to get the bulk of spill slot coalescing
"for free". This removes a lot of downstream work that the stack
allocator was doing in order to coalesce and allocate these spill slots.

In cases with a lot of spill slot coalescing opportunities this
significantly reduces both compile time and memory usage of the compiler.

Also, generalize the Air register allocation stats a bit so that
stack allocation stats can be collected to make the work and outcome
easier to measure.

Tests already exercise this new logic so no new test.

* Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj:
* Source/JavaScriptCore/b3/air/AirAllocateRegistersByGreedy.cpp:
(JSC::B3::Air::Greedy::TmpData::dump const):
(JSC::B3::Air::Greedy::TmpData::validate):
(JSC::B3::Air::Greedy::GreedyAllocator::groupForSpill):
(JSC::B3::Air::Greedy::GreedyAllocator::groupForReg):
(JSC::B3::Air::Greedy::GreedyAllocator::assignedReg):
(JSC::B3::Air::Greedy::GreedyAllocator::spillSlot):
(JSC::B3::Air::Greedy::GreedyAllocator::validateAssignments):
(JSC::B3::Air::Greedy::GreedyAllocator::buildLiveRanges):
(JSC::B3::Air::Greedy::GreedyAllocator::finalizeGroups):
(JSC::B3::Air::Greedy::GreedyAllocator::setStageAndEnqueue):
(JSC::B3::Air::Greedy::GreedyAllocator::allocateRegisters):
(JSC::B3::Air::Greedy::GreedyAllocator::tryAllocate):
(JSC::B3::Air::Greedy::GreedyAllocator::assignImpl):
(JSC::B3::Air::Greedy::GreedyAllocator::evict):
(JSC::B3::Air::Greedy::GreedyAllocator::trySplitGroup):
(JSC::B3::Air::Greedy::GreedyAllocator::spill):
(JSC::B3::Air::Greedy::GreedyAllocator::emitSpillCodeAndEnqueueNewTmps):
(JSC::B3::Air::Greedy::GreedyAllocator::insertSplitAroundClobbersFixupCode):
(JSC::B3::Air::Greedy::GreedyAllocator::assignRegisters):
(JSC::B3::Air::Greedy::GreedyAllocator::groupForTmp): Deleted.
* Source/JavaScriptCore/b3/air/AirAllocateStackByGraphColoring.cpp:
(JSC::B3::Air::allocateStackByGraphColoring):
* Source/JavaScriptCore/b3/air/AirPhaseStats.h: Added.
* Source/JavaScriptCore/b3/air/AirRegisterAllocatorStats.h:
(JSC::B3::Air::AirAllocateRegistersStats::name const):
(JSC::B3::Air::AirAllocateRegistersStats::~AirAllocateRegistersStats): Deleted.
(JSC::B3::Air::AirAllocateRegistersStats::dump const): Deleted.
* Source/JavaScriptCore/b3/air/AirStackAllocatorStats.h: Added.
(JSC::B3::Air::AirStackAllocatorStats::name const):
* Source/JavaScriptCore/runtime/OptionsList.h:

Canonical link: https://commits.webkit.org/306945@main



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

Reply via email to