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