-
Notifications
You must be signed in to change notification settings - Fork 836
MinifyImportsAndExports: Minify the memory and table as well. #3089
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| } | ||
| if (module->table.exists) { | ||
| processImport(&module->table); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we just use iterImportedMemories and iterImportedTables?
Or better still add an iterImports and just use that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, good idea for iterImports, that's much nicer. Added now.
(edit: and yes, I forgot about iterImportedMemories and iterImportedTables)
sbc100
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!
Code size improvements + stack improvements are inbound, WebAssembly/binaryen#3089 WebAssembly/binaryen#3091
Code size improvements are from WebAssembly/binaryen#3089 which lets us now minify the name of the memory and the table among the wasm imports and exports. Reverts the disablings in #12099, #12100 (except for the safe stack one, which requires more fixes in a subsequent PR).
| std::map<Name, Name> newToOld; | ||
| auto process = [&](Name& name) { | ||
| // do not minifiy special imports, they must always exist | ||
| if (name == MEMORY_BASE || name == TABLE_BASE || name == STACK_POINTER) { |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the special stack pointer import is relevant only for dynamic linking, but as mentioned earlier, we don't run this pass in that case anyhow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I see
We were careful not to minify those, as well as the stack pointer, which
makes sense in dynamic linking. But we don't run this pass in dynamic linking
anyhow - we need the proper names of symbols in that case. So this was
not helping us, and was just a leftover from an early state.
This both a useful optimization and also important for #3043,
as the wasm backend exports the table as
__indirect_function_table- a muchlonger name than emscripten's
table. So just changing to that would regresscode size on small projects. Once we land this, the name won't matter as it will
be minified anyhow.
This will break some tests on the roller as it improves code size beyond
current expectations, so it will require a double-roll or a temporary test
disabling.