-
Notifications
You must be signed in to change notification settings - Fork 786
Add --trap-mode=allow/clamp/js argument to asm2wasm and s2wasm #1210
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
I think if |
Pretty much. It doesn't sit well with me because it's adding to domain-logic complexity to avoid implementational coupling. But yeah, optional is what I really want here. Or something like Haskell's |
Actually maybe the best option is just to throw an exception. Since we already use exceptions in Binaryen, which I seem to always forget. |
src/tools/asm2wasm.cpp
Outdated
@@ -78,22 +78,39 @@ int main(int argc, const char *argv[]) { | |||
[](Options *o, const std::string &) { | |||
std::cerr << "--no-opts is deprecated (use -O0, etc.)\n"; | |||
}) | |||
.add("--emit-potential-traps", "-i", "Emit instructions that might trap, like div/rem of 0", Options::Arguments::Zero, | |||
.add("--emit-potential-traps", "-i", |
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, is this keeping the old flags for compatibility?
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.
Yeah, should I not? And if so, should I remove --imprecise as well?
Actually if we keep it I should update --imprecise to say "old name for --trap-mode=allow" now, to keep that consistent.
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.
I think we should consider asm2wasm
as an implementation detail of emscripten, and aggressively eliminate legacy compatibility things.
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.
Yeah, I think these are internal implementation details, just between emcc and asm2wasm. So we can remove old stuff.
But we will need to land this and the emscripten PRs at the same time, and make sure the emscripten one updates the binaryen tag to a new tag on binaryen after that merge, so it uses the new code immediately.
Update command-line arguments to take trap mode itself as a string parameter.
Not sure how reasonable it is to add an
Invalid
mode to theTrapMode
enum just for error handling. I basically wanted a way to separate the argument string parsing logic from what to do with an error, and this seemed like the least-bad way to do that. Maybe it's moot and I should justexit
from insidetrapModeFromString
. Thoughts?