diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-11-08 14:54:18 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-11-08 14:54:18 -0800 |
commit | c715cec68f4c965ca443669fcf48eecfa70b52d8 (patch) | |
tree | 61203a49205021e1525655deb9a32074d00fa0bc /tools | |
parent | 7f870cf9c357f6a1138ba612ace7d7249f85e250 (diff) |
invalidate calls on conditionals in js optimizer, to avoid eliminating into a non-executing code path
Diffstat (limited to 'tools')
-rw-r--r-- | tools/eliminator/asm-eliminator-test-output.js | 7 | ||||
-rw-r--r-- | tools/eliminator/asm-eliminator-test.js | 10 | ||||
-rw-r--r-- | tools/js-optimizer.js | 4 |
3 files changed, 20 insertions, 1 deletions
diff --git a/tools/eliminator/asm-eliminator-test-output.js b/tools/eliminator/asm-eliminator-test-output.js index dda82047..434fbaf9 100644 --- a/tools/eliminator/asm-eliminator-test-output.js +++ b/tools/eliminator/asm-eliminator-test-output.js @@ -291,4 +291,11 @@ function watIf() { if ($cmp38) {} else {} } } +function select2($foundBase_0_off0) { + $foundBase_0_off0 = $foundBase_0_off0 | 0; + var $call24 = 0; + $call24 = MUST_RUN() | 0; + STACKTOP = sp; + return ($foundBase_0_off0 ? 0 : $call24) | 0; +} diff --git a/tools/eliminator/asm-eliminator-test.js b/tools/eliminator/asm-eliminator-test.js index 6f426150..7ec277d5 100644 --- a/tools/eliminator/asm-eliminator-test.js +++ b/tools/eliminator/asm-eliminator-test.js @@ -362,5 +362,13 @@ function watIf() { } } } -// 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"] +function select2($foundBase_0_off0) { + $foundBase_0_off0 = $foundBase_0_off0 | 0; + var $call24 = 0, $retval_0 = 0; + $call24 = MUST_RUN() | 0; + $retval_0 = $foundBase_0_off0 ? 0 : $call24; + STACKTOP = sp; + return $retval_0 | 0; +} +// 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", "select2"] diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index 022bdf47..36244298 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -2485,6 +2485,10 @@ function eliminate(ast, memSafe) { } else if (type === 'return') { if (node[1]) traverseInOrder(node[1]); } else if (type === 'conditional') { + if (!callsInvalidated) { // invalidate calls, since we cannot eliminate them into a branch of an LLVM select/JS conditional that does not execute + invalidateCalls(); + callsInvalidated = true; + } traverseInOrder(node[1]); traverseInOrder(node[2]); traverseInOrder(node[3]); |