-
-
Notifications
You must be signed in to change notification settings - Fork 116
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
feat(compiler): Deduplicate foreign imports #2233
feat(compiler): Deduplicate foreign imports #2233
Conversation
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.
I think that you're getting a stack overflow because the snapshot is massive. As of the new object files PR, we don't do snapshots of wat
anymore because they're a lot bigger (and thus impossible to really diff/read). The way to test this is programmatically. An example of a test that looks at wasm exports (and you can do the same for imports) is
grain/compiler/test/suites/modules.re
Line 156 in 4b56c53
expect.list(Option.get(export_sections)).toContainEqual(( |
753c558
to
ac65ee8
Compare
I would lean towards trying to prevent the issue rather than rely on the Binaryen pass. I think you're right that this would be annoying to resolve during codegen, but I don't think this is bad to fix as a part of linking at all, because it's already keeping track of names to rewrite. You could dedupe the imports and just keep the needed name in the resolver. |
9dae5f8
to
2691ae7
Compare
I refactored this change to handle things in compcore but I still need to figure out why our smallest program got larger, it seems to be that the wrapper isn't being inlined anymore but I am unsure why. |
Both those changes have been made. |
Why is this marked as breaking? |
I wasn't sure if we considered this optimization a breaking change or not, I'll mark it as non breaking though. |
As a note if we merge this before a fix is made for #2243 we will need to make sure to handle the |
This enables the binaryen pass to de-duplicate imports, if were against using the binaryen pass I think we can also do this manually in
compcore
and just filter through the imports incompile_imports
but we'll have to manually handle re-patching the import identifiers through the program.This makes developing for runtimes such as
wasmtime
a little nicer.This also adds the
assertWasmSnapshot
which let's us testwat
snapshots for optimizations that occur after, as the regular mashtree snapshots won't catch these, we can get away with a simpleprint("test")
here because multiple places in the runtime importfd_write
.Closes: #2152