Bug 270376 - [JSC] Decode local indices at runtime in WASM in-place interpreter
Summary: [JSC] Decode local indices at runtime in WASM in-place interpreter
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebAssembly (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: David Degazio
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2024-03-01 13:43 PST by David Degazio
Modified: 2024-03-07 17:48 PST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Degazio 2024-03-01 13:43:49 PST
rdar://123720682

Local indices are encoded using ULEB128 in WebAssembly. In the work-in-progress in-place interpreter, we currently handle (U)LEB128 decoding during validation, and generate fully decoded indices in the metadata. Most functions, however, have very few locals in WebAssembly - WASM binaries that have gone through optimizations tend to treat locals like registers, and in all of JetStream 2 there is no local index that takes more than two bytes to encode. Since it's extremely common local indices will be single-byte, then it makes a lot of sense to skip the metadata entirely for all local instructions, instead having a single-byte fast path combined with an infrequently-taken ULEB128 decode at runtime. Since getting and setting locals makes up something like 1/3 of all WASM instructions in typical binaries, this should substantially reduce the size of the metadata generated for the in-place interpreter, and hopefully improve runtime performance as well.
Comment 1 David Degazio 2024-03-07 13:21:37 PST
Pull request: https://github.com/WebKit/WebKit/pull/25596
Comment 2 EWS 2024-03-07 17:48:18 PST
Committed 275815@main (bfe017002276): <https://commits.webkit.org/275815@main>

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