| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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); |
| 11 R visitBoolify(HBoolify node); | 11 R visitBoolify(HBoolify node); |
| (...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 | 733 |
| 734 static int computeDependsOnFlags(int flags) => flags << FLAG_CHANGES_COUNT; | 734 static int computeDependsOnFlags(int flags) => flags << FLAG_CHANGES_COUNT; |
| 735 | 735 |
| 736 int getChangesFlags() => flags & ((1 << FLAG_CHANGES_COUNT) - 1); | 736 int getChangesFlags() => flags & ((1 << FLAG_CHANGES_COUNT) - 1); |
| 737 bool hasSideEffects() => getChangesFlags() != 0; | 737 bool hasSideEffects() => getChangesFlags() != 0; |
| 738 void prepareGvn() { setAllSideEffects(); } | 738 void prepareGvn() { setAllSideEffects(); } |
| 739 | 739 |
| 740 void setAllSideEffects() { flags |= ((1 << FLAG_CHANGES_COUNT) - 1); } | 740 void setAllSideEffects() { flags |= ((1 << FLAG_CHANGES_COUNT) - 1); } |
| 741 void clearAllSideEffects() { flags &= ~((1 << FLAG_CHANGES_COUNT) - 1); } | 741 void clearAllSideEffects() { flags &= ~((1 << FLAG_CHANGES_COUNT) - 1); } |
| 742 | 742 |
| 743 bool dependsOnSomething() => getFlag(FLAG_DEPENDS_ON_SOMETHING); |
| 744 void setDependsOnSomething() { setFlag(FLAG_DEPENDS_ON_SOMETHING); } |
| 745 |
| 743 bool useGvn() => getFlag(FLAG_USE_GVN); | 746 bool useGvn() => getFlag(FLAG_USE_GVN); |
| 744 void setUseGvn() { setFlag(FLAG_USE_GVN); } | 747 void setUseGvn() { setFlag(FLAG_USE_GVN); } |
| 745 // Does this node potentially affect control flow. | 748 // Does this node potentially affect control flow. |
| 746 bool isControlFlow() => false; | 749 bool isControlFlow() => false; |
| 747 | 750 |
| 748 // All isFunctions work on the propagated types. | 751 // All isFunctions work on the propagated types. |
| 749 bool isArray() => propagatedType.isArray(); | 752 bool isArray() => propagatedType.isArray(); |
| 750 bool isReadableArray() => propagatedType.isReadableArray(); | 753 bool isReadableArray() => propagatedType.isReadableArray(); |
| 751 bool isMutableArray() => propagatedType.isMutableArray(); | 754 bool isMutableArray() => propagatedType.isMutableArray(); |
| 752 bool isExtendableArray() => propagatedType.isExtendableArray(); | 755 bool isExtendableArray() => propagatedType.isExtendableArray(); |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1069 HConditionalBranch(inputs) : super(inputs); | 1072 HConditionalBranch(inputs) : super(inputs); |
| 1070 HInstruction get condition() => inputs[0]; | 1073 HInstruction get condition() => inputs[0]; |
| 1071 HBasicBlock get trueBranch() => block.successors[0]; | 1074 HBasicBlock get trueBranch() => block.successors[0]; |
| 1072 HBasicBlock get falseBranch() => block.successors[1]; | 1075 HBasicBlock get falseBranch() => block.successors[1]; |
| 1073 abstract toString(); | 1076 abstract toString(); |
| 1074 } | 1077 } |
| 1075 | 1078 |
| 1076 class HControlFlow extends HInstruction { | 1079 class HControlFlow extends HInstruction { |
| 1077 HControlFlow(inputs) : super(inputs); | 1080 HControlFlow(inputs) : super(inputs); |
| 1078 abstract toString(); | 1081 abstract toString(); |
| 1082 void prepareGvn() { |
| 1083 // Control flow does not have side-effects. |
| 1084 } |
| 1079 bool isControlFlow() => true; | 1085 bool isControlFlow() => true; |
| 1080 bool isStatement() => true; | 1086 bool isStatement() => true; |
| 1081 } | 1087 } |
| 1082 | 1088 |
| 1083 class HInvoke extends HInstruction { | 1089 class HInvoke extends HInstruction { |
| 1084 /** | 1090 /** |
| 1085 * The first argument must be the target: either an [HStatic] node, or | 1091 * The first argument must be the target: either an [HStatic] node, or |
| 1086 * the receiver of a method-call. The remaining inputs are the arguments | 1092 * the receiver of a method-call. The remaining inputs are the arguments |
| 1087 * to the invocation. | 1093 * to the invocation. |
| 1088 */ | 1094 */ |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1254 HFieldGet(Element element, HInstruction receiver, | 1260 HFieldGet(Element element, HInstruction receiver, |
| 1255 [this.isFinalOrConst = false]) | 1261 [this.isFinalOrConst = false]) |
| 1256 : super(element, <HInstruction>[receiver]); | 1262 : super(element, <HInstruction>[receiver]); |
| 1257 HFieldGet.fromActivation(receiver) : this(null, receiver); | 1263 HFieldGet.fromActivation(receiver) : this(null, receiver); |
| 1258 | 1264 |
| 1259 HInstruction get receiver() => inputs.length == 1 ? inputs[0] : null; | 1265 HInstruction get receiver() => inputs.length == 1 ? inputs[0] : null; |
| 1260 | 1266 |
| 1261 accept(HVisitor visitor) => visitor.visitFieldGet(this); | 1267 accept(HVisitor visitor) => visitor.visitFieldGet(this); |
| 1262 | 1268 |
| 1263 void prepareGvn() { | 1269 void prepareGvn() { |
| 1264 if (isFinalOrConst) { | 1270 setUseGvn(); |
| 1265 assert(!hasSideEffects()); | 1271 if (!isFinalOrConst) setDependsOnSomething(); |
| 1266 setUseGvn(); | |
| 1267 } else { | |
| 1268 clearAllSideEffects(); | |
| 1269 } | |
| 1270 } | 1272 } |
| 1271 | 1273 |
| 1272 int typeCode() => 27; | 1274 int typeCode() => 27; |
| 1273 bool typeEquals(other) => other is HFieldGet; | 1275 bool typeEquals(other) => other is HFieldGet; |
| 1274 bool dataEquals(HFieldGet other) => element == other.element; | 1276 bool dataEquals(HFieldGet other) => element == other.element; |
| 1275 } | 1277 } |
| 1276 | 1278 |
| 1277 class HFieldSet extends HFieldAccess { | 1279 class HFieldSet extends HFieldAccess { |
| 1278 HFieldSet(Element element, HInstruction receiver, HInstruction value) | 1280 HFieldSet(Element element, HInstruction receiver, HInstruction value) |
| 1279 : super(element, <HInstruction>[receiver, value]); | 1281 : super(element, <HInstruction>[receiver, value]); |
| (...skipping 1313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2593 HBasicBlock get start() => expression.start; | 2595 HBasicBlock get start() => expression.start; |
| 2594 HBasicBlock get end() { | 2596 HBasicBlock get end() { |
| 2595 // We don't create a switch block if there are no cases. | 2597 // We don't create a switch block if there are no cases. |
| 2596 assert(!statements.isEmpty()); | 2598 assert(!statements.isEmpty()); |
| 2597 return statements.last().end; | 2599 return statements.last().end; |
| 2598 } | 2600 } |
| 2599 | 2601 |
| 2600 bool accept(HStatementInformationVisitor visitor) => | 2602 bool accept(HStatementInformationVisitor visitor) => |
| 2601 visitor.visitSwitchInfo(this); | 2603 visitor.visitSwitchInfo(this); |
| 2602 } | 2604 } |
| OLD | NEW |