Bug 228615

Summary: [JSC/Air] Optimize enableMovesOnValueAndAdjacents in IRC
Product: WebKit Reporter: Robin Morisset <rmorisset>
Component: JavaScriptCoreAssignee: Robin Morisset <rmorisset>
Status: RESOLVED FIXED    
Severity: Normal CC: ews-watchlist, keith_miller, mark.lam, msaboff, saam, tzagallo, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
saam: review+
Patch none

Description Robin Morisset 2021-07-29 15:37:04 PDT
The Iterated Register Coalescing (IRC) register coalescing spends a very significant fraction of its time in JS2 in enableMovesOnValueAndAdjacents (816ms out of 2.07s spent in register allocation for Wasm code in one particular run).
The reason is that if this function is called on N nodes that are neighbors of each other, then enableMovesOnValue (which is kinda expensive as it iterates a SmallSet which is not always small) will be called N times on each of the N nodes. This can trivially be fixed by keeping track of which nodes need enableMovesOnValue called on them and only calling it on them once.
Comment 1 Robin Morisset 2021-07-29 15:50:06 PDT
Created attachment 434580 [details]
Patch
Comment 2 Radar WebKit Bug Importer 2021-08-05 15:37:16 PDT
<rdar://problem/81587890>
Comment 3 Saam Barati 2021-11-17 16:14:30 PST
Comment on attachment 434580 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=434580&action=review

> Source/JavaScriptCore/b3/air/AirAllocateRegistersByGraphColoring.cpp:1322
> +    // Set of Tmps whose moves are now ready for possible coalescing.
> +    BitVector m_hasMovesToEnable;

nit: I'd name this "m_movesToEnable"
Comment 4 Robin Morisset 2021-11-18 14:31:43 PST
Created attachment 444739 [details]
Patch
Comment 5 EWS 2021-11-18 22:06:41 PST
Committed r286045 (244432@main): <https://commits.webkit.org/244432@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 444739 [details].