OLD | NEW |
1 // Copyright (c) 2012, 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 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 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1077 bool dominates(HInstruction other) { | 1077 bool dominates(HInstruction other) { |
1078 if (block != other.block) return block.dominates(other.block); | 1078 if (block != other.block) return block.dominates(other.block); |
1079 | 1079 |
1080 HInstruction current = this; | 1080 HInstruction current = this; |
1081 while (current !== null) { | 1081 while (current !== null) { |
1082 if (current === other) return true; | 1082 if (current === other) return true; |
1083 current = current.next; | 1083 current = current.next; |
1084 } | 1084 } |
1085 return false; | 1085 return false; |
1086 } | 1086 } |
| 1087 |
| 1088 |
| 1089 HInstruction convertType(Compiler compiler, |
| 1090 Element sourceElement, |
| 1091 int kind) { |
| 1092 DartType type = sourceElement.computeType(compiler); |
| 1093 if (type === null) return this; |
| 1094 if (type.element === compiler.dynamicClass) return this; |
| 1095 if (type.element === compiler.objectClass) return this; |
| 1096 |
| 1097 // If the original can't be null, type conversion also can't produce null. |
| 1098 bool canBeNull = this.guaranteedType.canBeNull(); |
| 1099 HType convertedType = |
| 1100 new HType.fromBoundedType(type, compiler, canBeNull); |
| 1101 |
| 1102 // No need to convert if we know the instruction has |
| 1103 // [convertedType] as a bound. |
| 1104 if (this.guaranteedType == convertedType) { |
| 1105 return this; |
| 1106 } |
| 1107 |
| 1108 return new HTypeConversion(convertedType, this, kind); |
| 1109 } |
1087 } | 1110 } |
1088 | 1111 |
1089 class HBoolify extends HInstruction { | 1112 class HBoolify extends HInstruction { |
1090 HBoolify(HInstruction value) : super(<HInstruction>[value]); | 1113 HBoolify(HInstruction value) : super(<HInstruction>[value]); |
1091 void prepareGvn(HTypeMap types) { | 1114 void prepareGvn(HTypeMap types) { |
1092 assert(!hasSideEffects(types)); | 1115 assert(!hasSideEffects(types)); |
1093 setUseGvn(); | 1116 setUseGvn(); |
1094 } | 1117 } |
1095 | 1118 |
1096 HType get guaranteedType => HType.BOOLEAN; | 1119 HType get guaranteedType => HType.BOOLEAN; |
(...skipping 1746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2843 HBasicBlock get start => expression.start; | 2866 HBasicBlock get start => expression.start; |
2844 HBasicBlock get end { | 2867 HBasicBlock get end { |
2845 // We don't create a switch block if there are no cases. | 2868 // We don't create a switch block if there are no cases. |
2846 assert(!statements.isEmpty()); | 2869 assert(!statements.isEmpty()); |
2847 return statements.last().end; | 2870 return statements.last().end; |
2848 } | 2871 } |
2849 | 2872 |
2850 bool accept(HStatementInformationVisitor visitor) => | 2873 bool accept(HStatementInformationVisitor visitor) => |
2851 visitor.visitSwitchInfo(this); | 2874 visitor.visitSwitchInfo(this); |
2852 } | 2875 } |
OLD | NEW |