diff options
-rw-r--r-- | tools/eliminator/eliminator-test-output.js | 10 | ||||
-rw-r--r-- | tools/eliminator/eliminator-test.js | 8 | ||||
-rw-r--r-- | tools/eliminator/eliminator.coffee | 5 |
3 files changed, 20 insertions, 3 deletions
diff --git a/tools/eliminator/eliminator-test-output.js b/tools/eliminator/eliminator-test-output.js index ccbd5e5f..594508d0 100644 --- a/tools/eliminator/eliminator-test-output.js +++ b/tools/eliminator/eliminator-test-output.js @@ -97,4 +97,12 @@ var anon = (function(x) { function r($0) { HEAP[$0 + 7] = 107; } -// EMSCRIPTEN_GENERATED_FUNCTIONS: ["f", "g", "h", "py", "r"] +function t() { + if ($10 < $11) { + __label__ = 3; + } + if (!($12 < $13)) { + __label__ = 4; + } +} +// EMSCRIPTEN_GENERATED_FUNCTIONS: ["f", "g", "h", "py", "r", "t"] diff --git a/tools/eliminator/eliminator-test.js b/tools/eliminator/eliminator-test.js index 2443d707..02ac0c08 100644 --- a/tools/eliminator/eliminator-test.js +++ b/tools/eliminator/eliminator-test.js @@ -108,5 +108,11 @@ var anon = function(x) { function r($0) { HEAP[$0 + 5 + 2] = 99+5+2+1; } -// EMSCRIPTEN_GENERATED_FUNCTIONS: ["f", "g", "h", "py", "r"] +function t() { + var $cmp2=($10) < ($11); + if ($cmp2) { __label__ = 3; } + var $cmp3=($12) < ($13); + if (!($cmp3)) { __label__ = 4; } +} +// EMSCRIPTEN_GENERATED_FUNCTIONS: ["f", "g", "h", "py", "r", "t"] diff --git a/tools/eliminator/eliminator.coffee b/tools/eliminator/eliminator.coffee index 62e7ef82..8b99338a 100644 --- a/tools/eliminator/eliminator.coffee +++ b/tools/eliminator/eliminator.coffee @@ -42,6 +42,7 @@ NODES_WITHOUT_SIDE_EFFECTS = string: true binary: true sub: true + 'unary-prefix': true # ++x can have side effects, but we never have that in generated code # Nodes which may break control flow. Moving a variable beyond them may have # side effects. @@ -148,7 +149,7 @@ class Eliminator varName = node[1] if @useCount.hasOwnProperty varName then @useCount[varName]++ else @isSingleDef[varName] = false - else if type in ['assign', 'unary-prefix', 'unary-postfix'] + else if type in ['assign'] varName = node[2][1] if @isSingleDef[varName] then @isSingleDef[varName] = false return undefined @@ -374,6 +375,8 @@ main = -> ast = uglify.parser.parse src + #process.stderr.write(JSON.stringify(ast) + '\n') + # Run on all functions. traverse ast, (node, type) -> if type in ['defun', 'function'] and isGenerated node[1] |