Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: pkg/compiler/lib/src/cps_ir/loop_hierarchy.dart

Issue 1444363002: dart2js cps: Global value numbering and loop-invariant code motion. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Add comment Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library dart2js.cps_ir.loop_hierarchy; 5 library dart2js.cps_ir.loop_hierarchy;
6 6
7 import 'cps_ir_nodes.dart'; 7 import 'cps_ir_nodes.dart';
8 8
9 /// Determines the effective nesting of loops. 9 /// Determines the effective nesting of loops.
10 /// 10 ///
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 } 143 }
144 target = _markInnerLoop(target, catchLoop); 144 target = _markInnerLoop(target, catchLoop);
145 for (Continuation cont in callContinuations) { 145 for (Continuation cont in callContinuations) {
146 // Store the loop target on each call continuation in the basic block. 146 // Store the loop target on each call continuation in the basic block.
147 // Because we walk over call continuations as part of the basic block 147 // Because we walk over call continuations as part of the basic block
148 // traversal, these do not get their loop target set otherwise. 148 // traversal, these do not get their loop target set otherwise.
149 loopTarget[cont] = target; 149 loopTarget[cont] = target;
150 } 150 }
151 return target; 151 return target;
152 } 152 }
153
154 /// Returns the the innermost loop that effectively encloses both
155 /// c1 and c2 (or `null` if there is no such loop).
156 Continuation lowestCommonAncestor(Continuation c1, Continuation c2) {
157 int d1 = getDepth(c1), d2 = getDepth(c2);
158 while (c1 != c2) {
159 if (d1 <= d2) {
160 c2 = getEnclosingLoop(c2);
161 d2 = getDepth(c2);
162 } else {
163 c1 = getEnclosingLoop(c1);
164 d1 = getDepth(c1);
165 }
166 }
167 return c1;
168 }
169
170 /// Returns the lexical nesting depth of [loop].
171 int getDepth(Continuation loop) {
172 if (loop == null) return -1;
sra1 2015/11/17 05:41:14 It would be useful if unnested was 0 (depth can th
asgerf 2015/11/17 12:43:43 Done. (The first loop had depth 1 so it kind of wr
173 return loopDepth[loop];
174 }
153 } 175 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698