diff options
-rwxr-xr-x | emscripten.py | 3 | ||||
-rw-r--r-- | src/jsifier.js | 2 | ||||
-rw-r--r-- | src/library.js | 13 | ||||
-rw-r--r-- | src/long.js | 7 | ||||
-rw-r--r-- | src/parseTools.js | 2 |
5 files changed, 16 insertions, 11 deletions
diff --git a/emscripten.py b/emscripten.py index a5ebbb31..bfcc3ea5 100755 --- a/emscripten.py +++ b/emscripten.py @@ -385,9 +385,8 @@ def emscript(infile, settings, outfile, libraries=[], compiler_engine=None, basic_vars = ['STACKTOP', 'STACK_MAX', 'tempDoublePtr', 'ABORT'] basic_float_vars = ['NaN', 'Infinity'] if forwarded_json['Types']['preciseI64MathUsed']: - basic_funcs += ['i64Math_' + op for op in ['subtract', 'multiply', 'divide', 'modulo']] + basic_funcs += ['i64Math_' + op for op in ['multiply', 'divide', 'modulo']] asm_setup += ''' -var i64Math_subtract = function(a, b, c, d) { i64Math.subtract(a, b, c, d) }; var i64Math_multiply = function(a, b, c, d) { i64Math.multiply(a, b, c, d) }; var i64Math_divide = function(a, b, c, d, e) { i64Math.divide(a, b, c, d, e) }; var i64Math_modulo = function(a, b, c, d, e) { i64Math.modulo(a, b, c, d, e) }; diff --git a/src/jsifier.js b/src/jsifier.js index 262dd3eb..2cf94a0d 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -1606,7 +1606,7 @@ function JSify(data, functionsOnly, givenFunctions) { // "Final shape that will be created"). if (PRECISE_I64_MATH && Types.preciseI64MathUsed) { if (!INCLUDE_FULL_LIBRARY) { - ['i64Add', 'bitshift64Shl', 'bitshift64Lshr', 'bitshift64Ashr'].forEach(function(func) { + ['i64Add', 'i64Subtract', 'bitshift64Shl', 'bitshift64Lshr', 'bitshift64Ashr'].forEach(function(func) { print(processLibraryFunction(LibraryManager.library[func], func)); // must be first to be close to generated code Functions.implementedFunctions['_' + func] = LibraryManager.library[func + '__sig']; }); diff --git a/src/library.js b/src/library.js index f9864134..a792a681 100644 --- a/src/library.js +++ b/src/library.js @@ -7490,6 +7490,19 @@ LibraryManager.library = { {{{ makeStructuralReturn(['l|0', 'h', 'overflow'], true) }}}; }, + i64Subtract__asm: true, + i64Subtract__sig: 'iiiii', + i64Subtract: function(a, b, c, d) { + a = a|0; b = b|0; c = c|0; d = d|0; + var l = 0, h = 0; + l = (a - c)>>>0; + h = (b - d)>>>0; + if ((l>>>0) > (a>>>0)) { // iff we overflowed + h = (h-1)>>>0; + } + {{{ makeStructuralReturn(['l|0', 'h'], true) }}}; + }, + bitshift64Shl__asm: true, bitshift64Shl__sig: 'iiii', bitshift64Shl: function(low, high, bits) { diff --git a/src/long.js b/src/long.js index 6d0e873d..b3d19bd3 100644 --- a/src/long.js +++ b/src/long.js @@ -1530,13 +1530,6 @@ var i64Math = (function() { // Emscripten wrapper // Emscripten wrapper var Wrapper = { - 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); - 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); diff --git a/src/parseTools.js b/src/parseTools.js index 010f4988..a568b718 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -2062,7 +2062,7 @@ function processMathop(item) { } case 'sub': { if (PRECISE_I64_MATH) { - return i64PreciseOp('subtract'); + return i64PreciseLib('subtract'); } else { warnI64_1(); return finish(splitI64(mergeI64(idents[0]) + '-' + mergeI64(idents[1]), true)); |