aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xemscripten.py2
-rw-r--r--src/jsifier.js4
-rw-r--r--src/parseTools.js13
3 files changed, 10 insertions, 9 deletions
diff --git a/emscripten.py b/emscripten.py
index 137d95cb..f978662c 100755
--- a/emscripten.py
+++ b/emscripten.py
@@ -413,7 +413,7 @@ var asm = (function(global, env, buffer) {
''' % (asm_setup,) + '\n' + asm_global_vars + '''
var __THREW__ = 0;
var undef = 0;
- var tempInt = 0, tempBigInt = 0, tempValue = 0;
+ var tempInt = 0, tempBigInt = 0, tempBigIntP = 0, tempBigIntS = 0, tempBigIntR = 0.0, tempBigIntI = 0, tempBigIntD = 0, tempValue = 0;
''' + ''.join(['''
var tempRet%d = 0;''' % i for i in range(10)]) + '\n' + asm_global_funcs + '''
function stackAlloc(size) {
diff --git a/src/jsifier.js b/src/jsifier.js
index dba2ad51..84a9b5f7 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -1106,7 +1106,7 @@ function JSify(data, functionsOnly, givenFunctions) {
var value;
if (useIfs) {
value = targetLabels[targetLabel].map(function(value) {
- return makeComparison(signedIdent, makeSignOp(value, item.type, 're'), item.type)
+ return makeComparison(signedIdent, '==', makeSignOp(value, item.type, 're'), item.type)
}).join(' | ');
ret += 'if (' + value + ') {\n';
} else {
@@ -1270,7 +1270,7 @@ function JSify(data, functionsOnly, givenFunctions) {
var phiSets = calcPhiSets(item);
var js = 'var ibr = ' + finalizeLLVMParameter(item.value) + ';\n';
for (var targetLabel in phiSets) {
- js += 'if (' + makeComparison('ibr', targetLabel, 'i32') + ') { ' + getPhiSetsForLabel(phiSets, targetLabel) + ' }\n';
+ js += 'if (' + makeComparison('ibr', '==', targetLabel, 'i32') + ') { ' + getPhiSetsForLabel(phiSets, targetLabel) + ' }\n';
}
return js + makeBranch('ibr', item.currLabelId, true);
});
diff --git a/src/parseTools.js b/src/parseTools.js
index 4f68d0a1..cceba188 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -1792,13 +1792,14 @@ function finalizeLLVMParameter(param, noIndexizeFunctions) {
return ret;
}
-function makeComparison(a, b, type) {
+function makeComparison(a, op, b, type) {
+ assert(type);
if (!isIllegalType(type)) {
- return asmCoercion(a, type) + ' == ' + asmCoercion(b, type);
+ return asmCoercion(a, type) + op + asmCoercion(b, type);
} else {
assert(type == 'i64');
- return asmCoercion(a + '$0', 'i32') + ' == ' + asmCoercion(b + '$0', 'i32') + ' & ' +
- asmCoercion(a + '$1', 'i32') + ' == ' + asmCoercion(b + '$1', 'i32');
+ return asmCoercion(a + '$0', 'i32') + op + asmCoercion(b + '$0', 'i32') + ' & ' +
+ asmCoercion(a + '$1', 'i32') + op + asmCoercion(b + '$1', 'i32');
}
}
@@ -1870,7 +1871,7 @@ function makeRounding(value, bits, signed, floatConversion) {
// Note that if converting a float, we may have the wrong sign at this point! But, we have
// been rounded properly regardless, and we will be sign-corrected later when actually used, if
// necessary.
- return makeInlineCalculation('VALUE >= 0 ? Math.floor(VALUE) : Math.ceil(VALUE)', value, 'tempBigIntR');
+ return makeInlineCalculation(makeComparison('VALUE', '>=', '0', 'float') + ' ? Math.floor(VALUE) : Math.ceil(VALUE)', value, 'tempBigIntR');
} else {
// asm.js mode, cleaner refactoring of this function as well. TODO: use in non-asm case, most of this
if (floatConversion && bits <= 32) {
@@ -1887,7 +1888,7 @@ function makeRounding(value, bits, signed, floatConversion) {
// Math.floor is reasonably fast if we don't care about corrections (and even correct if unsigned)
if (!correctRoundings() || !signed) return 'Math.floor(' + value + ')';
// We are left with >32 bits
- return makeInlineCalculation('VALUE >= 0 ? Math.floor(VALUE) : Math.ceil(VALUE)', value, 'tempBigIntR');
+ return makeInlineCalculation(makeComparison('VALUE', '>=', '0', 'float') + ' ? Math.floor(VALUE) : Math.ceil(VALUE)', value, 'tempBigIntR');
}
}