-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
SIMD cmov code runs in node but fails in SpiderMonkey. #3560
Comments
…rns in a SIMD vector, don't attempt to create a float SIMD vector directly out of them, since JS source can't represent NaNs with noncanonical bits. Instead, create a int SIMD vector and cast it to float one to detour to the SIMD vector with correct bits intact. Fixes emscripten-core/emscripten#2840, emscripten-core/emscripten#3560, emscripten-core/emscripten#3010 and emscripten-core/emscripten#3403.
…rns in a SIMD vector, don't attempt to create a float SIMD vector directly out of them, since JS source can't represent NaNs with noncanonical bits. Instead, create a int SIMD vector and cast it to float one to detour to the SIMD vector with correct bits intact. Fixes emscripten-core/emscripten#2840, emscripten-core/emscripten#3560, emscripten-core/emscripten#3010 and emscripten-core/emscripten#3403.
I get the same uncaught exception in node as in spidermonkey, same output in both. |
…rns in a SIMD vector, don't attempt to create a float SIMD vector directly out of them, since JS source can't represent NaNs with noncanonical bits. Instead, create a int SIMD vector and cast it to float one to detour to the SIMD vector with correct bits intact. Fixes emscripten-core/emscripten#2840, emscripten-core/emscripten#3560, emscripten-core/emscripten#3010 and emscripten-core/emscripten#3403.
I'm also getting the same error in node now, not sure if I tested it wrong in node way back. In any case, the PR to emscripten-fastcomp fixes this in both. |
After talking with @kripken and looking at the testcases, it looks like NaN bit patterns in scalar values are a lost cause in JS and therefore also asm.js, however NaN bit patterns in SIMD values are doable. I wrote up this patch: sunfishcode/emscripten-fastcomp@7644927 which implements a fix just for vector constants, in a very simple way. I plan to clean this code up a bit, and it's not really tested yet, but I'm posting it here to see what people think. Is this a feasible way forward? |
…rns in a SIMD vector, don't attempt to create a float SIMD vector directly out of them, since JS source can't represent NaNs with noncanonical bits. Instead, create a int SIMD vector and cast it to float one to detour to the SIMD vector with correct bits intact. Fixes emscripten-core/emscripten#2840, emscripten-core/emscripten#3560, emscripten-core/emscripten#3010 and emscripten-core/emscripten#3403.
…rns in a SIMD vector, don't attempt to create a float SIMD vector directly out of them, since JS source can't represent NaNs with noncanonical bits. Instead, create a int SIMD vector and cast it to float one to detour to the SIMD vector with correct bits intact. Fixes emscripten-core/emscripten#2840, emscripten-core/emscripten#3560, emscripten-core/emscripten#3010 and emscripten-core/emscripten#3403.
Here is an interesting small test case that works as expected in node.js and native, but fails in SpiderMonkey/Firefox:
In native/node.js, it prints:
whereas in SpiderMonkey/Firefox, it prints:
This might be related to NaN canonicalization, and I recall @sunfishcode saying that the SIMD.js polyfill (what node.js is running) does canonicalize, but browser doesn't, but here the effect is the opposite(?).
The text was updated successfully, but these errors were encountered: