-
Notifications
You must be signed in to change notification settings - Fork 745
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
Wrong conversion from double to int64 with SAFE_HEAP flag #1110
Comments
This is a corner case I'm not sure what to do with. What's going on is that
You can work around this for now by building with |
Meanwhile I documented the issue better on https://github.com/kripken/emscripten/wiki/WebAssembly#debugging Not sure yet what we can do aside from documenting this. A tricky point here that we may want to do something about is the interaction between the two optimizers. What can happen is
So the problem here is that the asm.js optimizer is unaware of the wasm trap mode. This is rarely an issue as we don't run the asm.js optimizer anymore, aside from special modes like SAFE_HEAP. Perhaps when we allow trapping in wasm but are forced to run the asm.js optimizer, we should issue a warning? Or perhaps we should disallow traps in wasm when doing so? |
Thank you for explanation. Warning definitely should be, but also this is issue because it generation wrong code. Why it generate |
The truncation operation uses |
Functions like For example:
Will crash with |
Yeah, that's a good example of the same issue. I verified |
Unfortunately |
@metalpavel you may want to follow along with the non-trapping-float-to-int proposal too. They're not available yet, but should help with this case. |
2 times slower is very bad. @metalpavel, can you maybe create a standalone benchmark of what you are seeing? Or if not, can you profile it and see what's going on? One possibility is that we could add separate flags for clamping different operations, this was proposed in the past but we didn't have data that supported it yet. |
Here is my simply benchmark with different types of floating points operations casts:
Tests:
|
Thanks for the benchmark. Some numbers about inlining are in #1125 , looks like we can get rid of most of the overhead that way, but not all. |
See also emscripten-core/emscripten#5498 |
Hi,
I create example for this issue:
Compile command:
em++ hello.cpp -O3 -s WASM=1 --emit-symbol-map --bind -s TOTAL_MEMORY=67108864 -s ALLOW_MEMORY_GROWTH=1 --memory-init-file 1 -g -s SAFE_HEAP=1 -s BINARYEN=1 -o hello.html
generate function:
(func $__Z12toSInteger64d (param $0 f64) (result i32)
and it crashes at
32.trunc_u/f64
without SAFE_HEAP it generates correct code:
(func $__Z12toSInteger64d (param $0 f64) (result i64)
with correct conversion
i64.trunc_s/f64
The text was updated successfully, but these errors were encountered: