aboutsummaryrefslogtreecommitdiff
path: root/tools/js-optimizer.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2014-05-19 10:45:29 -0700
committerAlon Zakai <alonzakai@gmail.com>2014-05-19 10:45:29 -0700
commita4ae7a1c29e7873f77ea4168e1c8c2c66a7cb34a (patch)
tree3e4a7e7d0e2bd0584d3fe6935806b1f366943eea /tools/js-optimizer.js
parentf0dd2f8d2da50da0ab87f5e2585e59e7a5f521b7 (diff)
do not move around loop variable incrementations when the helper is used outside the loop
Diffstat (limited to 'tools/js-optimizer.js')
-rw-r--r--tools/js-optimizer.js4
1 files changed, 3 insertions, 1 deletions
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js
index c0096df4..0cd27aa8 100644
--- a/tools/js-optimizer.js
+++ b/tools/js-optimizer.js
@@ -3704,9 +3704,11 @@ function eliminate(ast, memSafe) {
}
if (firstLooperUsage >= 0) {
// the looper is used, we cannot simply merge the two variables
- if ((firstHelperUsage < 0 || firstHelperUsage > lastLooperUsage) && lastLooperUsage+1 < stats.length && triviallySafeToMove(stats[found], asmData)) {
+ if ((firstHelperUsage < 0 || firstHelperUsage > lastLooperUsage) && lastLooperUsage+1 < stats.length && triviallySafeToMove(stats[found], asmData) &&
+ seenUses[helper] === namings[helper]) {
// the helper is not used, or it is used after the last use of the looper, so they do not overlap,
// and the last looper usage is not on the last line (where we could not append after it), and the
+ // helper is not used outside of the loop.
// just move the looper definition to after the looper's last use
stats.splice(lastLooperUsage+1, 0, stats[found]);
stats.splice(found, 1);