Bug 260913

Summary: WasmSectionParser should use tryReserveInitialCapacity instead of tryReserveCapacity.
Product: WebKit Reporter: Mark Lam <mark.lam>
Component: JavaScriptCoreAssignee: Mark Lam <mark.lam>
Status: RESOLVED FIXED    
Severity: Normal CC: webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

Description Mark Lam 2023-08-30 10:31:36 PDT
We already enforced ordered section parsing, which also enforces that a section type can only be parsed once (with CustomSection being the only exception).  For each of these sections, there are many cases where capacity for their vector stores can be allocated with Vector::tryReserveInitialCapacity instead of Vector::tryReserveCapacity.  Vector::tryReserveInitialCapacity will be more efficient.

Added some RELEASE_ASSERTs to enforce the invariant that these section types are only parsed once.
Added Vector::growCapacityBy and Vector::tryGrowCapacityBy to more concisely express the idea that we're growing the capacity by some increment.

rdar://114175821
Comment 1 Mark Lam 2023-08-30 10:51:53 PDT
Pull request: https://github.com/WebKit/WebKit/pull/17237
Comment 2 EWS 2023-08-30 16:06:58 PDT
Committed 267469@main (78ca85d1db78): <https://commits.webkit.org/267469@main>

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