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

Side by Side Diff: frog/leg/ssa/optimize.dart

Issue 9421035: Support break and labeled statements. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments. Created 8 years, 10 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 class SsaOptimizerTask extends CompilerTask { 5 class SsaOptimizerTask extends CompilerTask {
6 SsaOptimizerTask(Compiler compiler) : super(compiler); 6 SsaOptimizerTask(Compiler compiler) : super(compiler);
7 String get name() => 'SSA optimizer'; 7 String get name() => 'SSA optimizer';
8 8
9 void optimize(WorkItem work, HGraph graph) { 9 void optimize(WorkItem work, HGraph graph) {
10 measure(() { 10 measure(() {
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 HPhi phi = worklist.removeLast(); 289 HPhi phi = worklist.removeLast();
290 for (final input in phi.inputs) { 290 for (final input in phi.inputs) {
291 if (input is HPhi && !livePhis.contains(input)) { 291 if (input is HPhi && !livePhis.contains(input)) {
292 worklist.add(input); 292 worklist.add(input);
293 livePhis.add(input); 293 livePhis.add(input);
294 } 294 }
295 } 295 }
296 } 296 }
297 297
298 // Remove phis that are not live. 298 // Remove phis that are not live.
299 for (final block in graph.blocks) { 299 // Traverse in reverse order to remove phis with no uses before the
300 // phis that they might use.
301 // TODO(lrn): Handle cyclic usages.
302 List<HBasicBlock> blocks = graph.blocks;
303 for (int i = blocks.length - 1; i >= 0; i--) {
304 HBasicBlock block = blocks[i];
300 HPhi current = block.phis.first; 305 HPhi current = block.phis.first;
301 HPhi next = null; 306 HPhi next = null;
302 while (current != null) { 307 while (current != null) {
303 next = current.next; 308 next = current.next;
304 if (!livePhis.contains(current)) block.removePhi(current); 309 if (!livePhis.contains(current)) {
310 current.block.removePhi(current);
311 }
305 current = next; 312 current = next;
306 } 313 }
307 } 314 }
308 } 315 }
309 } 316 }
310 317
311 class SsaRedundantPhiEliminator { 318 class SsaRedundantPhiEliminator {
312 void visitGraph(HGraph graph) { 319 void visitGraph(HGraph graph) {
313 final List<HPhi> worklist = <HPhi>[]; 320 final List<HPhi> worklist = <HPhi>[];
314 321
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 } 611 }
605 } 612 }
606 if (!canBeMoved) continue; 613 if (!canBeMoved) continue;
607 614
608 // This is safe because we are running after GVN. 615 // This is safe because we are running after GVN.
609 // TODO(ngeoffray): ensure GVN has been run. 616 // TODO(ngeoffray): ensure GVN has been run.
610 set_.add(current); 617 set_.add(current);
611 } 618 }
612 } 619 }
613 } 620 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698