Bug 254960

Summary: Use fixed-size deadCells vector in MarkedBlock::sweep
Product: WebKit Reporter: David Degazio <d_degazio>
Component: JavaScriptCoreAssignee: David Degazio <d_degazio>
Status: RESOLVED FIXED    
Severity: Normal CC: webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

Description David Degazio 2023-04-03 17:36:48 PDT
rdar://107585451

In MarkedBlock::specializedSweep, we allocate a `Vector<uint64_t>` to store the list of dead cells we need to destroy. However, the maximum number of atoms in a MarkedBlock is bounded by a constant - currently 1024. This means we can do two things:

 - Because the maximum atom number is less than 65536, we can store them as `uint16_t`s to reduce memory usage/improve locality.
 
 - At only 1024 atoms per block, and since `specializedSweep` isn't recursive or anything, it's probably fine to allocate the full storage of the vector on the stack. This means we avoid allocation (both initially and to grow the vector), can use `Vector::uncheckedAppend`, and probably improve locality somewhat.
Comment 1 David Degazio 2023-04-03 17:42:47 PDT
Pull request: https://github.com/WebKit/WebKit/pull/12350
Comment 2 EWS 2023-04-04 23:45:35 PDT
Committed 262612@main (424d1996eedf): <https://commits.webkit.org/262612@main>

Reviewed commits have been landed. Closing PR #12350 and removing active labels.