aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-01-29 13:13:48 -0800
committerAlon Zakai <alonzakai@gmail.com>2012-01-29 13:13:48 -0800
commit63abeaa88d35575419f87c594df1830b957e0b4e (patch)
tree3e8a91a3df8bd0704198e0c0484aed33c4c55ba4 /tools
parente29f63136bb41aa5c5c5ef33e67a4c7fa1a8e36e (diff)
fix eliminator bug with eliminating over loops
Diffstat (limited to 'tools')
-rw-r--r--tools/eliminator/eliminator-test-output.js9
-rw-r--r--tools/eliminator/eliminator-test.js10
-rw-r--r--tools/eliminator/eliminator.coffee6
3 files changed, 19 insertions, 6 deletions
diff --git a/tools/eliminator/eliminator-test-output.js b/tools/eliminator/eliminator-test-output.js
index da9be5cc..876340de 100644
--- a/tools/eliminator/eliminator-test-output.js
+++ b/tools/eliminator/eliminator-test-output.js
@@ -111,4 +111,11 @@ function f2() {
var $8 = $_pre;
c($8);
}
-// EMSCRIPTEN_GENERATED_FUNCTIONS: ["f", "g", "h", "py", "r", "t", "f2"]
+function f3($s, $tree, $k) {
+ var $0 = HEAPU32[($s + 2908 + ($k << 2) | 0) >> 2];
+ while (1) {
+ HEAP32[($s + 2908 + ($storemerge_in << 2) | 0) >> 2] = $9;
+ }
+ HEAP32[($s + 2908 + ($storemerge_in << 2) | 0) >> 2] = $0;
+}
+// EMSCRIPTEN_GENERATED_FUNCTIONS: ["f", "g", "h", "py", "r", "t", "f2", "f3"]
diff --git a/tools/eliminator/eliminator-test.js b/tools/eliminator/eliminator-test.js
index 3410499d..4928134a 100644
--- a/tools/eliminator/eliminator-test.js
+++ b/tools/eliminator/eliminator-test.js
@@ -122,5 +122,13 @@ function f2() {
var $8 = $_pre;
c($8);
}
-// EMSCRIPTEN_GENERATED_FUNCTIONS: ["f", "g", "h", "py", "r", "t", "f2"]
+function f3($s, $tree, $k) {
+ // HEAP vars alias each other, and the loop can confuse us
+ var $0 = HEAPU32[($s + 2908 + ($k << 2) | 0) >> 2];
+ while (1) {
+ HEAP32[($s + 2908 + ($storemerge_in << 2) | 0) >> 2] = $9;
+ }
+ HEAP32[($s + 2908 + ($storemerge_in << 2) | 0) >> 2] = $0;
+}
+// EMSCRIPTEN_GENERATED_FUNCTIONS: ["f", "g", "h", "py", "r", "t", "f2", "f3"]
diff --git a/tools/eliminator/eliminator.coffee b/tools/eliminator/eliminator.coffee
index 84e544b2..5b8ac43f 100644
--- a/tools/eliminator/eliminator.coffee
+++ b/tools/eliminator/eliminator.coffee
@@ -252,12 +252,10 @@ class Eliminator
traverseChild child
else
# Don't put anything from outside into the body of a loop.
- savedLive = isLive
isLive = {}
for child in node then traverseChild child
- for name of isLive
- if not isLive[name] then savedLive[name] = false
- isLive = savedLive
+ # Don't keep anything alive through a loop
+ isLive = {}
return node
else if type is 'var'
for [varName, varValue] in node[1]