diff options
author | Alon Zakai <alonzakai@gmail.com> | 2014-02-03 22:12:41 -0500 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2014-02-03 22:12:41 -0500 |
commit | b6782ad900f6f4487aba973fbd04e8e232a33e79 (patch) | |
tree | 8fa139ae83616aef6ac9105598e6a1c207210f1d /tools/js-optimizer.js | |
parent | 9ce41213fd7c3978952cf8beae785e7ce0e7064d (diff) |
handle fround in optimizing out of tempDoublePtr
Diffstat (limited to 'tools/js-optimizer.js')
-rw-r--r-- | tools/js-optimizer.js | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index 21d521fd..2ae3ce47 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -709,6 +709,10 @@ function simplifyExpressions(ast) { } } }); + var hasFloat = false; + for (var v in asmData.vars) { + if (asmData.vars[v] === ASM_FLOAT) hasFloat = true; + } for (var v in bitcastVars) { var info = bitcastVars[v]; // good variables define only one type, use only one type, have definitions and uses, and define as a different type than they use @@ -729,7 +733,12 @@ function simplifyExpressions(ast) { info.uses.forEach(function(use) { use[2][1][1] = correct; }); - asmData.vars[v] = 1 - asmData.vars[v]; + var correctType; + switch(asmData.vars[v]) { + case ASM_INT: correctType = hasFloat ? ASM_FLOAT : ASM_DOUBLE; break; + case ASM_FLOAT: case ASM_DOUBLE: correctType = ASM_INT; break; + } + asmData.vars[v] = correctType; } } denormalizeAsm(ast, asmData); @@ -1577,7 +1586,7 @@ function makeAsmVarDef(v, type) { case ASM_INT: return [v, ['num', 0]]; case ASM_DOUBLE: return [v, ['unary-prefix', '+', ['num', 0]]]; case ASM_FLOAT: return [v, ['call', ['name', 'Math_fround'], [['num', 0]]]]; - default: throw 'wha?'; + default: throw 'wha? ' + JSON.stringify([node, type]) + new Error().stack; } } |