aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Kelly <ryan@rfk.id.au>2014-01-20 20:58:22 +1100
committerRyan Kelly <ryan@rfk.id.au>2014-01-20 21:50:09 +1100
commitdd4745db3ba58ceecebc406744d199231e5d7f7e (patch)
tree06b4bdcdbaa07f6d02637fe7563d412b61d40260
parent1c5d10fb5b13e5ac8927ea11de6c780ede117a16 (diff)
Fix a param-handling bug in normalizeAsm
-rw-r--r--tools/js-optimizer.js1
-rw-r--r--tools/test-js-optimizer-asm-regs-min-output.js5
-rw-r--r--tools/test-js-optimizer-asm-regs-min.js5
3 files changed, 11 insertions, 0 deletions
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js
index 6d65f3e7..d604f546 100644
--- a/tools/js-optimizer.js
+++ b/tools/js-optimizer.js
@@ -1603,6 +1603,7 @@ function normalizeAsm(func) {
node = node[1];
var name = node[2][1];
if (func[2] && func[2].indexOf(name) < 0) break; // not an assign into a parameter, but a global
+ if (name in data.params) break; // already done that param, must be starting function body
data.params[name] = detectAsmCoercion(node[3]);
stats[i] = emptyNode();
i++;
diff --git a/tools/test-js-optimizer-asm-regs-min-output.js b/tools/test-js-optimizer-asm-regs-min-output.js
index 3955e48a..748b8e0a 100644
--- a/tools/test-js-optimizer-asm-regs-min-output.js
+++ b/tools/test-js-optimizer-asm-regs-min-output.js
@@ -33,4 +33,9 @@ function cl(b) {
a(c);
i1(b);
}
+function cl(b) {
+ b = b | 0;
+ b = b + 4;
+ a(b);
+}
diff --git a/tools/test-js-optimizer-asm-regs-min.js b/tools/test-js-optimizer-asm-regs-min.js
index a5b9427e..65d8d429 100644
--- a/tools/test-js-optimizer-asm-regs-min.js
+++ b/tools/test-js-optimizer-asm-regs-min.js
@@ -33,5 +33,10 @@ function collideLocal(i1) {
aGlobal(a); // multiple collisions, a and i1
bGlobal(i1);
}
+function collideLocal(i1) {
+ i1 = i1 | 0;
+ i1 = i1 + 4; // statement is of similar shape to a param coercion
+ aGlobal(i1);
+}
// EMSCRIPTEN_GENERATED_FUNCTIONS
// EXTRA_INFO: { "names": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "i1", "cl"], "globals": { "aGlobal": "a", "bGlobal": "i1", "collideLocal": "cl" } }