Repository navigation
Conversation
parse_local_functions decodes every function body a second time to find the implicit block types of legacy catch handlers, on one thread, before it parses the bodies in parallel. The scan runs for any module with a tag that has params, which includes every Emscripten module built with C++ exceptions because of the `__cpp_exception(i32)` tag, or with a function type that has two or more results. legacy_catch_block_types now takes &self and returns the types instead of adding them to ModuleTypes, so with the `parallel` feature the scan runs over all bodies in parallel. The serial loop adds each function's types after its entry block type, as before, so type IDs are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
✅ Parsing a module scans every function body for the implicit block types of legacy catch handlers. This PR moves that scan out of the serial per-function loop. The scan now returns the types per function and, with parallel, runs over the bodies with par_iter. The serial loop still adds each function's types right after its entry block type, so TypeId order is unchanged. It looks aimed at speeding up wasm-bindgen on Emscripten C++-exception modules, where the __cpp_exception(i32) tag always triggers the scan. The change looks correct to me and I have no concerns: rayon's ordered collect::<Result<Vec<_>>> keeps results in function order, Module, IndicesToIds and the bodies are already shared across threads in the main parse, and the existing tests in legacy-exceptions-multivalue-catch.rs cover the handler types both with and without parallel.
parse_local_functionsdecodes every function body a second time to find the implicit block types of legacycatchhandlers. It does this on one thread, before it parses the bodies in parallel. The scan runs for any module with a tag that has params, or with a function type that has two or more results. Every Emscripten module built with C++ exceptions has such a tag,__cpp_exception(i32), even when no function uses a legacytry.Change
register_legacy_catch_block_typesis renamed tolegacy_catch_block_types. It now takes&selfand returns the types instead of adding them toModuleTypes.parallelfeature, the scan runs over all bodies withpar_iter.Performance
I ran wasm-bindgen on a 74 MB Emscripten module built with C++ exceptions, on a 12-core Linux VM. wasm-bindgen enables walrus's
parallelfeature. The wasm-bindgen build ismainwith wasm-bindgen/wasm-bindgen#5479, wasm-bindgen/wasm-bindgen#5480, wasm-bindgen/wasm-bindgen#5481 and wasm-bindgen/wasm-bindgen#5482 applied. Each figure is the median wall time of 7 runs.mainwasm-bindgen's output for this module is byte-identical with both versions of walrus.
The existing tests in
legacy-exceptions-multivalue-catch.rscover the handler types this scan finds, with and withoutparallel.🤖 Generated with Claude Code