diff options
Diffstat (limited to 'src/preamble.js')
-rw-r--r-- | src/preamble.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/preamble.js b/src/preamble.js index 24049283..6f4b49de 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -748,6 +748,20 @@ Module['writeArrayToMemory'] = writeArrayToMemory; {{{ unSign }}} {{{ reSign }}} +#if PRECISE_I32_MUL +if (!Math.imul) Math.imul = function(a, b) { + var ah = a >>> 16; + var al = a & 0xffff; + var bh = b >>> 16; + var bl = b & 0xffff; + return (al*bl + ((ah*bl + al*bh) << 16))|0; +}; +#else +Math.imul = function(a, b) { + return (a*b)|0; // fast but imprecise +}; +#endif + // A counter of dependencies for calling run(). If we need to // do asynchronous work before running, increment this and // decrement it. Incrementing must happen in a place like |