binaryen icon indicating copy to clipboard operation
binaryen copied to clipboard

RemoveUnusedModuleElements: Optimize indirect calls when the table is immutable

Open kripken opened this issue 1 month ago • 1 comments

To do this, refactor the table scanning code out of Directize into TableUtils. Then when we see a CallIndirect in RemoveUnusedModuleElements, we no longer automatically assume it could call anything whose reference was taken: if we see the table is not modified, then only the table's known contents might be called.

That is, before: CallIndirect implied we could call anything of that type, in that table. But also, we assumed other things might be written into the table at runtime, so anything whose reference was taken was callable. After: We know which tables do not have new entries written into them.

kripken avatar Dec 08 '25 17:12 kripken

Measuring on Dart, I see a small benefit here. Probably it is small as other devirtualization etc. mechanisms already handle most things.

kripken avatar Dec 09 '25 23:12 kripken

friendly nonurgent ping @tlively

kripken avatar Dec 16 '25 17:12 kripken