diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-12-23 18:42:28 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-12-23 18:42:28 -0800 |
commit | 508d4f02413a6f3d1924c17e410882081ba67615 (patch) | |
tree | 006f024f28455c7b54873e8862ed933af5562497 | |
parent | 5f00b61350b9236c36e81dafd5e8e3a9c93b347e (diff) |
make eliminator not get confused by calls without a return but with a coercion
-rw-r--r-- | tools/eliminator/asm-eliminator-test-output.js | 5 | ||||
-rw-r--r-- | tools/eliminator/asm-eliminator-test.js | 10 | ||||
-rw-r--r-- | tools/js-optimizer.js | 2 |
3 files changed, 15 insertions, 2 deletions
diff --git a/tools/eliminator/asm-eliminator-test-output.js b/tools/eliminator/asm-eliminator-test-output.js index c71063cb..a344fc35 100644 --- a/tools/eliminator/asm-eliminator-test-output.js +++ b/tools/eliminator/asm-eliminator-test-output.js @@ -299,4 +299,9 @@ function select2($foundBase_0_off0) { STACKTOP = sp; return ($foundBase_0_off0 ? 0 : $call24) | 0; } +function binary(x) { + x = x | 0; + memset(f(x)) | 0; + +dmemset(f(x)); +} diff --git a/tools/eliminator/asm-eliminator-test.js b/tools/eliminator/asm-eliminator-test.js index 7ec277d5..4b45e4d4 100644 --- a/tools/eliminator/asm-eliminator-test.js +++ b/tools/eliminator/asm-eliminator-test.js @@ -370,5 +370,13 @@ function select2($foundBase_0_off0) { 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"] +function binary(x) { + x = x | 0; + var y = 0, z = 0; + y = f(x); + memset(y) | 0; + z = f(x); + +dmemset(z); +} +// 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", "binary"] diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index 587221a6..296a5cae 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -2144,7 +2144,7 @@ function registerize(ast) { // In memSafe mode, we are more careful and assume functions can replace HEAP and FUNCTION_TABLE, which // can happen in ALLOW_MEMORY_GROWTH mode -var ELIMINATION_SAFE_NODES = set('var', 'assign', 'call', 'if', 'toplevel', 'do', 'return', 'label', 'switch'); // do is checked carefully, however +var ELIMINATION_SAFE_NODES = set('var', 'assign', 'call', 'if', 'toplevel', 'do', 'return', 'label', 'switch', 'binary', 'unary-prefix'); // do is checked carefully, however var IGNORABLE_ELIMINATOR_SCAN_NODES = set('num', 'toplevel', 'string', 'break', 'continue', 'dot'); // dot can only be STRING_TABLE.* var ABORTING_ELIMINATOR_SCAN_NODES = set('new', 'object', 'function', 'defun', 'for', 'while', 'array', 'throw'); // we could handle some of these, TODO, but nontrivial (e.g. for while, the condition is hit multiple times after the body) |