diff options
Diffstat (limited to 'src/parseTools.js')
-rw-r--r-- | src/parseTools.js | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/parseTools.js b/src/parseTools.js index 7dafbebe..2eb456f1 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -1756,7 +1756,7 @@ function makeStructuralReturn(values, inAsm) { return 'return ' + asmCoercion(values.slice(1).map(function(value) { i++; return ASM_JS ? (inAsm ? 'tempRet' + i + ' = ' + value : 'asm.setTempRet' + i + '(' + value + ')') - : 'tempRet' + (i++) + ' = ' + value; + : 'tempRet' + i + ' = ' + value; }).concat([values[0]]).join(','), 'i32'); } else { var i = 0; @@ -1998,9 +1998,12 @@ function processMathop(item) { return finish(['(i64Math' + (ASM_JS ? '_' : '.') + type + '(' + asmCoercion(low1, 'i32') + ',' + asmCoercion(high1, 'i32') + ',' + asmCoercion(low2, 'i32') + ',' + asmCoercion(high2, 'i32') + (lastArg ? ',' + asmCoercion(+lastArg, 'i32') : '') + '),' + makeGetValue('tempDoublePtr', 0, 'i32') + ')', makeGetValue('tempDoublePtr', Runtime.getNativeTypeSize('i32'), 'i32')]); } - function i64PreciseLib(type) { + function preciseCall(name) { Types.preciseI64MathUsed = true; - return finish(['_i64' + type[0].toUpperCase() + type.substr(1) + '(' + low1 + ',' + high1 + ',' + low2 + ',' + high2 + ')', 'tempRet0']); + return finish([name + '(' + low1 + ',' + high1 + ',' + low2 + ',' + high2 + ')', 'tempRet0']); + } + function i64PreciseLib(type) { + return preciseCall('_i64' + type[0].toUpperCase() + type.substr(1)); } switch (op) { // basic integer ops @@ -2062,7 +2065,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)); @@ -2070,7 +2073,7 @@ function processMathop(item) { } case 'sdiv': case 'udiv': { if (PRECISE_I64_MATH) { - return i64PreciseOp('divide', op[0] === 'u'); + return preciseCall(op[0] === 'u' ? '___udivdi3' : '___divdi3'); } else { warnI64_1(); return finish(splitI64(makeRounding(mergeI64(idents[0], op[0] === 'u') + '/' + mergeI64(idents[1], op[0] === 'u'), bits, op[0] === 's'), true)); @@ -2078,7 +2081,7 @@ function processMathop(item) { } case 'mul': { if (PRECISE_I64_MATH) { - return i64PreciseOp('multiply'); + return preciseCall('___muldi3'); } else { warnI64_1(); return finish(splitI64(mergeI64(idents[0], op[0] === 'u') + '*' + mergeI64(idents[1], op[0] === 'u'), true)); @@ -2086,7 +2089,7 @@ function processMathop(item) { } case 'urem': case 'srem': { if (PRECISE_I64_MATH) { - return i64PreciseOp('modulo', op[0] === 'u'); + return preciseCall(op[0] === 'u' ? '___uremdi3' : '___remdi3'); } else { warnI64_1(); return finish(splitI64(mergeI64(idents[0], op[0] === 'u') + '%' + mergeI64(idents[1], op[0] === 'u'), true)); |