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 part of ssa; | 5 part of ssa; |
6 | 6 |
7 abstract class HVisitor<R> { | 7 abstract class HVisitor<R> { |
8 R visitAdd(HAdd node); | 8 R visitAdd(HAdd node); |
9 R visitAwait(HAwait node); | 9 R visitAwait(HAwait node); |
10 R visitBitAnd(HBitAnd node); | 10 R visitBitAnd(HBitAnd node); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 } | 165 } |
166 | 166 |
167 HBasicBlock addNewLoopHeaderBlock(JumpTarget target, | 167 HBasicBlock addNewLoopHeaderBlock(JumpTarget target, |
168 List<LabelDefinition> labels) { | 168 List<LabelDefinition> labels) { |
169 HBasicBlock result = addNewBlock(); | 169 HBasicBlock result = addNewBlock(); |
170 result.loopInformation = | 170 result.loopInformation = |
171 new HLoopInformation(result, target, labels); | 171 new HLoopInformation(result, target, labels); |
172 return result; | 172 return result; |
173 } | 173 } |
174 | 174 |
175 HConstant addConstant(ConstantValue constant, Compiler compiler) { | 175 HConstant addConstant(ConstantValue constant, Compiler compiler, |
| 176 {SourceInformation sourceInformation}) { |
176 HConstant result = constants[constant]; | 177 HConstant result = constants[constant]; |
| 178 // TODO(johnniwinther): Support source information per constant reference. |
177 if (result == null) { | 179 if (result == null) { |
178 TypeMask type = computeTypeMask(compiler, constant); | 180 TypeMask type = computeTypeMask(compiler, constant); |
179 result = new HConstant.internal(constant, type); | 181 result = new HConstant.internal(constant, type) |
| 182 ..sourceInformation = sourceInformation; |
180 entry.addAtExit(result); | 183 entry.addAtExit(result); |
181 constants[constant] = result; | 184 constants[constant] = result; |
182 } else if (result.block == null) { | 185 } else if (result.block == null) { |
183 // The constant was not used anymore. | 186 // The constant was not used anymore. |
184 entry.addAtExit(result); | 187 entry.addAtExit(result); |
185 } | 188 } |
186 return result; | 189 return result; |
187 } | 190 } |
188 | 191 |
189 HConstant addDeferredConstant(ConstantValue constant, PrefixElement prefix, | 192 HConstant addDeferredConstant(ConstantValue constant, PrefixElement prefix, |
| 193 SourceInformation sourceInformation, |
190 Compiler compiler) { | 194 Compiler compiler) { |
191 // TODO(sigurdm,johnniwinter): These deferred constants should be created | 195 // TODO(sigurdm,johnniwinter): These deferred constants should be created |
192 // by the constant evaluator. | 196 // by the constant evaluator. |
193 ConstantValue wrapper = new DeferredConstantValue(constant, prefix); | 197 ConstantValue wrapper = new DeferredConstantValue(constant, prefix); |
194 compiler.deferredLoadTask.registerConstantDeferredUse(wrapper, prefix); | 198 compiler.deferredLoadTask.registerConstantDeferredUse(wrapper, prefix); |
195 return addConstant(wrapper, compiler); | 199 return addConstant(wrapper, compiler, sourceInformation: sourceInformation); |
196 } | 200 } |
197 | 201 |
198 HConstant addConstantInt(int i, Compiler compiler) { | 202 HConstant addConstantInt(int i, Compiler compiler) { |
199 return addConstant(compiler.backend.constantSystem.createInt(i), compiler); | 203 return addConstant(compiler.backend.constantSystem.createInt(i), compiler); |
200 } | 204 } |
201 | 205 |
202 HConstant addConstantDouble(double d, Compiler compiler) { | 206 HConstant addConstantDouble(double d, Compiler compiler) { |
203 return addConstant( | 207 return addConstant( |
204 compiler.backend.constantSystem.createDouble(d), compiler); | 208 compiler.backend.constantSystem.createDouble(d), compiler); |
205 } | 209 } |
(...skipping 1095 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1301 */ | 1305 */ |
1302 abstract class HLateInstruction extends HInstruction { | 1306 abstract class HLateInstruction extends HInstruction { |
1303 HLateInstruction(List<HInstruction> inputs, TypeMask type) | 1307 HLateInstruction(List<HInstruction> inputs, TypeMask type) |
1304 : super(inputs, type); | 1308 : super(inputs, type); |
1305 } | 1309 } |
1306 | 1310 |
1307 class HBoolify extends HInstruction { | 1311 class HBoolify extends HInstruction { |
1308 HBoolify(HInstruction value, TypeMask type) | 1312 HBoolify(HInstruction value, TypeMask type) |
1309 : super(<HInstruction>[value], type) { | 1313 : super(<HInstruction>[value], type) { |
1310 setUseGvn(); | 1314 setUseGvn(); |
| 1315 sourceInformation = value.sourceInformation; |
1311 } | 1316 } |
1312 | 1317 |
1313 accept(HVisitor visitor) => visitor.visitBoolify(this); | 1318 accept(HVisitor visitor) => visitor.visitBoolify(this); |
1314 int typeCode() => HInstruction.BOOLIFY_TYPECODE; | 1319 int typeCode() => HInstruction.BOOLIFY_TYPECODE; |
1315 bool typeEquals(other) => other is HBoolify; | 1320 bool typeEquals(other) => other is HBoolify; |
1316 bool dataEquals(HInstruction other) => true; | 1321 bool dataEquals(HInstruction other) => true; |
1317 } | 1322 } |
1318 | 1323 |
1319 /** | 1324 /** |
1320 * A [HCheck] instruction is an instruction that might do a dynamic | 1325 * A [HCheck] instruction is an instruction that might do a dynamic |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1504 /** The class where the call to super is being done. */ | 1509 /** The class where the call to super is being done. */ |
1505 final ClassElement caller; | 1510 final ClassElement caller; |
1506 final bool isSetter; | 1511 final bool isSetter; |
1507 final Selector selector; | 1512 final Selector selector; |
1508 | 1513 |
1509 HInvokeSuper(Element element, | 1514 HInvokeSuper(Element element, |
1510 this.caller, | 1515 this.caller, |
1511 this.selector, | 1516 this.selector, |
1512 inputs, | 1517 inputs, |
1513 type, | 1518 type, |
| 1519 SourceInformation sourceInformation, |
1514 {this.isSetter}) | 1520 {this.isSetter}) |
1515 : super(element, inputs, type); | 1521 : super(element, inputs, type) { |
| 1522 this.sourceInformation = sourceInformation; |
| 1523 } |
1516 | 1524 |
1517 HInstruction get receiver => inputs[0]; | 1525 HInstruction get receiver => inputs[0]; |
1518 HInstruction getDartReceiver(Compiler compiler) { | 1526 HInstruction getDartReceiver(Compiler compiler) { |
1519 return isCallOnInterceptor(compiler) ? inputs[1] : inputs[0]; | 1527 return isCallOnInterceptor(compiler) ? inputs[1] : inputs[0]; |
1520 } | 1528 } |
1521 | 1529 |
1522 /** | 1530 /** |
1523 * Returns whether this call is on an interceptor object. | 1531 * Returns whether this call is on an interceptor object. |
1524 */ | 1532 */ |
1525 bool isCallOnInterceptor(Compiler compiler) { | 1533 bool isCallOnInterceptor(Compiler compiler) { |
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2255 accept(HVisitor visitor) => visitor.visitLessEqual(this); | 2263 accept(HVisitor visitor) => visitor.visitLessEqual(this); |
2256 | 2264 |
2257 BinaryOperation operation(ConstantSystem constantSystem) | 2265 BinaryOperation operation(ConstantSystem constantSystem) |
2258 => constantSystem.lessEqual; | 2266 => constantSystem.lessEqual; |
2259 int typeCode() => HInstruction.LESS_EQUAL_TYPECODE; | 2267 int typeCode() => HInstruction.LESS_EQUAL_TYPECODE; |
2260 bool typeEquals(other) => other is HLessEqual; | 2268 bool typeEquals(other) => other is HLessEqual; |
2261 bool dataEquals(HInstruction other) => true; | 2269 bool dataEquals(HInstruction other) => true; |
2262 } | 2270 } |
2263 | 2271 |
2264 class HReturn extends HControlFlow { | 2272 class HReturn extends HControlFlow { |
2265 HReturn(value) : super(<HInstruction>[value]); | 2273 HReturn(HInstruction value, SourceInformation sourceInformation) |
| 2274 : super(<HInstruction>[value]) { |
| 2275 this.sourceInformation = sourceInformation; |
| 2276 } |
2266 toString() => 'return'; | 2277 toString() => 'return'; |
2267 accept(HVisitor visitor) => visitor.visitReturn(this); | 2278 accept(HVisitor visitor) => visitor.visitReturn(this); |
2268 } | 2279 } |
2269 | 2280 |
2270 class HThrowExpression extends HInstruction { | 2281 class HThrowExpression extends HInstruction { |
2271 HThrowExpression(value) | 2282 HThrowExpression(HInstruction value, SourceInformation sourceInformation) |
2272 : super(<HInstruction>[value], const TypeMask.nonNullEmpty()); | 2283 : super(<HInstruction>[value], const TypeMask.nonNullEmpty()) { |
| 2284 this.sourceInformation = sourceInformation; |
| 2285 } |
2273 toString() => 'throw expression'; | 2286 toString() => 'throw expression'; |
2274 accept(HVisitor visitor) => visitor.visitThrowExpression(this); | 2287 accept(HVisitor visitor) => visitor.visitThrowExpression(this); |
2275 bool canThrow() => true; | 2288 bool canThrow() => true; |
2276 } | 2289 } |
2277 | 2290 |
2278 class HAwait extends HInstruction { | 2291 class HAwait extends HInstruction { |
2279 HAwait(HInstruction value, TypeMask type) | 2292 HAwait(HInstruction value, TypeMask type) |
2280 : super(<HInstruction>[value], type); | 2293 : super(<HInstruction>[value], type); |
2281 toString() => 'await'; | 2294 toString() => 'await'; |
2282 accept(HVisitor visitor) => visitor.visitAwait(this); | 2295 accept(HVisitor visitor) => visitor.visitAwait(this); |
2283 // An await will throw if its argument is not a real future. | 2296 // An await will throw if its argument is not a real future. |
2284 bool canThrow() => true; | 2297 bool canThrow() => true; |
2285 SideEffects sideEffects = new SideEffects(); | 2298 SideEffects sideEffects = new SideEffects(); |
2286 } | 2299 } |
2287 | 2300 |
2288 class HYield extends HInstruction { | 2301 class HYield extends HInstruction { |
2289 HYield(HInstruction value, this.hasStar) | 2302 HYield(HInstruction value, this.hasStar) |
2290 : super(<HInstruction>[value], const TypeMask.nonNullEmpty()); | 2303 : super(<HInstruction>[value], const TypeMask.nonNullEmpty()); |
2291 bool hasStar; | 2304 bool hasStar; |
2292 toString() => 'yield'; | 2305 toString() => 'yield'; |
2293 accept(HVisitor visitor) => visitor.visitYield(this); | 2306 accept(HVisitor visitor) => visitor.visitYield(this); |
2294 bool canThrow() => false; | 2307 bool canThrow() => false; |
2295 SideEffects sideEffects = new SideEffects(); | 2308 SideEffects sideEffects = new SideEffects(); |
2296 } | 2309 } |
2297 | 2310 |
2298 class HThrow extends HControlFlow { | 2311 class HThrow extends HControlFlow { |
2299 final bool isRethrow; | 2312 final bool isRethrow; |
2300 HThrow(value, {this.isRethrow: false}) : super(<HInstruction>[value]); | 2313 HThrow(HInstruction value, |
| 2314 SourceInformation sourceInformation, |
| 2315 {this.isRethrow: false}) |
| 2316 : super(<HInstruction>[value]) { |
| 2317 this.sourceInformation = sourceInformation; |
| 2318 } |
2301 toString() => 'throw'; | 2319 toString() => 'throw'; |
2302 accept(HVisitor visitor) => visitor.visitThrow(this); | 2320 accept(HVisitor visitor) => visitor.visitThrow(this); |
2303 } | 2321 } |
2304 | 2322 |
2305 class HStatic extends HInstruction { | 2323 class HStatic extends HInstruction { |
2306 final Element element; | 2324 final Element element; |
2307 HStatic(this.element, type) : super(<HInstruction>[], type) { | 2325 HStatic(this.element, type) : super(<HInstruction>[], type) { |
2308 assert(element != null); | 2326 assert(element != null); |
2309 assert(invariant(this, element.isDeclaration)); | 2327 assert(invariant(this, element.isDeclaration)); |
2310 sideEffects.clearAllSideEffects(); | 2328 sideEffects.clearAllSideEffects(); |
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3181 class HDynamicType extends HRuntimeType { | 3199 class HDynamicType extends HRuntimeType { |
3182 HDynamicType(DynamicType dartType, TypeMask instructionType) | 3200 HDynamicType(DynamicType dartType, TypeMask instructionType) |
3183 : super(const <HInstruction>[], dartType, instructionType); | 3201 : super(const <HInstruction>[], dartType, instructionType); |
3184 | 3202 |
3185 accept(HVisitor visitor) => visitor.visitDynamicType(this); | 3203 accept(HVisitor visitor) => visitor.visitDynamicType(this); |
3186 | 3204 |
3187 int typeCode() => HInstruction.DYNAMIC_TYPE_TYPECODE; | 3205 int typeCode() => HInstruction.DYNAMIC_TYPE_TYPECODE; |
3188 | 3206 |
3189 bool typeEquals(HInstruction other) => other is HDynamicType; | 3207 bool typeEquals(HInstruction other) => other is HDynamicType; |
3190 } | 3208 } |
OLD | NEW |