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
Accessing the stack/heap from Javascript #1215
Comments
Yes, you can access the linear memory if you export it from the module. It will be a
No, that's not currently possible. The call stack is discarded when an exception is thrown. To do this, you'd have to instrument your module to allow for this behavior. It's likely that some of the extensions discussed in the exception-handling proposal would help here as well. |
Is the heap contained in the memory buffer? I haven't seen it mentioned in the documentation. |
A WebAssembly module doesn't have a heap, it just has a memory which is a flat vector of bytes. When a language like C++ is compiled to WebAssembly, the heap is stored in the memory, but so are other data. In general, the WebAssembly call stack (which includes the stack of called functions and their locals) is not stored in memory, and is not accessible. But when a language like C++ is compiled to WebAssembly, some elements of the C++ stack may be stored in memory. Generally these are the "address-taken" C++ variables and large arrays. |
Ah, I see, so that's what the __heap_base is for!
Thank you very much! |
WebAssembly.Memory is so called heap |
Is it possible to access the heap of the calling WASM instance within an imported Javascript function?
Related, is it possible to resume an instance after an imported Javascript function threw an exception? Specifically, right after point where it stopped, including the current heap data, call stack etc.
I'm trying to find out whether it is possible to make WASM processes orthogonally persistent, and that not only between calls, but within calls (for example when they run out of resources, see https://github.com/ewasm/wasm-metering).
The text was updated successfully, but these errors were encountered: