3 ms·
It's not an extra two operations. An optimizing JIT like CrankShaft or IonMonkey can remove the first |0 operation in code paths where it is not needed (that is
by azakai 13y ago
It's not an extra two operations. An optimizing JIT like CrankShaft or IonMonkey can remove the first |0 operation in code paths where it is not needed (that is, where you call it with an integer), and can remove the second |0 even more easily by simple inference - in fact, the second |0 allows the JIT to emit a 32-bit addition, with no overflow checks. So it can make code faster, with or without asm.js.
- kibibu 13y agoCount the number of times you wrote "can" vs how many times you typed "does". Similar stuff happens with C++ compilers all the time, where certain code "can" help the compiler but, in practice, doesn't always. The linked benchmarks do show a slowdown with asm.js in IE10. Whether this is due to type annotations or something else I don't know.
- azakai 13y agoAre you saying it's as unpredictable as C++ performance then? I'll take that ;) I wrote "can" because there are no guarantees, but in practice, this is definitely done in Firefox and Chrome. See http://www.arewefastyet.com/#machine=11&view=breakdown&suite=asmjs-ubench http://www.arewefastyet.com/#machine=11&view=breakdown&#... - they don't get that close to native speed without such optimizations. Not sure what is going on in IE10, but I am more curious about IE11.