-
Couldn't load subscription status.
- Fork 3.4k
[SPLIT_MODULE] Fix imports into deferred module when loading #25621
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
[SPLIT_MODULE] Fix imports into deferred module when loading #25621
Conversation
…odule upon loading
|
I only see a test change so I guess this PR is WIP? |
Yes, I plan to have the tests fail first and add in the fix later, which should fix the tests as well 🙏 |
|
Sure, we can't actually land the failing test right? So I guess I'll wait to review this? |
|
(If you are just experimenting then maybe do that with the PR marked as "DRAFT" or you can also do that in your own fork too) |
|
@sbc100 I have reproduced the issue I'm facing in the test suite and some attempted fix that works in resolving this issue. |
|
@aheejin @tlively who have been working on module splitting more than I have. The solution does seem reasonable yes. We so something similar in dynamic linking where we maintain Can you please wrap all these changes in |
|
Sorry, I'm not sure if I understand the problem and the solution here. Can you give the command line to run your test? It'd be good if we have a test in one of Also... I guess I'm missing something, but the solution just looks like renaming |
I think the issue is that if we just use The issue only shows up course then wrapper functions are used. |
Thanks for explaning the issue @sbc100 |
test/other/test_split_module.c
Outdated
| #include <stdio.h> | ||
| #include <emscripten.h> | ||
| #include <stdlib.h> // For malloc and free | ||
| #include <stdint.h> // For int64_t |
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.
This line is no longer needed
Does this mean |
the wrappers we generate for wasm64 are for the benefit of JS. They basically turn bigint values into numbers so that JS developers don't have to worry about the "pointers are bigints" problem (at least not in most cases). The importing function between one wasm module and another we explictly do not want to use these wrappers, and that would actually break, which this PR fixes I believe. |
|
@sbc100 test sanity has been failing but it seems to be unrelated to my changes. |
|
Yup, i think a rebase would fix but I'm also happy to just land as-is. Thanks for the contribution! |
Fix an error when attempted to reserve a new memory space in the deferred module when building with MEMORY64 + SPLIT_MODULE.
In a mem64 build, we call applySignatureConversions on
malloc()in the wasmExports.applySignatureConversions()wraps the exports and converts the return value to a javascript number. The wasmExports is passed into the deferred module during instantiation so when we call a malloc in the deferred module, we'd be calling the wrapped function, hitting into this error.Furthermore, we are making a direct call when calling a malloc, so strictly speaking, we should not need to go through the JS trampoline.