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

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: Removed unused var. Better trace output. 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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 while (!worklist.isEmpty()) { 288 while (!worklist.isEmpty()) {
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 recursiveRemove(HPhi phi) {
299 while (!phi.usedBy.isEmpty()) {
300 recursiveRemove(phi.usedBy[0]);
301 }
302 phi.block.removePhi(phi);
303 }
304
298 // Remove phis that are not live. 305 // Remove phis that are not live.
299 for (final block in graph.blocks) { 306 for (final block in graph.blocks) {
300 HPhi current = block.phis.first; 307 HPhi current = block.phis.first;
301 HPhi next = null; 308 HPhi next = null;
302 while (current != null) { 309 while (current != null) {
303 next = current.next; 310 next = current.next;
304 if (!livePhis.contains(current)) block.removePhi(current); 311 if (!livePhis.contains(current)) {
ngeoffray 2012/02/21 13:12:17 Should we visit post dominator instead?
Lasse Reichstein Nielsen 2012/02/21 13:53:56 That might work if there is no cyclic dependency.
312 // Remove any (dead phi) uses of current before removing current.
313 recursiveRemove(current);
314 }
305 current = next; 315 current = next;
306 } 316 }
307 } 317 }
308 } 318 }
309 } 319 }
310 320
311 class SsaRedundantPhiEliminator { 321 class SsaRedundantPhiEliminator {
312 void visitGraph(HGraph graph) { 322 void visitGraph(HGraph graph) {
313 final List<HPhi> worklist = <HPhi>[]; 323 final List<HPhi> worklist = <HPhi>[];
314 324
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 } 614 }
605 } 615 }
606 if (!canBeMoved) continue; 616 if (!canBeMoved) continue;
607 617
608 // This is safe because we are running after GVN. 618 // This is safe because we are running after GVN.
609 // TODO(ngeoffray): ensure GVN has been run. 619 // TODO(ngeoffray): ensure GVN has been run.
610 set_.add(current); 620 set_.add(current);
611 } 621 }
612 } 622 }
613 } 623 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698