diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-12-01 14:19:52 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-12-07 14:23:22 -0800 |
commit | 74c843c55f0238bd75a919fdd5b2dc2f57f48fe2 (patch) | |
tree | f10d06d0da4c5cd88ec6f2c2fc93af2b349a4c39 /src | |
parent | 61e57490b2f55f57291f8d28a79805d5bd84f176 (diff) |
i64Math in asm
Diffstat (limited to 'src')
-rw-r--r-- | src/library.js | 6 | ||||
-rw-r--r-- | src/long.js | 29 | ||||
-rw-r--r-- | src/parseTools.js | 6 |
3 files changed, 20 insertions, 21 deletions
diff --git a/src/library.js b/src/library.js index f8e1022b..9e447232 100644 --- a/src/library.js +++ b/src/library.js @@ -5064,16 +5064,16 @@ LibraryManager.library = { llvm_uadd_with_overflow_i64: function(xl, xh, yl, yh) { i64Math.add(xl, xh, yl, yh); return { - f0: i64Math.result, + f0: [HEAP32[tempDoublePtr>>2], HEAP32[tempDoublePtr+4>>2]], f1: 0 // XXX Need to hack support for this in long.js }; }, llvm_umul_with_overflow_i64__deps: [function() { Types.preciseI64MathUsed = 1 }], llvm_umul_with_overflow_i64: function(xl, xh, yl, yh) { - i64Math.mul(xl, xh, yl, yh); + i64Math.multiply(xl, xh, yl, yh); return { - f0: i64Math.result, + f0: [HEAP32[tempDoublePtr>>2], HEAP32[tempDoublePtr+4>>2]], f1: 0 // XXX Need to hack support for this in long.js }; }, diff --git a/src/long.js b/src/long.js index d5770e48..865540db 100644 --- a/src/long.js +++ b/src/long.js @@ -1530,27 +1530,26 @@ var i64Math = (function() { // Emscripten wrapper // Emscripten wrapper var Wrapper = { - result: [0, 0], // return result stored here add: function(xl, xh, yl, yh) { var x = new goog.math.Long(xl, xh); var y = new goog.math.Long(yl, yh); var ret = x.add(y); - Wrapper.result[0] = ret.low_; - Wrapper.result[1] = ret.high_; + HEAP32[tempDoublePtr>>2] = ret.low_; + HEAP32[tempDoublePtr+4>>2] = ret.high_; }, subtract: function(xl, xh, yl, yh) { var x = new goog.math.Long(xl, xh); var y = new goog.math.Long(yl, yh); var ret = x.subtract(y); - Wrapper.result[0] = ret.low_; - Wrapper.result[1] = ret.high_; + HEAP32[tempDoublePtr>>2] = ret.low_; + HEAP32[tempDoublePtr+4>>2] = ret.high_; }, multiply: function(xl, xh, yl, yh) { var x = new goog.math.Long(xl, xh); var y = new goog.math.Long(yl, yh); var ret = x.multiply(y); - Wrapper.result[0] = ret.low_; - Wrapper.result[1] = ret.high_; + HEAP32[tempDoublePtr>>2] = ret.low_; + HEAP32[tempDoublePtr+4>>2] = ret.high_; }, makeTwo32: function() { Wrapper.two32 = new BigInteger(); @@ -1573,8 +1572,8 @@ var i64Math = (function() { // Emscripten wrapper var x = new goog.math.Long(xl, xh); var y = new goog.math.Long(yl, yh); var ret = x.div(y); - Wrapper.result[0] = ret.low_; - Wrapper.result[1] = ret.high_; + HEAP32[tempDoublePtr>>2] = ret.low_; + HEAP32[tempDoublePtr+4>>2] = ret.high_; } else { // slow precise bignum division var x = Wrapper.lh2bignum(xl >>> 0, xh >>> 0); @@ -1584,8 +1583,8 @@ var i64Math = (function() { // Emscripten wrapper var l = new BigInteger(); var h = new BigInteger(); z.divRemTo(Wrapper.two32, h, l); - Wrapper.result[0] = parseInt(l.toString()) | 0; - Wrapper.result[1] = parseInt(h.toString()) | 0; + HEAP32[tempDoublePtr>>2] = parseInt(l.toString()) | 0; + HEAP32[tempDoublePtr+4>>2] = parseInt(h.toString()) | 0; } }, modulo: function(xl, xh, yl, yh, unsigned) { @@ -1594,8 +1593,8 @@ var i64Math = (function() { // Emscripten wrapper var x = new goog.math.Long(xl, xh); var y = new goog.math.Long(yl, yh); var ret = x.modulo(y); - Wrapper.result[0] = ret.low_; - Wrapper.result[1] = ret.high_; + HEAP32[tempDoublePtr>>2] = ret.low_; + HEAP32[tempDoublePtr+4>>2] = ret.high_; } else { // slow precise bignum division var x = Wrapper.lh2bignum(xl >>> 0, xh >>> 0); @@ -1605,8 +1604,8 @@ var i64Math = (function() { // Emscripten wrapper var l = new BigInteger(); var h = new BigInteger(); z.divRemTo(Wrapper.two32, h, l); - Wrapper.result[0] = parseInt(l.toString()) | 0; - Wrapper.result[1] = parseInt(h.toString()) | 0; + HEAP32[tempDoublePtr>>2] = parseInt(l.toString()) | 0; + HEAP32[tempDoublePtr+4>>2] = parseInt(h.toString()) | 0; } }, stringify: function(l, h, unsigned) { diff --git a/src/parseTools.js b/src/parseTools.js index e31a3027..258ef40a 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -1737,8 +1737,8 @@ function processMathop(item) { } function i64PreciseOp(type, lastArg) { Types.preciseI64MathUsed = true; - return finish(['(i64Math.' + type + '(' + low1 + ',' + high1 + ',' + low2 + ',' + high2 + - (lastArg ? ',' + lastArg : '') + '),i64Math.result[0])', 'i64Math.result[1]']); + return finish(['(i64Math' + (ASM_JS ? '_' : '.') + type + '(' + low1 + ',' + high1 + ',' + low2 + ',' + high2 + + (lastArg ? ',' + lastArg : '') + '),' + makeGetValue('tempDoublePtr', 0, 'i32') + ')', makeGetValue('tempDoublePtr', Runtime.getNativeTypeSize('i32'), 'i32')]); } switch (op) { // basic integer ops @@ -1898,7 +1898,7 @@ function processMathop(item) { case 'mul': { if (bits == 32 && PRECISE_I32_MUL) { Types.preciseI64MathUsed = true; - return '(i64Math.multiply(' + idents[0] + ',0,' + idents[1] + ',0),i64Math.result[0])'; + return '(i64Math' + (ASM_JS ? '_' : '.') + 'multiply(' + idents[0] + ',0,' + idents[1] + ',0),' + makeGetValue('tempDoublePtr', 0, 'i32') + ')'; } else { return handleOverflow(getFastValue(idents[0], '*', idents[1], item.type), bits); } |