aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-10-27 10:05:01 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-10-27 10:05:01 -0700
commit62df681398225bf957fec9e953c0ae25f691551a (patch)
tree21ba7225555b4ee6c08f076e92da97c2cbccc021 /tools
parentcb9b1db479868532192c764739b0578de68b91e4 (diff)
do not scan into while
Diffstat (limited to 'tools')
-rw-r--r--tools/eliminator/eliminator-test-output.js9
-rw-r--r--tools/eliminator/eliminator-test.js9
-rw-r--r--tools/js-optimizer.js7
3 files changed, 22 insertions, 3 deletions
diff --git a/tools/eliminator/eliminator-test-output.js b/tools/eliminator/eliminator-test-output.js
index 662d04dd..a0e4f1e7 100644
--- a/tools/eliminator/eliminator-test-output.js
+++ b/tools/eliminator/eliminator-test-output.js
@@ -58,6 +58,15 @@ function a() {
barrier();
var $65, $image, $51$s2;
HEAP32[$65 >> 2] = _int_ceildivpow2(HEAP32[$65 >> 2] - _int_ceildiv(HEAP32[$image >> 2], HEAP32[$51$s2]) | 0, HEAP32[$51$s2 + 10]);
+ barr();
+ var ONCE = sheep();
+ while (ONCE) {
+ work();
+ }
+ var ONCEb = 75;
+ while (ONCEb) {
+ work();
+ }
}
function b() {
var $148 = _sqlite3Strlen30($147);
diff --git a/tools/eliminator/eliminator-test.js b/tools/eliminator/eliminator-test.js
index f57cf252..d2c1e8fe 100644
--- a/tools/eliminator/eliminator-test.js
+++ b/tools/eliminator/eliminator-test.js
@@ -74,6 +74,15 @@ function a() {
var $66 = HEAP32[$65 >> 2];
var $71 = $66 - _int_ceildiv(HEAP32[$image >> 2], HEAP32[$51$s2]) | 0;
HEAP32[$65 >> 2] = _int_ceildivpow2($71, HEAP32[$51$s2 + 10]);
+ barr();
+ var ONCE = sheep();
+ while (ONCE) {
+ work();
+ }
+ var ONCEb = 75;
+ while (ONCEb) {
+ work();
+ }
}
function b() {
var $148 = _sqlite3Strlen30($147);
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js
index b915a9d8..f44e7b67 100644
--- a/tools/js-optimizer.js
+++ b/tools/js-optimizer.js
@@ -1369,7 +1369,7 @@ function registerize(ast) {
var ELIMINATION_SAFE_NODES = set('var', 'assign', 'call', 'if', 'toplevel');
var NODES_WITHOUT_ELIMINATION_SIDE_EFFECTS = set('name', 'num', 'string', 'binary', 'sub', 'unary-prefix');
var IGNORABLE_ELIMINATOR_SCAN_NODES = set('num', 'toplevel', 'string', 'break', 'continue', 'dot', 'return'); // dot can only be STRING_TABLE.*
-var ABORTING_ELIMINATOR_SCAN_NODES = set('new', 'object', 'function', 'defun', 'switch', 'for'); // we could handle some of these, TODO
+var ABORTING_ELIMINATOR_SCAN_NODES = set('new', 'object', 'function', 'defun', 'switch', 'for', 'while'); // we could handle some of these, TODO, but nontrivial (e.g. for while, the condition is hit multiple times after the body)
function eliminate(ast) {
// Find variables that have a single use, and if they can be eliminated, do so
@@ -1591,8 +1591,9 @@ function eliminate(ast) {
traverseInOrder(value);
if (name in potentials && allowTracking) {
track(name, value, node);
+ } else {
+ invalidateByDep(name);
}
- invalidateByDep(name);
}
}
} else if (type == 'binary') {
@@ -1646,7 +1647,7 @@ function eliminate(ast) {
traverseInOrder(node[1]);
} else if (type == 'label') {
traverseInOrder(node[2]);
- } else if (type == 'while' || type == 'seq') {
+ } else if (type == 'seq') {
traverseInOrder(node[1]);
traverseInOrder(node[2]);
} else if (type == 'do') {