diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-02-22 18:41:37 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-02-22 18:55:13 -0800 |
commit | c00e097d60100c7a562ac25664eb3c25bb9403ae (patch) | |
tree | f724c92e09a6c24c85110a33fc40561a2b0dcbb4 /src | |
parent | 90710c0c8ee4425c06402cc7831abdee8c519a43 (diff) |
always use Math.imul, with fast polyfill. will be useful for faster 64-bit math
Diffstat (limited to 'src')
-rw-r--r-- | src/parseTools.js | 6 | ||||
-rw-r--r-- | src/preamble.js | 2 | ||||
-rw-r--r-- | src/settings.js | 1 |
3 files changed, 4 insertions, 5 deletions
diff --git a/src/parseTools.js b/src/parseTools.js index 15c2169b..514d74d0 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -1046,10 +1046,8 @@ function asmMultiplyI32(a, b) { if ((isNumber(a) && Math.abs(a) < TWO_TWENTY) || (isNumber(b) && Math.abs(b) < TWO_TWENTY)) { return '(((' + a + ')*(' + b + '))&-1)'; // small enough to emit directly as a multiply } - if (USE_MATH_IMUL) { - return 'Math.imul(' + a + ',' + b + ')'; - } - return '(~~(+((' + a + ')|0) * +((' + b + ')|0)))'; + return 'Math.imul(' + a + ',' + b + ')'; + // non-imul version: return '(~~(+((' + a + ')|0) * +((' + b + ')|0)))'; } function asmFloatToInt(x) { diff --git a/src/preamble.js b/src/preamble.js index 503b09f1..b355f130 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -742,6 +742,8 @@ Module['writeArrayToMemory'] = writeArrayToMemory; {{{ unSign }}} {{{ reSign }}} +if (!Math.imul) Math.imul = function(x, y) { return (x*y)|0 }; // # not a real polyfill since semantics not identical, but close and fast + // 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 diff --git a/src/settings.js b/src/settings.js index f4e23c5b..1023ee11 100644 --- a/src/settings.js +++ b/src/settings.js @@ -325,7 +325,6 @@ var BENCHMARK = 0; // If 1, will just time how long main() takes to execute, and var ASM_JS = 0; // If 1, generate code in asm.js format. XXX This is highly experimental, // and will not work on most codebases yet. It is NOT recommended that you // try this yet. -var USE_MATH_IMUL = 1; // If 1, use Math.imul when normal int math can't be done in ASM_JS var EXPLICIT_ZEXT = 0; // If 1, generate an explicit conversion of zext i1 to i32, using ?: |