aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-06-25 10:52:54 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-06-25 10:52:54 -0700
commit6f3337677dbec6716d9a08f4414454d6472926ee (patch)
tree845dcb685aa057de470d44804048b71cff5ce5a0
parentde688a4e5d5a57959d55626c4b0283e715dfebaa (diff)
fix crash in js optimizer loop variables pass on empty if blocks
-rw-r--r--tools/eliminator/asm-eliminator-test-output.js5
-rw-r--r--tools/eliminator/asm-eliminator-test.js8
-rw-r--r--tools/js-optimizer.js4
3 files changed, 14 insertions, 3 deletions
diff --git a/tools/eliminator/asm-eliminator-test-output.js b/tools/eliminator/asm-eliminator-test-output.js
index b28fbd4a..5cc6238e 100644
--- a/tools/eliminator/asm-eliminator-test-output.js
+++ b/tools/eliminator/asm-eliminator-test-output.js
@@ -5121,4 +5121,9 @@ function tempDouble2($46, $14, $28, $42, $20, $32, $45) {
HEAP32[$45 + 4 >> 2] = $_sroa_06_0_insert_insert$1;
HEAP32[$45 + 8 >> 2] = $_sroa_06_0_insert_insert$1;
}
+function watIf() {
+ while (1) {
+ if ($cmp38) {} else {}
+ }
+}
diff --git a/tools/eliminator/asm-eliminator-test.js b/tools/eliminator/asm-eliminator-test.js
index f90c3557..b33c6040 100644
--- a/tools/eliminator/asm-eliminator-test.js
+++ b/tools/eliminator/asm-eliminator-test.js
@@ -6851,5 +6851,11 @@ function tempDouble2($46, $14, $28, $42, $20, $32, $45) {
HEAP32[$45 + 4 >> 2] = $_sroa_06_0_insert_insert$1;
HEAP32[$45 + 8 >> 2] = $_sroa_06_0_insert_insert$1;
}
-// EMSCRIPTEN_GENERATED_FUNCTIONS: ["asm", "__Z11printResultPiS_j", "_segment_holding", "__ZN5identC2EiPKcPci", "_vec2Length", "exc", "label", "confuusion", "tempDouble", "_org_apache_harmony_luni_util_NumberConverter_freeFormat__", "__ZN23b2EdgeAndPolygonContact8EvaluateEP10b2ManifoldRK11b2TransformS4_", "_java_nio_charset_Charset_forNameInternal___java_lang_String", "looop2", "looop3", "looop4", "looop5", "looop6", "looop7", "looop8", "multiloop", "multiloop2", "tempDouble2"]
+function watIf() {
+ while (1) {
+ if ($cmp38) {} else {
+ }
+ }
+}
+// EMSCRIPTEN_GENERATED_FUNCTIONS: ["asm", "__Z11printResultPiS_j", "_segment_holding", "__ZN5identC2EiPKcPci", "_vec2Length", "exc", "label", "confuusion", "tempDouble", "_org_apache_harmony_luni_util_NumberConverter_freeFormat__", "__ZN23b2EdgeAndPolygonContact8EvaluateEP10b2ManifoldRK11b2TransformS4_", "_java_nio_charset_Charset_forNameInternal___java_lang_String", "looop2", "looop3", "looop4", "looop5", "looop6", "looop7", "looop8", "multiloop", "multiloop2", "tempDouble2", "watIf"]
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js
index 67cd8066..7561abc8 100644
--- a/tools/js-optimizer.js
+++ b/tools/js-optimizer.js
@@ -2535,13 +2535,13 @@ function eliminate(ast, memSafe) {
var ifTrue = last[2];
var ifFalse = last[3];
var flip = false;
- if (ifFalse[1][0][0] == 'break') { // canonicalize break in the if
+ if (ifFalse[1][0] && ifFalse[1][0][0] == 'break') { // canonicalize break in the if
var temp = ifFalse;
ifFalse = ifTrue;
ifTrue = temp;
flip = true;
}
- if (ifTrue[1][0][0] == 'break') {
+ if (ifTrue[1][0] && ifTrue[1][0][0] == 'break') {
var assigns = ifFalse[1];
var loopers = [], helpers = [];
for (var i = 0; i < assigns.length; i++) {