-
Notifications
You must be signed in to change notification settings - Fork 271
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
Add emscripten_notify_memory_growth import? #601
Comments
funny there's only one, and I guess it is multi-memory ready as the index is the memory index right? (always 0 at the moment) Adding something for emscripten sounds fine as it can consolidate the docs and stop people from having to type out what you added, solely to ignore the callback. Of course, even in Go, you may want to pay attention to it, if there's an unsafe view of memory. We can limit this to just the module part (ex similar to the /assemblyscript directory/package) and not dig into an example, yet. The default could be no-op and the builder could allow overriding via a Are you keen to give this a go? |
I think Wazero could provide some channel to send events when |
indeed an event listener was on topic a month or two ago. and yeah this emscripten function would exist regardless of that. so many neat things left on the plate :D |
ps we are doing some shifting around again, so I'll take this on to reduce drift (adding a small module for emscripten) |
Aside as it doesn't impact doing this, but it is related... You know this, but maybe others watching don't, that go also has this same notification API https://github.com/golang/go/blob/9839668b5619f45e293dd40339bf0ac614ea6bee/src/runtime/mem_js.go#L82 |
@inkeliz so re-parsing your comment having seen the pattern repeat in go. Here's my takeaway:
Am I getting this right? |
Yes. I think makes more sense to ignore "compiler-specific callbacks" (exports these functions as "no-op"). Expose a generic channel/callback (which will work regardless of the compiler/language): that should trigger when that Grow is called (and the buffer reallocates). |
sounds good. nuance to document:
any other thoughts? |
Yes, that makes sense.
I'm not sure if I understand "can affect multiple instantiated modules". But, I think that is quite expected, maybe just add it as an documentation. |
ps I've verified this builds and ends up with the following imports
|
@inkeliz I'm probably doing something stupid, but regardless of if the memory growth param is set, when I compile the above example, it invariably results in unreachable. ex without optimization
Were you able to successfully compile and run a main function using emcc like above? |
I added the
I'll look into this tomorrow unless someone has run into this before and knows what's up. |
oh wow. looks like emscripten wants to not be able to return from exit! emscripten-core/emscripten#12322 (comment) This is a separate issue we'll need to decide to panic by default or via config cc @anuraaga @mathetake |
This changes the AssemblyScript abort handler and WASI proc_exit implementation to panic the caller which eventually invoked close. This ensures no code executes afterwards, For example, LLVM inserts unreachable instructions after calls to exit. See emscripten-core/emscripten#12322 See #601 Signed-off-by: Adrian Cole <adrian@tetrate.io>
After this is in, emscripten should work naturally #673 Then, we can add a host module including a fake memory hook |
I don't remember to have this issue before, but I didn't test it recently. :S |
This changes the AssemblyScript abort handler and WASI proc_exit implementation to panic the caller which eventually invoked close. This ensures no code executes afterwards, For example, LLVM inserts unreachable instructions after calls to exit. See emscripten-core/emscripten#12322 See #601 Signed-off-by: Adrian Cole <adrian@tetrate.io>
This changes the AssemblyScript abort handler and WASI proc_exit implementation to panic the caller which eventually invoked close. This ensures no code executes afterwards, For example, LLVM inserts unreachable instructions after calls to exit. See emscripten-core/emscripten#12322 See #601 Signed-off-by: Adrian Cole <adrian@tetrate.io>
This changes the AssemblyScript abort handler and WASI proc_exit implementation to panic the caller which eventually invoked close. This ensures no code executes afterwards, For example, LLVM inserts unreachable instructions after calls to exit. See emscripten-core/emscripten#12322 See #601 Signed-off-by: Adrian Cole <adrian@tetrate.io>
This adds a toehold integration for emscripten users, so they don't have to define the memory growth function. Fixes #601 Signed-off-by: Adrian Cole <adrian@tetrate.io>
This adds a toehold integration for emscripten users, so they don't have to define the memory growth function. Fixes #601 Signed-off-by: Adrian Cole <adrian@tetrate.io>
This adds a toehold integration for emscripten users, so they don't have to define the memory growth function. Fixes #601 Signed-off-by: Adrian Cole <adrian@tetrate.io>
Is your feature request related to a problem? Please describe.
Compiling using emscripten requires
emscripten_notify_memory_growth
, defined at https://emscripten.org/docs/api_reference/emscripten.h.html#abi-functions.This is one single function and that is useless for Wazero. That is require for
malloc
.Minimal code:
Compile with:
Requires
emscripten_notify_memory_growth
.Describe the solution you'd like
Maybe Wazero can define such import, so any emscripten compiled wasm will work without declaring additional modules.
Describe alternatives you've considered
It's possible to fix by using:
That is very small footprint, but very annoying to declare it everytime.
Additional context
Maybe we can do something similar of AssemblyScript and create one new Emscripten package? However, it's very small, maybe can be declared on WASI? But, it's not WASI anyway. :\
The text was updated successfully, but these errors were encountered: