Skip to content

RemoveUnusedModuleElements: Scan indirect calls once up front [NFC]#8116

Merged
kripken merged 2 commits into
WebAssembly:mainfrom
kripken:rume.typeEF
Dec 12, 2025
Merged

RemoveUnusedModuleElements: Scan indirect calls once up front [NFC]#8116
kripken merged 2 commits into
WebAssembly:mainfrom
kripken:rume.typeEF

Conversation

@kripken
Copy link
Copy Markdown
Member

@kripken kripken commented Dec 11, 2025

Before, for each call_indirect signature (type+table) we scanned the elems to
find the callable functions. We used caching here, so it seemed fairly fast.
Measuring on a large Dart testcase, however, just scanning the elems
multiple times (once per type) is a lot of overhead. This avoids that by
scanning elems up front and filling in a data structure with all the info for
fast querying later.

Note the real overhead is not the table scanning, but all the HeapType::isSubType
calls. If we could make those fast it would be good, but this PR avoids the
issue in this pass at least.

This PR may be slower if no indirect calls exist (in that case we'd never
scan the table), but I see no memory overhead and it makes this Dart
testcase almost 2.8x faster on this pass, which runs more than once,
making the total -O3 noticeably faster, 15%.

@tlively suggested this and I did not realize how big a win it could be!

cc #4165

@kripken kripken requested a review from tlively December 11, 2025 23:56
@kripken kripken merged commit 2a05afe into WebAssembly:main Dec 12, 2025
17 checks passed
@kripken kripken deleted the rume.typeEF branch December 12, 2025 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants