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

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

Issue 9351020: Implement try/catch without finally, and without type checks. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' 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
« no previous file with comments | « frog/leg/ssa/codegen.dart ('k') | frog/leg/ssa/optimize.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 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);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 R visitReturn(HReturn node); 51 R visitReturn(HReturn node);
52 R visitShiftLeft(HShiftLeft node); 52 R visitShiftLeft(HShiftLeft node);
53 R visitShiftRight(HShiftRight node); 53 R visitShiftRight(HShiftRight node);
54 R visitStatic(HStatic node); 54 R visitStatic(HStatic node);
55 R visitStaticStore(HStaticStore node); 55 R visitStaticStore(HStaticStore node);
56 R visitStore(HStore node); 56 R visitStore(HStore node);
57 R visitSubtract(HSubtract node); 57 R visitSubtract(HSubtract node);
58 R visitThis(HThis node); 58 R visitThis(HThis node);
59 R visitThrow(HThrow node); 59 R visitThrow(HThrow node);
60 R visitTruncatingDivide(HTruncatingDivide node); 60 R visitTruncatingDivide(HTruncatingDivide node);
61 R visitTry(HTry node);
61 R visitTypeGuard(HTypeGuard node); 62 R visitTypeGuard(HTypeGuard node);
62 } 63 }
63 64
64 class HGraphVisitor { 65 class HGraphVisitor {
65 visitDominatorTree(HGraph graph) { 66 visitDominatorTree(HGraph graph) {
66 void visitBasicBlockAndSuccessors(HBasicBlock block) { 67 void visitBasicBlockAndSuccessors(HBasicBlock block) {
67 visitBasicBlock(block); 68 visitBasicBlock(block);
68 List dominated = block.dominatedBlocks; 69 List dominated = block.dominatedBlocks;
69 for (int i = 0; i < dominated.length; i++) { 70 for (int i = 0; i < dominated.length; i++) {
70 visitBasicBlockAndSuccessors(dominated[i]); 71 visitBasicBlockAndSuccessors(dominated[i]);
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 visitParameterValue(HParameterValue node) => visitInstruction(node); 251 visitParameterValue(HParameterValue node) => visitInstruction(node);
251 visitReturn(HReturn node) => visitControlFlow(node); 252 visitReturn(HReturn node) => visitControlFlow(node);
252 visitShiftRight(HShiftRight node) => visitBinaryBitOp(node); 253 visitShiftRight(HShiftRight node) => visitBinaryBitOp(node);
253 visitShiftLeft(HShiftLeft node) => visitBinaryBitOp(node); 254 visitShiftLeft(HShiftLeft node) => visitBinaryBitOp(node);
254 visitSubtract(HSubtract node) => visitBinaryArithmetic(node); 255 visitSubtract(HSubtract node) => visitBinaryArithmetic(node);
255 visitStatic(HStatic node) => visitInstruction(node); 256 visitStatic(HStatic node) => visitInstruction(node);
256 visitStaticStore(HStaticStore node) => visitInstruction(node); 257 visitStaticStore(HStaticStore node) => visitInstruction(node);
257 visitStore(HStore node) => visitInstruction(node); 258 visitStore(HStore node) => visitInstruction(node);
258 visitThis(HThis node) => visitParameterValue(node); 259 visitThis(HThis node) => visitParameterValue(node);
259 visitThrow(HThrow node) => visitControlFlow(node); 260 visitThrow(HThrow node) => visitControlFlow(node);
261 visitTry(HTry node) => visitControlFlow(node);
260 visitTruncatingDivide(HTruncatingDivide node) => visitBinaryArithmetic(node); 262 visitTruncatingDivide(HTruncatingDivide node) => visitBinaryArithmetic(node);
261 visitTypeGuard(HTypeGuard node) => visitInstruction(node); 263 visitTypeGuard(HTypeGuard node) => visitInstruction(node);
262 visitIs(HIs node) => visitInstruction(node); 264 visitIs(HIs node) => visitInstruction(node);
263 } 265 }
264 266
265 class HInstructionList { 267 class HInstructionList {
266 HInstruction first = null; 268 HInstruction first = null;
267 HInstruction last = null; 269 HInstruction last = null;
268 270
269 bool isEmpty() { 271 bool isEmpty() {
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 } 1133 }
1132 } 1134 }
1133 1135
1134 bool typeEquals(other) => other is HInvokeInterceptor; 1136 bool typeEquals(other) => other is HInvokeInterceptor;
1135 bool dataEquals(HInvokeInterceptor other) { 1137 bool dataEquals(HInvokeInterceptor other) {
1136 return builtinJsName == other.builtinJsName && name == other.name; 1138 return builtinJsName == other.builtinJsName && name == other.name;
1137 } 1139 }
1138 } 1140 }
1139 1141
1140 class HFieldGet extends HInstruction { 1142 class HFieldGet extends HInstruction {
1141 Element element; 1143 final Element element;
1142 HFieldGet(Element this.element, HInstruction receiver) 1144 HFieldGet(Element this.element, HInstruction receiver)
1143 : super(<HInstruction>[receiver]); 1145 : super(<HInstruction>[receiver]);
1144 HFieldGet.fromActivation() : super(<HInstruction>[]); 1146 HFieldGet.fromActivation(Element this.element) : super(<HInstruction>[]);
1145 1147
1146 HInstruction get receiver() => inputs.length == 1 ? inputs[0] : null; 1148 HInstruction get receiver() => inputs.length == 1 ? inputs[0] : null;
1147 accept(HVisitor visitor) => visitor.visitFieldGet(this); 1149 accept(HVisitor visitor) => visitor.visitFieldGet(this);
1148 } 1150 }
1149 1151
1150 class HFieldSet extends HInstruction { 1152 class HFieldSet extends HInstruction {
1151 Element element; 1153 final Element element;
1152 HFieldSet(Element this.element, HInstruction receiver, HInstruction value) 1154 HFieldSet(Element this.element, HInstruction receiver, HInstruction value)
1153 : super(<HInstruction>[receiver, value]); 1155 : super(<HInstruction>[receiver, value]);
1154 HFieldSet.fromActivation(HInstruction value) : super(<HInstruction>[value]); 1156 HFieldSet.fromActivation(Element this.element, HInstruction value)
1157 : super(<HInstruction>[value]);
1155 1158
1156 HInstruction get receiver() => inputs.length == 2 ? inputs[0] : null; 1159 HInstruction get receiver() => inputs.length == 2 ? inputs[0] : null;
1157 HInstruction get value() => inputs.length == 2 ? inputs[1] : inputs[0]; 1160 HInstruction get value() => inputs.length == 2 ? inputs[1] : inputs[0];
1158 accept(HVisitor visitor) => visitor.visitFieldSet(this); 1161 accept(HVisitor visitor) => visitor.visitFieldSet(this);
1159 1162
1160 void prepareGvn() { 1163 void prepareGvn() {
1161 // TODO(ngeoffray): implement more fine grain side effects. 1164 // TODO(ngeoffray): implement more fine grain side effects.
1162 setAllSideEffects(); 1165 setAllSideEffects();
1163 } 1166 }
1164 } 1167 }
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
1624 toString() => 'exit'; 1627 toString() => 'exit';
1625 accept(HVisitor visitor) => visitor.visitExit(this); 1628 accept(HVisitor visitor) => visitor.visitExit(this);
1626 } 1629 }
1627 1630
1628 class HGoto extends HControlFlow { 1631 class HGoto extends HControlFlow {
1629 HGoto() : super(const <HInstruction>[]); 1632 HGoto() : super(const <HInstruction>[]);
1630 toString() => 'goto'; 1633 toString() => 'goto';
1631 accept(HVisitor visitor) => visitor.visitGoto(this); 1634 accept(HVisitor visitor) => visitor.visitGoto(this);
1632 } 1635 }
1633 1636
1637 class HTry extends HControlFlow {
1638 HBasicBlock finallyBlock;
1639 HTry() : super(const <HInstruction>[]);
1640 toString() => 'try';
1641 accept(HVisitor visitor) => visitor.visitTry(this);
1642 }
1643
1634 class HIf extends HConditionalBranch { 1644 class HIf extends HConditionalBranch {
1635 bool hasElse; 1645 bool hasElse;
1636 HIf(HInstruction condition, this.hasElse) : super(<HInstruction>[condition]); 1646 HIf(HInstruction condition, this.hasElse) : super(<HInstruction>[condition]);
1637 toString() => 'if'; 1647 toString() => 'if';
1638 accept(HVisitor visitor) => visitor.visitIf(this); 1648 accept(HVisitor visitor) => visitor.visitIf(this);
1639 1649
1640 HBasicBlock get thenBlock() { 1650 HBasicBlock get thenBlock() {
1641 assert(block.dominatedBlocks[0] === block.successors[0]); 1651 assert(block.dominatedBlocks[0] === block.successors[0]);
1642 return block.successors[0]; 1652 return block.successors[0];
1643 } 1653 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1704 // Literals have the type they have. It can't be changed. 1714 // Literals have the type they have. It can't be changed.
1705 bool updateType() => false; 1715 bool updateType() => false;
1706 1716
1707 bool hasExpectedType() => true; 1717 bool hasExpectedType() => true;
1708 1718
1709 bool isLiteralBoolean() => value is bool; 1719 bool isLiteralBoolean() => value is bool;
1710 bool isLiteralNull() => value === null; 1720 bool isLiteralNull() => value === null;
1711 bool isLiteralNumber() => value is num; 1721 bool isLiteralNumber() => value is num;
1712 bool isLiteralString() => value is DartString; 1722 bool isLiteralString() => value is DartString;
1713 bool typeEquals(other) => other is HLiteral; 1723 bool typeEquals(other) => other is HLiteral;
1714 bool dataEquals(HLiteral other) => value == other.value; 1724 bool dataEquals(HLiteral other) {
1725 if (isLiteralNumber() && other.isLiteralNumber()) {
1726 if (value.isNaN()) return other.value.isNaN();
1727 }
1728 return value == other.value;
1729 }
1715 } 1730 }
1716 1731
1717 class HNot extends HInstruction { 1732 class HNot extends HInstruction {
1718 HNot(HInstruction value) : super(<HInstruction>[value]); 1733 HNot(HInstruction value) : super(<HInstruction>[value]);
1719 void prepareGvn() { 1734 void prepareGvn() {
1720 assert(!hasSideEffects()); 1735 assert(!hasSideEffects());
1721 setUseGvn(); 1736 setUseGvn();
1722 } 1737 }
1723 1738
1724 HType computeType() => HType.BOOLEAN; 1739 HType computeType() => HType.BOOLEAN;
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
2115 2130
2116 HInstruction get expression() => inputs[0]; 2131 HInstruction get expression() => inputs[0];
2117 2132
2118 HType computeType() => HType.BOOLEAN; 2133 HType computeType() => HType.BOOLEAN;
2119 bool hasExpectedType() => true; 2134 bool hasExpectedType() => true;
2120 2135
2121 accept(HVisitor visitor) => visitor.visitIs(this); 2136 accept(HVisitor visitor) => visitor.visitIs(this);
2122 2137
2123 toString() => "$expression is $typeExpression"; 2138 toString() => "$expression is $typeExpression";
2124 } 2139 }
OLDNEW
« no previous file with comments | « frog/leg/ssa/codegen.dart ('k') | frog/leg/ssa/optimize.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698