diff options
-rw-r--r-- | tools/eliminator/asm-eliminator-test-output.js | 1 | ||||
-rw-r--r-- | tools/eliminator/asm-eliminator-test.js | 3 | ||||
-rw-r--r-- | tools/js-optimizer.js | 4 |
3 files changed, 6 insertions, 2 deletions
diff --git a/tools/eliminator/asm-eliminator-test-output.js b/tools/eliminator/asm-eliminator-test-output.js index 9b874ba6..a7eebe25 100644 --- a/tools/eliminator/asm-eliminator-test-output.js +++ b/tools/eliminator/asm-eliminator-test-output.js @@ -5047,5 +5047,6 @@ function looop7() { } } HEAP32[$old_0_i107_i >> 2] = HEAP32[$696 >> 2] | 0; + while (1) {} } diff --git a/tools/eliminator/asm-eliminator-test.js b/tools/eliminator/asm-eliminator-test.js index 9524bde2..22b6ddec 100644 --- a/tools/eliminator/asm-eliminator-test.js +++ b/tools/eliminator/asm-eliminator-test.js @@ -6771,6 +6771,9 @@ function looop7() { } } HEAP32[$old_0_i107_i >> 2] = HEAP32[$696 >> 2] | 0; + // empty loop + while (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"] diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index 67ce2b3d..2b05aeb3 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -2364,7 +2364,7 @@ function eliminate(ast, memSafe) { // try to remove loop helper variables specifically var stats = node[2][1]; var last = stats[stats.length-1]; - if (last[0] == 'if' && last[2][0] == 'block' && last[3] && last[3][0] == 'block') { + if (last && last[0] == 'if' && last[2][0] == 'block' && last[3] && last[3][0] == 'block') { var ifTrue = last[2]; var ifFalse = last[3]; var flip = false; @@ -2555,7 +2555,7 @@ function asmLoopOptimizer(ast) { // while (1) { .. if (..) { break } } ==> do { .. } while(..) var stats = node[2][1]; var last = stats[stats.length-1]; - if (last[0] == 'if' && !last[3] && last[2][0] == 'block' && last[2][1][0][0] == 'break' && !last[2][1][0][1]) { + if (last && last[0] == 'if' && !last[3] && last[2][0] == 'block' && last[2][1][0][0] == 'break' && !last[2][1][0][1]) { var conditionToBreak = last[1]; stats.pop(); node[0] = 'do'; |