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 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1075 bool dominates(HInstruction other) { | 1075 bool dominates(HInstruction other) { |
1076 if (block != other.block) return block.dominates(other.block); | 1076 if (block != other.block) return block.dominates(other.block); |
1077 | 1077 |
1078 HInstruction current = this; | 1078 HInstruction current = this; |
1079 while (current !== null) { | 1079 while (current !== null) { |
1080 if (current === other) return true; | 1080 if (current === other) return true; |
1081 current = current.next; | 1081 current = current.next; |
1082 } | 1082 } |
1083 return false; | 1083 return false; |
1084 } | 1084 } |
1085 | |
1086 | |
1087 HInstruction convertType(Compiler compiler, | |
1088 Element sourceElement, | |
1089 int kind) { | |
1090 DartType type = sourceElement.computeType(compiler); | |
1091 if (type === null) return this; | |
1092 if (type.element === compiler.dynamicClass) return this; | |
1093 if (type.element === compiler.objectClass) return this; | |
1094 | |
1095 // If the original can't be null, type conversion also can't produce null. | |
1096 bool canBeNull = this.guaranteedType.canBeNull(); | |
1097 HType convertedType = | |
1098 new HType.fromBoundedType(type, compiler, canBeNull); | |
1099 | |
1100 // No need to convert if we know the instruction has | |
1101 // [convertedType] as a bound. | |
1102 if (this.guaranteedType == convertedType) { | |
1103 return this; | |
1104 } | |
1105 | |
1106 HInstruction instruction = new HTypeConversion(convertedType, this, kind); | |
kasperl
2012/09/06 10:20:39
Maybe just return it here with creating a new loca
ngeoffray
2012/09/06 16:12:03
Done.
| |
1107 return instruction; | |
1108 } | |
1085 } | 1109 } |
1086 | 1110 |
1087 class HBoolify extends HInstruction { | 1111 class HBoolify extends HInstruction { |
1088 HBoolify(HInstruction value) : super(<HInstruction>[value]); | 1112 HBoolify(HInstruction value) : super(<HInstruction>[value]); |
1089 void prepareGvn(HTypeMap types) { | 1113 void prepareGvn(HTypeMap types) { |
1090 assert(!hasSideEffects(types)); | 1114 assert(!hasSideEffects(types)); |
1091 setUseGvn(); | 1115 setUseGvn(); |
1092 } | 1116 } |
1093 | 1117 |
1094 HType get guaranteedType => HType.BOOLEAN; | 1118 HType get guaranteedType => HType.BOOLEAN; |
(...skipping 1726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2821 HBasicBlock get start => expression.start; | 2845 HBasicBlock get start => expression.start; |
2822 HBasicBlock get end { | 2846 HBasicBlock get end { |
2823 // We don't create a switch block if there are no cases. | 2847 // We don't create a switch block if there are no cases. |
2824 assert(!statements.isEmpty()); | 2848 assert(!statements.isEmpty()); |
2825 return statements.last().end; | 2849 return statements.last().end; |
2826 } | 2850 } |
2827 | 2851 |
2828 bool accept(HStatementInformationVisitor visitor) => | 2852 bool accept(HStatementInformationVisitor visitor) => |
2829 visitor.visitSwitchInfo(this); | 2853 visitor.visitSwitchInfo(this); |
2830 } | 2854 } |
OLD | NEW |