-
-
Notifications
You must be signed in to change notification settings - Fork 670
Add WASI abort, trace and seed implementations #1159
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
Conversation
Alright, it now also supports UTF8 and can auto-detect the presence of the WASI bindings. New usage is: import "wasi"; // anywhere in your code As soon as the WASI bindings are used, the non-standard fallback |
It could be great do same auto-detection for seedRandom: #1080 as well. wdyt? |
This now not only implements |
Also verified that the tests "just work" in a few actual headless Wasm VMs, but I guess we'll want something to do that as part of the test suite eventually. Tried Wasmtime and Wasmer, which both seem very similar. |
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.
Thank you sooooooo much for this! 🙏 😄
I think this is going to make WASI like 1000x easier to get started with in my opinion 😄 Especially once we update as-wasi on top of this 😄 👍
@@ -0,0 +1,5 @@ | |||
import "wasi"; |
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.
Wooooaaaahhh this is soooo cool! 💥 🎉
Thank you so much for this, it's like 1000x cooler than what I was suggesting haha! 😄
return reinterpret<f64>(rand); | ||
} | ||
|
||
export * from "bindings/wasi"; |
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.
With the import "wasi"
syntax. Does this automatically provide all of the bindings, without having to import them individually?
And I assume current projects can just keep importing them individually right? 😄 This is such a great solution 😄
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.
Yes, one can either enable all this stuff including stdlib-provided implementations abort/trace/seed by import "wasi"
or use the bindings with custom implementations and command line options (similar to before, import "bindings/wasi"
), with the former implying (and re-exporting) the latter.
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.
In case this didn't exactly answer the question: import * as wasi from "wasi"
is what one would do to also have all the bindings at their fingertips :)
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.
Oh that's perfect! Thank you! 😄 👍
That's a very nice improvement! |
Terrible implementations of
abort
andtrace
specifically for WASI that are as minimal and robust as it gets (allocation would be especially evil in abort if the abort originates in MM/GC).Output format is:
Also implements
seed
, which is a new API for seedingMath.random
. Now happens automatically in WASI environments, and requires an importenv.seed
in other environments.Presence of the WASI bindings is automatically detected. Usage is:
with each of the APIs being overridable with
--use
just as before (with or without WASI being present).