-
Notifications
You must be signed in to change notification settings - Fork 785
How to convert imported variables? #6
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
Comments
This is an issue that happens because WebAssembly does not have global variables. The idea is that people use locations in memory to replace them, but that requires interaction with the compiler, so it knows where it can place them. For emscripten, we just reserve 8-1000 for such "mapped globals" as we call them, and we know that will be enough room. We could make this work for other asm.js code too. The mapping shows up in |
I see. So before running WASM code, load_mapped_globals() should be called to copy imported variables to the correct locations and inside WASM, global variable access is interpreted to load/store of linear memory. |
Yes, exactly. Out of curiosity, are you trying to convert asm.js from a non-emscripten source? |
No, I also convert asm.js generated by EmScripten to v8-native binary format. Since v8-native still supports Global variable, I need to consider how to initialize the imported variables to the global variables. My current solution is to import variables by FFI function call, like Then modify the asm.js code to call this initialization before running _main function. |
I see. Yes, something like that could work too. |
Closing because asm2wasm no longer exists! |
From the output of asm2wasm, I find it just simply delete the imported variables statements, such as "var i = env.STACKTOP | 0; ". Without the support of imported variables, can this tool support all asm.js?
The text was updated successfully, but these errors were encountered: