Chromium Code Reviews| 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 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1068 HConditionalBranch(inputs) : super(inputs); | 1071 HConditionalBranch(inputs) : super(inputs); |
| 1069 HInstruction get condition() => inputs[0]; | 1072 HInstruction get condition() => inputs[0]; |
| 1070 HBasicBlock get trueBranch() => block.successors[0]; | 1073 HBasicBlock get trueBranch() => block.successors[0]; |
| 1071 HBasicBlock get falseBranch() => block.successors[1]; | 1074 HBasicBlock get falseBranch() => block.successors[1]; |
| 1072 abstract toString(); | 1075 abstract toString(); |
| 1073 } | 1076 } |
| 1074 | 1077 |
| 1075 class HControlFlow extends HInstruction { | 1078 class HControlFlow extends HInstruction { |
| 1076 HControlFlow(inputs) : super(inputs); | 1079 HControlFlow(inputs) : super(inputs); |
| 1077 abstract toString(); | 1080 abstract toString(); |
| 1081 void prepareGvn() { | |
| 1082 clearAllSideEffects(); | |
|
ngeoffray
2012/06/15 19:45:33
Do you need to do this? I think by default insturc
Mads Ager (google)
2012/06/18 07:45:23
You are right, we don't need to clear side effects
| |
| 1083 } | |
| 1078 bool isControlFlow() => true; | 1084 bool isControlFlow() => true; |
| 1079 bool isStatement() => true; | 1085 bool isStatement() => true; |
| 1080 } | 1086 } |
| 1081 | 1087 |
| 1082 class HInvoke extends HInstruction { | 1088 class HInvoke extends HInstruction { |
| 1083 /** | 1089 /** |
| 1084 * The first argument must be the target: either an [HStatic] node, or | 1090 * The first argument must be the target: either an [HStatic] node, or |
| 1085 * the receiver of a method-call. The remaining inputs are the arguments | 1091 * the receiver of a method-call. The remaining inputs are the arguments |
| 1086 * to the invocation. | 1092 * to the invocation. |
| 1087 */ | 1093 */ |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1253 HFieldGet(Element element, HInstruction receiver, | 1259 HFieldGet(Element element, HInstruction receiver, |
| 1254 [this.isFinalOrConst = false]) | 1260 [this.isFinalOrConst = false]) |
| 1255 : super(element, <HInstruction>[receiver]); | 1261 : super(element, <HInstruction>[receiver]); |
| 1256 HFieldGet.fromActivation(receiver) : this(null, receiver); | 1262 HFieldGet.fromActivation(receiver) : this(null, receiver); |
| 1257 | 1263 |
| 1258 HInstruction get receiver() => inputs.length == 1 ? inputs[0] : null; | 1264 HInstruction get receiver() => inputs.length == 1 ? inputs[0] : null; |
| 1259 | 1265 |
| 1260 accept(HVisitor visitor) => visitor.visitFieldGet(this); | 1266 accept(HVisitor visitor) => visitor.visitFieldGet(this); |
| 1261 | 1267 |
| 1262 void prepareGvn() { | 1268 void prepareGvn() { |
| 1263 if (isFinalOrConst) { | 1269 clearAllSideEffects(); |
|
ngeoffray
2012/06/15 19:45:33
ditto
Mads Ager (google)
2012/06/18 07:45:23
Done.
| |
| 1264 assert(!hasSideEffects()); | 1270 setUseGvn(); |
| 1265 setUseGvn(); | 1271 if (!isFinalOrConst) setDependsOnSomething(); |
| 1266 } else { | |
| 1267 clearAllSideEffects(); | |
| 1268 } | |
| 1269 } | 1272 } |
| 1270 | 1273 |
| 1271 int typeCode() => 27; | 1274 int typeCode() => 27; |
| 1272 bool typeEquals(other) => other is HFieldGet; | 1275 bool typeEquals(other) => other is HFieldGet; |
| 1273 bool dataEquals(HFieldGet other) => element == other.element; | 1276 bool dataEquals(HFieldGet other) => element == other.element; |
| 1274 } | 1277 } |
| 1275 | 1278 |
| 1276 class HFieldSet extends HFieldAccess { | 1279 class HFieldSet extends HFieldAccess { |
| 1277 HFieldSet(Element element, HInstruction receiver, HInstruction value) | 1280 HFieldSet(Element element, HInstruction receiver, HInstruction value) |
| 1278 : super(element, <HInstruction>[receiver, value]); | 1281 : super(element, <HInstruction>[receiver, value]); |
| (...skipping 1310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2589 HBasicBlock get start() => expression.start; | 2592 HBasicBlock get start() => expression.start; |
| 2590 HBasicBlock get end() { | 2593 HBasicBlock get end() { |
| 2591 // We don't create a switch block if there are no cases. | 2594 // We don't create a switch block if there are no cases. |
| 2592 assert(!statements.isEmpty()); | 2595 assert(!statements.isEmpty()); |
| 2593 return statements.last().end; | 2596 return statements.last().end; |
| 2594 } | 2597 } |
| 2595 | 2598 |
| 2596 bool accept(HStatementInformationVisitor visitor) => | 2599 bool accept(HStatementInformationVisitor visitor) => |
| 2597 visitor.visitSwitchInfo(this); | 2600 visitor.visitSwitchInfo(this); |
| 2598 } | 2601 } |
| OLD | NEW |