Accessing WebAssembly memory ?

43 views
Skip to first unread message

Stéphane Letz

unread,
May 16, 2019, 1:22:41 PM5/16/19
to emscripten-discuss
In a previous version of Emscripten, I was able to access the underlying WebAssembly memory by just using the Module['wasmMemory'] field. This does not work anymore with code compiled using Emscripten with 1.38.30.
 
Is there an official and reliable way to access the WebAssembly memory? I need that when giving a correctly built importObject argument in the WebAssembly.Instance function.

Thanks

Alon Zakai

unread,
May 16, 2019, 5:36:07 PM5/16/19
to emscripte...@googlegroups.com
We removed undocumented automatic exporting like that for several objects, as it is bad for code size if you don't need those exports.

But wasmMemory still exists as a JS variable, so you can access it from EM_JS/EM_ASM, --post-js, etc., and you can capture it there (and export it, if you want).

- Alon


--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/bc4d31de-59fb-474c-9dd9-792aa3fe648d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Stéphane Letz

unread,
May 24, 2019, 6:13:26 AM5/24/19
to emscripten-discuss
I could indeed access the wasmMemory variable from an EM_ASM block compiled on C++ side. But I can not access for the JS side, like if is was not properly exported. How can that be done ? What is the --post-js code to add to do that?

Thanks.


Le jeudi 16 mai 2019 23:36:07 UTC+2, Alon Zakai a écrit :
We removed undocumented automatic exporting like that for several objects, as it is bad for code size if you don't need those exports.

But wasmMemory still exists as a JS variable, so you can access it from EM_JS/EM_ASM, --post-js, etc., and you can capture it there (and export it, if you want).

- Alon


On Thu, May 16, 2019 at 10:22 AM Stéphane Letz <le...@grame.fr> wrote:
In a previous version of Emscripten, I was able to access the underlying WebAssembly memory by just using the Module['wasmMemory'] field. This does not work anymore with code compiled using Emscripten with 1.38.30.
 
Is there an official and reliable way to access the WebAssembly memory? I need that when giving a correctly built importObject argument in the WebAssembly.Instance function.

Thanks

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.

Alon Zakai

unread,
May 24, 2019, 1:02:54 PM5/24/19
to emscripte...@googlegroups.com
You can do in a post-js

Module['wasmMemory'] = wasmMemory;

and then from JS that only has access to Module from the outside you can do Module.wasmMemory.


On Fri, May 24, 2019 at 3:13 AM Stéphane Letz <le...@grame.fr> wrote:
I could indeed access the wasmMemory variable from an EM_ASM block compiled on C++ side. But I can not access for the JS side, like if is was not properly exported. How can that be done ? What is the --post-js code to add to do that?

Thanks.

Le jeudi 16 mai 2019 23:36:07 UTC+2, Alon Zakai a écrit :
We removed undocumented automatic exporting like that for several objects, as it is bad for code size if you don't need those exports.

But wasmMemory still exists as a JS variable, so you can access it from EM_JS/EM_ASM, --post-js, etc., and you can capture it there (and export it, if you want).

- Alon


On Thu, May 16, 2019 at 10:22 AM Stéphane Letz <le...@grame.fr> wrote:
In a previous version of Emscripten, I was able to access the underlying WebAssembly memory by just using the Module['wasmMemory'] field. This does not work anymore with code compiled using Emscripten with 1.38.30.
 
Is there an official and reliable way to access the WebAssembly memory? I need that when giving a correctly built importObject argument in the WebAssembly.Instance function.

Thanks

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/9902a80d-7c60-4b02-812b-3ad95a5daa90%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages