diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-10-27 13:00:56 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-10-27 13:00:56 -0700 |
commit | 00497b25cb90415d43c3ea56f2cf5fa2ca60c0a8 (patch) | |
tree | 7cc91575fe4fcf9dad3ac932c55a63cc2d75485c | |
parent | 9538f033eca496fd30af2b483414d051911f8812 (diff) |
note function arguments as locals
-rw-r--r-- | tools/eliminator/eliminator-test-output.js | 3 | ||||
-rw-r--r-- | tools/eliminator/eliminator-test.js | 5 | ||||
-rw-r--r-- | tools/js-optimizer.js | 7 |
3 files changed, 13 insertions, 2 deletions
diff --git a/tools/eliminator/eliminator-test-output.js b/tools/eliminator/eliminator-test-output.js index a0e4f1e7..29e7c185 100644 --- a/tools/eliminator/eliminator-test-output.js +++ b/tools/eliminator/eliminator-test-output.js @@ -1,4 +1,5 @@ -function a() { +function a($directory) { + chak($directory + _strlen($directory) | 0); var $210 = HEAP32[100]; HEAP32[1e3] = HEAP32[5]; HEAP32[90] = $210; diff --git a/tools/eliminator/eliminator-test.js b/tools/eliminator/eliminator-test.js index d2c1e8fe..7d0a865e 100644 --- a/tools/eliminator/eliminator-test.js +++ b/tools/eliminator/eliminator-test.js @@ -1,4 +1,7 @@ -function a() { +function a($directory) { + var $1 = _strlen($directory); + var $p_0 = $directory + $1 | 0; + chak($p_0); var $210 = HEAP32[100]; // heaps alias each other! so this cannot be eliminated HEAP32[1e3] = HEAP32[5]; HEAP32[90] = $210; diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index 203db5bc..b9a0bce8 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -1382,6 +1382,13 @@ function eliminate(ast) { var values = {}; var locals = {}; var varsToRemove = {}; // variables being removed, that we can eliminate all 'var x;' of + // add arguments as locals + if (func[2]) { + for (var i = 0; i < func[2].length; i++) { + locals[func[2][i]] = true; + } + } + // examine body and note locals traverse(func, function(node, type) { if (type === 'var') { var node1 = node[1]; |