diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-03-08 13:51:56 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-03-08 13:51:56 -0800 |
commit | 51bbcd608450d161d1c26fc83aab545837929a86 (patch) | |
tree | cb54ce0574b1f1d6235cfc1878c0614ddc4e0f57 /tools | |
parent | 52b9d04de89f922d9499415f2fe04f8ff6375e9f (diff) |
handle assigns into globals at the top of asm functions in normalizeAsm
Diffstat (limited to 'tools')
-rw-r--r-- | tools/js-optimizer.js | 4 | ||||
-rw-r--r-- | tools/test-js-optimizer-asm-regs-output.js | 4 | ||||
-rw-r--r-- | tools/test-js-optimizer-asm-regs.js | 6 |
3 files changed, 12 insertions, 2 deletions
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index 0387f9fd..77ad0ba3 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -1302,7 +1302,9 @@ function normalizeAsm(func) { var node = stats[i]; if (node[0] != 'stat' || node[1][0] != 'assign' || node[1][2][0] != 'name') break; node = node[1]; - data.params[node[2][1]] = detectAsmCoercion(node[3]); + var name = node[2][1]; + if (func[2] && func[2].indexOf(name) < 0) break; // not an assign into a parameter, but a global + data.params[name] = detectAsmCoercion(node[3]); stats[i] = emptyNode(); i++; } diff --git a/tools/test-js-optimizer-asm-regs-output.js b/tools/test-js-optimizer-asm-regs-output.js index 99bccd2e..8c0bd970 100644 --- a/tools/test-js-optimizer-asm-regs-output.js +++ b/tools/test-js-optimizer-asm-regs-output.js @@ -38,4 +38,8 @@ function retf() { } return +0; } +function stackRestore(i1) { + i1 = i1 | 0; + STACKTOP = i1; +} diff --git a/tools/test-js-optimizer-asm-regs.js b/tools/test-js-optimizer-asm-regs.js index 0afced29..a8b637ce 100644 --- a/tools/test-js-optimizer-asm-regs.js +++ b/tools/test-js-optimizer-asm-regs.js @@ -41,5 +41,9 @@ function retf() { } // missing final return, need it as a float } -// EMSCRIPTEN_GENERATED_FUNCTIONS: ["asm", "_doit", "rett", "ret2t", "retf"] +function stackRestore(top) { + top = top|0; + STACKTOP = top; +} +// EMSCRIPTEN_GENERATED_FUNCTIONS: ["asm", "_doit", "rett", "ret2t", "retf", "stackRestore"] |