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

Side by Side Diff: lib/compiler/implementation/ssa/nodes.dart

Issue 10454049: Validate that all instructions dominate their inputs. And fix a bug where that did not happen. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 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 interface HVisitor<R> { 5 interface HVisitor<R> {
6 R visitAdd(HAdd node); 6 R visitAdd(HAdd node);
7 R visitBitAnd(HBitAnd node); 7 R visitBitAnd(HBitAnd node);
8 R visitBitNot(HBitNot node); 8 R visitBitNot(HBitNot node);
9 R visitBitOr(HBitOr node); 9 R visitBitOr(HBitOr node);
10 R visitBitXor(HBitXor node); 10 R visitBitXor(HBitXor node);
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 } 654 }
655 655
656 void forEachPhi(void f(HPhi phi)) { 656 void forEachPhi(void f(HPhi phi)) {
657 HPhi current = phis.first; 657 HPhi current = phis.first;
658 while (current !== null) { 658 while (current !== null) {
659 f(current); 659 f(current);
660 current = current.next; 660 current = current.next;
661 } 661 }
662 } 662 }
663 663
664 void forEachInstruction(void f(HInstruction instruction)) {
665 HInstruction current = first;
666 while (current !== null) {
Lasse Reichstein Nielsen 2012/05/30 09:35:14 A block must have a non-null first instruction (ri
ngeoffray 2012/05/30 10:19:07 It might be safer to keep it as-is in case one use
667 f(current);
668 current = current.next;
669 }
670 }
671
664 bool isValid() { 672 bool isValid() {
665 assert(isClosed()); 673 assert(isClosed());
666 HValidator validator = new HValidator(); 674 HValidator validator = new HValidator();
667 validator.visitBasicBlock(this); 675 validator.visitBasicBlock(this);
668 return validator.isValid; 676 return validator.isValid;
669 } 677 }
670 678
671 // TODO(ngeoffray): Cache the information if this method ends up 679 // TODO(ngeoffray): Cache the information if this method ends up
672 // being hot. 680 // being hot.
673 bool dominates(HBasicBlock other) { 681 bool dominates(HBasicBlock other) {
(...skipping 983 matching lines...) Expand 10 before | Expand all | Expand 10 after
1657 final TargetElement target; 1665 final TargetElement target;
1658 final LabelElement label; 1666 final LabelElement label;
1659 HContinue(this.target) : label = null; 1667 HContinue(this.target) : label = null;
1660 HContinue.toLabel(LabelElement label) : label = label, target = label.target; 1668 HContinue.toLabel(LabelElement label) : label = label, target = label.target;
1661 toString() => (label !== null) ? 'continue ${label.labelName}' : 'continue'; 1669 toString() => (label !== null) ? 'continue ${label.labelName}' : 'continue';
1662 accept(HVisitor visitor) => visitor.visitContinue(this); 1670 accept(HVisitor visitor) => visitor.visitContinue(this);
1663 } 1671 }
1664 1672
1665 class HTry extends HControlFlow { 1673 class HTry extends HControlFlow {
1666 HParameterValue exception; 1674 HParameterValue exception;
1675 HBasicBlock catchBlock;
1667 HBasicBlock finallyBlock; 1676 HBasicBlock finallyBlock;
1668 HTry() : super(const <HInstruction>[]); 1677 HTry() : super(const <HInstruction>[]);
1669 toString() => 'try'; 1678 toString() => 'try';
1670 accept(HVisitor visitor) => visitor.visitTry(this); 1679 accept(HVisitor visitor) => visitor.visitTry(this);
1671 HBasicBlock get joinBlock() => this.block.successors.last(); 1680 HBasicBlock get joinBlock() => this.block.successors.last();
1672 } 1681 }
1673 1682
1674 class HIf extends HConditionalBranch { 1683 class HIf extends HConditionalBranch {
1675 bool hasElse; 1684 bool hasElse;
1676 HBlockFlow blockInformation = null; 1685 HBlockFlow blockInformation = null;
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after
2470 this.catchBlock, 2479 this.catchBlock,
2471 this.finallyBlock); 2480 this.finallyBlock);
2472 2481
2473 HBasicBlock get start() => body.start; 2482 HBasicBlock get start() => body.start;
2474 HBasicBlock get end() => 2483 HBasicBlock get end() =>
2475 finallyBlock === null ? catchBlock.end : finallyBlock.end; 2484 finallyBlock === null ? catchBlock.end : finallyBlock.end;
2476 2485
2477 bool accept(HStatementInformationVisitor visitor) => 2486 bool accept(HStatementInformationVisitor visitor) =>
2478 visitor.visitTryInfo(this); 2487 visitor.visitTryInfo(this);
2479 } 2488 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698