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

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

Issue 9718034: Continue for simple loops (while/for). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 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 visitBailoutTarget(HBailoutTarget node); 7 R visitBailoutTarget(HBailoutTarget node);
8 R visitBitAnd(HBitAnd node); 8 R visitBitAnd(HBitAnd node);
9 R visitBitNot(HBitNot node); 9 R visitBitNot(HBitNot node);
10 R visitBitOr(HBitOr node); 10 R visitBitOr(HBitOr node);
11 R visitBitXor(HBitXor node); 11 R visitBitXor(HBitXor node);
12 R visitBoolify(HBoolify node); 12 R visitBoolify(HBoolify node);
13 R visitBoundsCheck(HBoundsCheck node); 13 R visitBoundsCheck(HBoundsCheck node);
14 R visitBreak(HBreak node); 14 R visitBreak(HBreak node);
15 R visitConstant(HConstant node); 15 R visitConstant(HConstant node);
16 R visitContinue(HContinue node);
16 R visitDivide(HDivide node); 17 R visitDivide(HDivide node);
17 R visitEquals(HEquals node); 18 R visitEquals(HEquals node);
18 R visitExit(HExit node); 19 R visitExit(HExit node);
19 R visitFieldGet(HFieldGet node); 20 R visitFieldGet(HFieldGet node);
20 R visitFieldSet(HFieldSet node); 21 R visitFieldSet(HFieldSet node);
21 R visitForeign(HForeign node); 22 R visitForeign(HForeign node);
22 R visitForeignNew(HForeignNew node); 23 R visitForeignNew(HForeignNew node);
23 R visitGoto(HGoto node); 24 R visitGoto(HGoto node);
24 R visitGreater(HGreater node); 25 R visitGreater(HGreater node);
25 R visitGreaterEqual(HGreaterEqual node); 26 R visitGreaterEqual(HGreaterEqual node);
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 250
250 visitAdd(HAdd node) => visitBinaryArithmetic(node); 251 visitAdd(HAdd node) => visitBinaryArithmetic(node);
251 visitBitAnd(HBitAnd node) => visitBinaryBitOp(node); 252 visitBitAnd(HBitAnd node) => visitBinaryBitOp(node);
252 visitBitNot(HBitNot node) => visitInvokeUnary(node); 253 visitBitNot(HBitNot node) => visitInvokeUnary(node);
253 visitBitOr(HBitOr node) => visitBinaryBitOp(node); 254 visitBitOr(HBitOr node) => visitBinaryBitOp(node);
254 visitBitXor(HBitXor node) => visitBinaryBitOp(node); 255 visitBitXor(HBitXor node) => visitBinaryBitOp(node);
255 visitBailoutTarget(HBailoutTarget node) => visitInstruction(node); 256 visitBailoutTarget(HBailoutTarget node) => visitInstruction(node);
256 visitBoolify(HBoolify node) => visitInstruction(node); 257 visitBoolify(HBoolify node) => visitInstruction(node);
257 visitBoundsCheck(HBoundsCheck node) => visitCheck(node); 258 visitBoundsCheck(HBoundsCheck node) => visitCheck(node);
258 visitBreak(HBreak node) => visitGoto(node); 259 visitBreak(HBreak node) => visitGoto(node);
260 visitContinue(HContinue node) => visitGoto(node);
259 visitCheck(HCheck node) => visitInstruction(node); 261 visitCheck(HCheck node) => visitInstruction(node);
260 visitConstant(HConstant node) => visitInstruction(node); 262 visitConstant(HConstant node) => visitInstruction(node);
261 visitDivide(HDivide node) => visitBinaryArithmetic(node); 263 visitDivide(HDivide node) => visitBinaryArithmetic(node);
262 visitEquals(HEquals node) => visitRelational(node); 264 visitEquals(HEquals node) => visitRelational(node);
263 visitExit(HExit node) => visitControlFlow(node); 265 visitExit(HExit node) => visitControlFlow(node);
264 visitFieldGet(HFieldGet node) => visitInstruction(node); 266 visitFieldGet(HFieldGet node) => visitInstruction(node);
265 visitFieldSet(HFieldSet node) => visitInstruction(node); 267 visitFieldSet(HFieldSet node) => visitInstruction(node);
266 visitForeign(HForeign node) => visitInstruction(node); 268 visitForeign(HForeign node) => visitInstruction(node);
267 visitForeignNew(HForeignNew node) => visitForeign(node); 269 visitForeignNew(HForeignNew node) => visitForeign(node);
268 visitGoto(HGoto node) => visitControlFlow(node); 270 visitGoto(HGoto node) => visitControlFlow(node);
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 } 648 }
647 649
648 bool isValid() { 650 bool isValid() {
649 assert(isClosed()); 651 assert(isClosed());
650 HValidator validator = new HValidator(); 652 HValidator validator = new HValidator();
651 validator.visitBasicBlock(this); 653 validator.visitBasicBlock(this);
652 return validator.isValid; 654 return validator.isValid;
653 } 655 }
654 } 656 }
655 657
656 class HBlockInformation { 658 class HLabeledBlockInformation {
657 // Just a marker class.
658 }
659
660 class HLabeledBlockInformation extends HBlockInformation {
661 final SubGraph body; 659 final SubGraph body;
662 final HBasicBlock joinBlock; 660 final HBasicBlock joinBlock;
663 final List<LabelElement> labels; 661 final List<LabelElement> labels;
664 final TargetElement target; 662 final TargetElement target;
663 final bool isContinue;
665 664
666 HLabeledBlockInformation(this.body, this.joinBlock, 665 HLabeledBlockInformation(this.body, this.joinBlock,
667 List<LabelElement> labels) : 666 List<LabelElement> labels,
667 [this.isContinue = false]) :
668 this.labels = labels, this.target = labels[0].target; 668 this.labels = labels, this.target = labels[0].target;
669 669
670 // For creating block information when there are no explicit labels. 670 HLabeledBlockInformation.implicit(this.body,
671 HLabeledBlockInformation.implicit(this.body, this.joinBlock, this.target) : 671 this.joinBlock,
672 this.labels = const<LabelElement>[]; 672 this.target,
673 [this.isContinue = false])
674 : this.labels = const<LabelElement>[];
673 } 675 }
674 676
675 class HLoopInformation extends HBlockInformation { 677 class HLoopInformation {
676 final HBasicBlock header; 678 final HBasicBlock header;
677 final List<HBasicBlock> blocks; 679 final List<HBasicBlock> blocks;
678 final List<HBasicBlock> backEdges; 680 final List<HBasicBlock> backEdges;
679 final List<LabelElement> labels; 681 final List<LabelElement> labels;
680 682
681 HLoopInformation(this.header, this.labels) 683 HLoopInformation(this.header, this.labels)
682 : blocks = new List<HBasicBlock>(), 684 : blocks = new List<HBasicBlock>(),
683 backEdges = new List<HBasicBlock>(); 685 backEdges = new List<HBasicBlock>();
684 686
685 void addBackEdge(HBasicBlock predecessor) { 687 void addBackEdge(HBasicBlock predecessor) {
(...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after
1604 accept(HVisitor visitor) => visitor.visitExit(this); 1606 accept(HVisitor visitor) => visitor.visitExit(this);
1605 } 1607 }
1606 1608
1607 class HGoto extends HControlFlow { 1609 class HGoto extends HControlFlow {
1608 HGoto() : super(const <HInstruction>[]); 1610 HGoto() : super(const <HInstruction>[]);
1609 toString() => 'goto'; 1611 toString() => 'goto';
1610 accept(HVisitor visitor) => visitor.visitGoto(this); 1612 accept(HVisitor visitor) => visitor.visitGoto(this);
1611 } 1613 }
1612 1614
1613 class HBreak extends HGoto { 1615 class HBreak extends HGoto {
1614 // Target is either a LabelElement or a TargetElement.
1615 final TargetElement target; 1616 final TargetElement target;
1616 final LabelElement label; 1617 final LabelElement label;
1617 HBreak(this.target) : label = null; 1618 HBreak(this.target) : label = null;
1618 HBreak.toLabel(LabelElement label) : label = label, target = label.target; 1619 HBreak.toLabel(LabelElement label) : label = label, target = label.target;
1619 toString() => (target is LabelElement) ? 'break ${label.labelName}' : 'break'; 1620 toString() => (label !== null) ? 'break ${label.labelName}' : 'break';
1620 accept(HVisitor visitor) => visitor.visitBreak(this); 1621 accept(HVisitor visitor) => visitor.visitBreak(this);
1621 } 1622 }
1622 1623
1624 class HContinue extends HGoto {
1625 final TargetElement target;
1626 final LabelElement label;
1627 HContinue(this.target) : label = null;
1628 HContinue.toLabel(LabelElement label) : label = label, target = label.target;
1629 toString() => (label !== null) ? 'continue ${label.labelName}' : 'continue';
1630 accept(HVisitor visitor) => visitor.visitContinue(this);
1631 }
1632
1623 class HTry extends HControlFlow { 1633 class HTry extends HControlFlow {
1624 HParameterValue exception; 1634 HParameterValue exception;
1625 HBasicBlock finallyBlock; 1635 HBasicBlock finallyBlock;
1626 HTry() : super(const <HInstruction>[]); 1636 HTry() : super(const <HInstruction>[]);
1627 toString() => 'try'; 1637 toString() => 'try';
1628 accept(HVisitor visitor) => visitor.visitTry(this); 1638 accept(HVisitor visitor) => visitor.visitTry(this);
1629 HBasicBlock get joinBlock() => this.block.successors.last(); 1639 HBasicBlock get joinBlock() => this.block.successors.last();
1630 } 1640 }
1631 1641
1632 class HIf extends HConditionalBranch { 1642 class HIf extends HConditionalBranch {
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
2133 class HIfBlockInformation { 2143 class HIfBlockInformation {
2134 final HIf branch; 2144 final HIf branch;
2135 final SubGraph thenGraph; 2145 final SubGraph thenGraph;
2136 final SubGraph elseGraph; 2146 final SubGraph elseGraph;
2137 final HBasicBlock joinBlock; 2147 final HBasicBlock joinBlock;
2138 HIfBlockInformation(this.branch, 2148 HIfBlockInformation(this.branch,
2139 this.thenGraph, 2149 this.thenGraph,
2140 this.elseGraph, 2150 this.elseGraph,
2141 this.joinBlock); 2151 this.joinBlock);
2142 } 2152 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698