by zobzu · 13y ago · 0 comments
Also its slightly slower (a few %) than regular JS on browsers without asm.js support.
Of crippled native, with things like SIMD instructions disabled.
Second, compilers also do auto vectorization (automatically vectorizing code that is not explicitly written to use vector types / SIMD intrinsics) and in addition SSE is used even for scalar floating point operations these days. It doesn't look like asm.js even lets you operate on single precision (32 bit) floating point values which can be a performance issue in some cases.
Last, web workers are less flexible than native multithreading with shared memory between threads and atomic instructions / mutexes etc.
These and other issues mean it will not be possible to squeeze as much performance (and as a result power savings) out of asm.js as from native code or PNaCL.
You sure you meant what you said here?
function add1(x) {
x = x|0; // x : int
return (x+1)|0;
}
This declares x to be an int in asm.js, which allows a bunch of optimizations. In a non-asm.js engine, it is an extra 2 operations.It's not difficult to believe that a non-asm.js engine would be slower with the type annotations than without, although I don't have any performance numbers to check.
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.