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

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

Issue 8513004: Throw and a small fix to If. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 9 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 | Annotate | Revision Log
« no previous file with comments | « frog/leg/ssa/codegen.dart ('k') | frog/leg/ssa/tracer.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 visitBasicBlock(HBasicBlock node); 7 R visitBasicBlock(HBasicBlock node);
8 R visitDivide(HDivide node); 8 R visitDivide(HDivide node);
9 R visitExit(HExit node); 9 R visitExit(HExit node);
10 R visitGoto(HGoto node); 10 R visitGoto(HGoto node);
11 R visitIf(HIf node); 11 R visitIf(HIf node);
12 R visitInvoke(HInvoke node); 12 R visitInvoke(HInvoke node);
13 R visitInvokeForeign(HInvokeForeign node); 13 R visitInvokeForeign(HInvokeForeign node);
14 R visitLiteral(HLiteral node); 14 R visitLiteral(HLiteral node);
15 R visitParameter(HParameter node); 15 R visitParameter(HParameter node);
16 R visitPhi(HPhi node); 16 R visitPhi(HPhi node);
17 R visitSubtract(HSubtract node); 17 R visitSubtract(HSubtract node);
18 R visitMultiply(HMultiply node); 18 R visitMultiply(HMultiply node);
19 R visitReturn(HReturn node); 19 R visitReturn(HReturn node);
20 R visitThrow(HThrow node);
20 R visitTruncatingDivide(HTruncatingDivide node); 21 R visitTruncatingDivide(HTruncatingDivide node);
21 } 22 }
22 23
23 class HGraphVisitor { 24 class HGraphVisitor {
24 visitDominatorTree(HGraph graph) { 25 visitDominatorTree(HGraph graph) {
25 void visitBasicBlockAndSuccessors(HBasicBlock block) { 26 void visitBasicBlockAndSuccessors(HBasicBlock block) {
26 visitBasicBlock(block); 27 visitBasicBlock(block);
27 List dominated = block.dominatedBlocks; 28 List dominated = block.dominatedBlocks;
28 for (int i = 0; i < dominated.length; i++) { 29 for (int i = 0; i < dominated.length; i++) {
29 visitBasicBlockAndSuccessors(dominated[i]); 30 visitBasicBlockAndSuccessors(dominated[i]);
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 HInstruction instruction = node.first; 138 HInstruction instruction = node.first;
138 while (instruction !== null) { 139 while (instruction !== null) {
139 instruction.accept(this); 140 instruction.accept(this);
140 instruction = instruction.next; 141 instruction = instruction.next;
141 } 142 }
142 } 143 }
143 144
144 visitInstruction(HInstruction) {} 145 visitInstruction(HInstruction) {}
145 146
146 visitArithmetic(HArithmetic node) => visitInvoke(node); 147 visitArithmetic(HArithmetic node) => visitInvoke(node);
148 visitControlFlow(HControlFlow node) => visitInstruction(node);
147 149
148 visitAdd(HAdd node) => visitArithmetic(node); 150 visitAdd(HAdd node) => visitArithmetic(node);
149 visitDivide(HDivide node) => visitArithmetic(node); 151 visitDivide(HDivide node) => visitArithmetic(node);
150 visitExit(HExit node) => visitInstruction(node); 152 visitExit(HExit node) => visitControlFlow(node);
151 visitGoto(HGoto node) => visitInstruction(node); 153 visitGoto(HGoto node) => visitControlFlow(node);
152 visitIf(HIf node) => visitInstruction(node); 154 visitIf(HIf node) => visitControlFlow(node);
153 visitInvoke(HInvoke node) => visitInstruction(node); 155 visitInvoke(HInvoke node) => visitInstruction(node);
154 visitInvokeForeign(HInvokeForeign node) => visitInvoke(node); 156 visitInvokeForeign(HInvokeForeign node) => visitInvoke(node);
155 visitLiteral(HLiteral node) => visitInstruction(node); 157 visitLiteral(HLiteral node) => visitInstruction(node);
156 visitPhi(HPhi node) => visitInstruction(node); 158 visitPhi(HPhi node) => visitInstruction(node);
157 visitMultiply(HMultiply node) => visitArithmetic(node); 159 visitMultiply(HMultiply node) => visitArithmetic(node);
158 visitParameter(HParameter node) => visitInstruction(node); 160 visitParameter(HParameter node) => visitInstruction(node);
159 visitReturn(HReturn node) => visitInstruction(node); 161 visitReturn(HReturn node) => visitControlFlow(node);
160 visitSubtract(HSubtract node) => visitArithmetic(node); 162 visitSubtract(HSubtract node) => visitArithmetic(node);
163 visitThrow(HThrow node) => visitControlFlow(node);
161 visitTruncatingDivide(HTruncatingDivide node) => visitArithmetic(node); 164 visitTruncatingDivide(HTruncatingDivide node) => visitArithmetic(node);
162 } 165 }
163 166
164 class HBasicBlock { 167 class HBasicBlock {
165 // [id] must be such that any successor's id is greater than this [id]. The 168 // [id] must be such that any successor's id is greater than this [id]. The
166 // exception are back-edges. 169 // exception are back-edges.
167 int id; 170 int id;
168 HInstruction first = null; 171 HInstruction first = null;
169 HInstruction last = null; 172 HInstruction last = null;
170 final List<HBasicBlock> predecessors; 173 final List<HBasicBlock> predecessors;
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 bool isLiteralNumber() => false; 467 bool isLiteralNumber() => false;
465 bool isLiteralString() => false; 468 bool isLiteralString() => false;
466 469
467 bool isValid() { 470 bool isValid() {
468 HValidator validator = new HValidator(); 471 HValidator validator = new HValidator();
469 validator.visitInstruction(this); 472 validator.visitInstruction(this);
470 return validator.isValid; 473 return validator.isValid;
471 } 474 }
472 } 475 }
473 476
477 class HControlFlow extends HInstruction {
478 HControlFlow(inputs) : super(inputs);
479 abstract toString();
480 }
481
474 class HInvoke extends HInstruction { 482 class HInvoke extends HInstruction {
475 final SourceString selector; 483 final SourceString selector;
476 HInvoke(this.selector, inputs) : super(inputs); 484 HInvoke(this.selector, inputs) : super(inputs);
477 toString() => 'invoke: $selector'; 485 toString() => 'invoke: $selector';
478 accept(HVisitor visitor) => visitor.visitInvoke(this); 486 accept(HVisitor visitor) => visitor.visitInvoke(this);
479 } 487 }
480 488
481 class HInvokeForeign extends HInvoke { 489 class HInvokeForeign extends HInvoke {
482 HInvokeForeign(code, inputs) : super(code, inputs); 490 HInvokeForeign(code, inputs) : super(code, inputs);
483 accept(HVisitor visitor) => visitor.visitInvokeForeign(this); 491 accept(HVisitor visitor) => visitor.visitInvokeForeign(this);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 } 544 }
537 545
538 class HTruncatingDivide extends HArithmetic { 546 class HTruncatingDivide extends HArithmetic {
539 HTruncatingDivide(inputs) : super(const SourceString('~/'), inputs); 547 HTruncatingDivide(inputs) : super(const SourceString('~/'), inputs);
540 accept(HVisitor visitor) => visitor.visitTruncatingDivide(this); 548 accept(HVisitor visitor) => visitor.visitTruncatingDivide(this);
541 num evaluate(num a, num b) => a ~/ b; 549 num evaluate(num a, num b) => a ~/ b;
542 bool typeEquals(other) => other is HTruncatingDivide; 550 bool typeEquals(other) => other is HTruncatingDivide;
543 bool dataEquals(HInstruction other) => true; 551 bool dataEquals(HInstruction other) => true;
544 } 552 }
545 553
546 class HExit extends HInstruction { 554 class HExit extends HControlFlow {
547 HExit() : super(const <HInstruction>[]); 555 HExit() : super(const <HInstruction>[]);
548 toString() => 'exit'; 556 toString() => 'exit';
549 accept(HVisitor visitor) => visitor.visitExit(this); 557 accept(HVisitor visitor) => visitor.visitExit(this);
550 } 558 }
551 559
552 class HGoto extends HInstruction { 560 class HGoto extends HControlFlow {
553 HGoto() : super(const <HInstruction>[]); 561 HGoto() : super(const <HInstruction>[]);
554 toString() => 'goto'; 562 toString() => 'goto';
555 accept(HVisitor visitor) => visitor.visitGoto(this); 563 accept(HVisitor visitor) => visitor.visitGoto(this);
556 } 564 }
557 565
558 class HIf extends HInstruction { 566 class HIf extends HControlFlow {
559 bool hasElse; 567 bool hasElse;
560 HIf(HInstruction condition, this.hasElse) : super(<HInstruction>[condition]); 568 HIf(HInstruction condition, this.hasElse) : super(<HInstruction>[condition]);
561 toString() => 'if'; 569 toString() => 'if';
562 accept(HVisitor visitor) => visitor.visitIf(this); 570 accept(HVisitor visitor) => visitor.visitIf(this);
563 } 571 }
564 572
565 class HLiteral extends HInstruction { 573 class HLiteral extends HInstruction {
566 final value; 574 final value;
567 HLiteral(this.value) : super([]); 575 HLiteral(this.value) : super([]);
568 void prepareGvn() { 576 void prepareGvn() {
(...skipping 18 matching lines...) Expand all
587 accept(HVisitor visitor) => visitor.visitParameter(this); 595 accept(HVisitor visitor) => visitor.visitParameter(this);
588 } 596 }
589 597
590 class HPhi extends HInstruction { 598 class HPhi extends HInstruction {
591 HPhi(HInstruction input1, HInstruction input2) 599 HPhi(HInstruction input1, HInstruction input2)
592 : super(<HInstruction>[input1, input2]); 600 : super(<HInstruction>[input1, input2]);
593 toString() => 'phi'; 601 toString() => 'phi';
594 accept(HVisitor visitor) => visitor.visitPhi(this); 602 accept(HVisitor visitor) => visitor.visitPhi(this);
595 } 603 }
596 604
597 class HReturn extends HInstruction { 605 class HReturn extends HControlFlow {
598 HReturn(value) : super([value]); 606 HReturn(value) : super([value]);
599 toString() => 'return'; 607 toString() => 'return';
600 accept(HVisitor visitor) => visitor.visitReturn(this); 608 accept(HVisitor visitor) => visitor.visitReturn(this);
601 } 609 }
610
611 class HThrow extends HControlFlow {
612 HThrow(value) : super([value]);
613 toString() => 'throw';
614 accept(HVisitor visitor) => visitor.visitThrow(this);
615 }
OLDNEW
« no previous file with comments | « frog/leg/ssa/codegen.dart ('k') | frog/leg/ssa/tracer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698