diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-07-18 16:07:46 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-07-18 16:08:26 -0700 |
commit | a1a7cb6031f7120f229593e00879860ad01d09f5 (patch) | |
tree | 2f3fcbd53ecb0cdc0d383dc29abd62b6befa711e /tools/js-optimizer.js | |
parent | 646e5af8883c87e4c9b8e709c18fb65520199dc6 (diff) |
send variables to outlines code even if just written; they may not be written to, and we would write a zero incorrectly
Diffstat (limited to 'tools/js-optimizer.js')
-rw-r--r-- | tools/js-optimizer.js | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index dfc4d5dd..14d26a89 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -3118,11 +3118,11 @@ function outline(ast) { // add spills and reads before and after the call to the outlined code, and in the outlined code itself var codeInfo = analyzeCode(func, asmData, code); var reps = []; - for (var v in codeInfo.reads) { + keys(setUnion(codeInfo.reads, codeInfo.writes)).forEach(function(v) { if (v != 'sp') { reps.push(['stat', ['assign', true, ['sub', ['name', getAsmType(v, asmData) == ASM_INT ? 'HEAP32' : 'HEAPF32'], ['binary', '>>', ['binary', '+', ['name', 'sp'], ['num', asmData.stackPos[v]]], ['num', '2']]], ['name', v]]]); } - } + }); reps.push(['stat', ['call', ['name', newIdent], [['name', 'sp']]]]); for (var v in codeInfo.writes) { reps.push(['stat', ['assign', true, ['name', v], makeAsmCoercion(['sub', ['name', getAsmType(v, asmData) == ASM_INT ? 'HEAP32' : 'HEAPF32'], ['binary', '>>', ['binary', '+', ['name', 'sp'], ['num', asmData.stackPos[v]]], ['num', '2']]], getAsmType(v, asmData))]]); @@ -3240,11 +3240,11 @@ function outline(ast) { } } // add spills and unspills in outlined code outside the OL loop - for (var v in codeInfo.reads) { + keys(setUnion(codeInfo.reads, codeInfo.writes)).forEach(function(v) { if (v != 'sp') { code.unshift(['stat', ['assign', true, ['name', v], makeAsmCoercion(['sub', ['name', getAsmType(v, asmData) == ASM_INT ? 'HEAP32' : 'HEAPF32'], ['binary', '>>', ['binary', '+', ['name', 'sp'], ['num', asmData.stackPos[v]]], ['num', '2']]], getAsmType(v, asmData))]]); } - } + }); for (var v in codeInfo.writes) { code.push(['stat', ['assign', true, ['sub', ['name', getAsmType(v, asmData) == ASM_INT ? 'HEAP32' : 'HEAPF32'], ['binary', '>>', ['binary', '+', ['name', 'sp'], ['num', asmData.stackPos[v]]], ['num', '2']]], ['name', v]]]); } |