| 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 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1309 */ | 1313 */ |
| 1310 abstract class HLateInstruction extends HInstruction { | 1314 abstract class HLateInstruction extends HInstruction { |
| 1311 HLateInstruction(List<HInstruction> inputs, TypeMask type) | 1315 HLateInstruction(List<HInstruction> inputs, TypeMask type) |
| 1312 : super(inputs, type); | 1316 : super(inputs, type); |
| 1313 } | 1317 } |
| 1314 | 1318 |
| 1315 class HBoolify extends HInstruction { | 1319 class HBoolify extends HInstruction { |
| 1316 HBoolify(HInstruction value, TypeMask type) | 1320 HBoolify(HInstruction value, TypeMask type) |
| 1317 : super(<HInstruction>[value], type) { | 1321 : super(<HInstruction>[value], type) { |
| 1318 setUseGvn(); | 1322 setUseGvn(); |
| 1323 sourceInformation = value.sourceInformation; |
| 1319 } | 1324 } |
| 1320 | 1325 |
| 1321 accept(HVisitor visitor) => visitor.visitBoolify(this); | 1326 accept(HVisitor visitor) => visitor.visitBoolify(this); |
| 1322 int typeCode() => HInstruction.BOOLIFY_TYPECODE; | 1327 int typeCode() => HInstruction.BOOLIFY_TYPECODE; |
| 1323 bool typeEquals(other) => other is HBoolify; | 1328 bool typeEquals(other) => other is HBoolify; |
| 1324 bool dataEquals(HInstruction other) => true; | 1329 bool dataEquals(HInstruction other) => true; |
| 1325 } | 1330 } |
| 1326 | 1331 |
| 1327 /** | 1332 /** |
| 1328 * A [HCheck] instruction is an instruction that might do a dynamic | 1333 * A [HCheck] instruction is an instruction that might do a dynamic |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1521 /** The class where the call to super is being done. */ | 1526 /** The class where the call to super is being done. */ |
| 1522 final ClassElement caller; | 1527 final ClassElement caller; |
| 1523 final bool isSetter; | 1528 final bool isSetter; |
| 1524 final Selector selector; | 1529 final Selector selector; |
| 1525 | 1530 |
| 1526 HInvokeSuper(Element element, | 1531 HInvokeSuper(Element element, |
| 1527 this.caller, | 1532 this.caller, |
| 1528 this.selector, | 1533 this.selector, |
| 1529 inputs, | 1534 inputs, |
| 1530 type, | 1535 type, |
| 1536 SourceInformation sourceInformation, |
| 1531 {this.isSetter}) | 1537 {this.isSetter}) |
| 1532 : super(element, inputs, type); | 1538 : super(element, inputs, type) { |
| 1539 this.sourceInformation = sourceInformation; |
| 1540 } |
| 1533 | 1541 |
| 1534 HInstruction get receiver => inputs[0]; | 1542 HInstruction get receiver => inputs[0]; |
| 1535 HInstruction getDartReceiver(Compiler compiler) { | 1543 HInstruction getDartReceiver(Compiler compiler) { |
| 1536 return isCallOnInterceptor(compiler) ? inputs[1] : inputs[0]; | 1544 return isCallOnInterceptor(compiler) ? inputs[1] : inputs[0]; |
| 1537 } | 1545 } |
| 1538 | 1546 |
| 1539 /** | 1547 /** |
| 1540 * Returns whether this call is on an interceptor object. | 1548 * Returns whether this call is on an interceptor object. |
| 1541 */ | 1549 */ |
| 1542 bool isCallOnInterceptor(Compiler compiler) { | 1550 bool isCallOnInterceptor(Compiler compiler) { |
| (...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2295 accept(HVisitor visitor) => visitor.visitLessEqual(this); | 2303 accept(HVisitor visitor) => visitor.visitLessEqual(this); |
| 2296 | 2304 |
| 2297 BinaryOperation operation(ConstantSystem constantSystem) | 2305 BinaryOperation operation(ConstantSystem constantSystem) |
| 2298 => constantSystem.lessEqual; | 2306 => constantSystem.lessEqual; |
| 2299 int typeCode() => HInstruction.LESS_EQUAL_TYPECODE; | 2307 int typeCode() => HInstruction.LESS_EQUAL_TYPECODE; |
| 2300 bool typeEquals(other) => other is HLessEqual; | 2308 bool typeEquals(other) => other is HLessEqual; |
| 2301 bool dataEquals(HInstruction other) => true; | 2309 bool dataEquals(HInstruction other) => true; |
| 2302 } | 2310 } |
| 2303 | 2311 |
| 2304 class HReturn extends HControlFlow { | 2312 class HReturn extends HControlFlow { |
| 2305 HReturn(value) : super(<HInstruction>[value]); | 2313 HReturn(HInstruction value, SourceInformation sourceInformation) |
| 2314 : super(<HInstruction>[value]) { |
| 2315 this.sourceInformation = sourceInformation; |
| 2316 } |
| 2306 toString() => 'return'; | 2317 toString() => 'return'; |
| 2307 accept(HVisitor visitor) => visitor.visitReturn(this); | 2318 accept(HVisitor visitor) => visitor.visitReturn(this); |
| 2308 } | 2319 } |
| 2309 | 2320 |
| 2310 class HThrowExpression extends HInstruction { | 2321 class HThrowExpression extends HInstruction { |
| 2311 HThrowExpression(value) | 2322 HThrowExpression(HInstruction value, SourceInformation sourceInformation) |
| 2312 : super(<HInstruction>[value], const TypeMask.nonNullEmpty()); | 2323 : super(<HInstruction>[value], const TypeMask.nonNullEmpty()) { |
| 2324 this.sourceInformation = sourceInformation; |
| 2325 } |
| 2313 toString() => 'throw expression'; | 2326 toString() => 'throw expression'; |
| 2314 accept(HVisitor visitor) => visitor.visitThrowExpression(this); | 2327 accept(HVisitor visitor) => visitor.visitThrowExpression(this); |
| 2315 bool canThrow() => true; | 2328 bool canThrow() => true; |
| 2316 } | 2329 } |
| 2317 | 2330 |
| 2318 class HAwait extends HInstruction { | 2331 class HAwait extends HInstruction { |
| 2319 HAwait(HInstruction value, TypeMask type) | 2332 HAwait(HInstruction value, TypeMask type) |
| 2320 : super(<HInstruction>[value], type); | 2333 : super(<HInstruction>[value], type); |
| 2321 toString() => 'await'; | 2334 toString() => 'await'; |
| 2322 accept(HVisitor visitor) => visitor.visitAwait(this); | 2335 accept(HVisitor visitor) => visitor.visitAwait(this); |
| 2323 // An await will throw if its argument is not a real future. | 2336 // An await will throw if its argument is not a real future. |
| 2324 bool canThrow() => true; | 2337 bool canThrow() => true; |
| 2325 SideEffects sideEffects = new SideEffects(); | 2338 SideEffects sideEffects = new SideEffects(); |
| 2326 } | 2339 } |
| 2327 | 2340 |
| 2328 class HYield extends HInstruction { | 2341 class HYield extends HInstruction { |
| 2329 HYield(HInstruction value, this.hasStar) | 2342 HYield(HInstruction value, this.hasStar) |
| 2330 : super(<HInstruction>[value], const TypeMask.nonNullEmpty()); | 2343 : super(<HInstruction>[value], const TypeMask.nonNullEmpty()); |
| 2331 bool hasStar; | 2344 bool hasStar; |
| 2332 toString() => 'yield'; | 2345 toString() => 'yield'; |
| 2333 accept(HVisitor visitor) => visitor.visitYield(this); | 2346 accept(HVisitor visitor) => visitor.visitYield(this); |
| 2334 bool canThrow() => false; | 2347 bool canThrow() => false; |
| 2335 SideEffects sideEffects = new SideEffects(); | 2348 SideEffects sideEffects = new SideEffects(); |
| 2336 } | 2349 } |
| 2337 | 2350 |
| 2338 class HThrow extends HControlFlow { | 2351 class HThrow extends HControlFlow { |
| 2339 final bool isRethrow; | 2352 final bool isRethrow; |
| 2340 HThrow(value, {this.isRethrow: false}) : super(<HInstruction>[value]); | 2353 HThrow(HInstruction value, |
| 2354 SourceInformation sourceInformation, |
| 2355 {this.isRethrow: false}) |
| 2356 : super(<HInstruction>[value]) { |
| 2357 this.sourceInformation = sourceInformation; |
| 2358 } |
| 2341 toString() => 'throw'; | 2359 toString() => 'throw'; |
| 2342 accept(HVisitor visitor) => visitor.visitThrow(this); | 2360 accept(HVisitor visitor) => visitor.visitThrow(this); |
| 2343 } | 2361 } |
| 2344 | 2362 |
| 2345 class HStatic extends HInstruction { | 2363 class HStatic extends HInstruction { |
| 2346 final Element element; | 2364 final Element element; |
| 2347 HStatic(this.element, type) : super(<HInstruction>[], type) { | 2365 HStatic(this.element, type) : super(<HInstruction>[], type) { |
| 2348 assert(element != null); | 2366 assert(element != null); |
| 2349 assert(invariant(this, element.isDeclaration)); | 2367 assert(invariant(this, element.isDeclaration)); |
| 2350 sideEffects.clearAllSideEffects(); | 2368 sideEffects.clearAllSideEffects(); |
| (...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3225 class HDynamicType extends HRuntimeType { | 3243 class HDynamicType extends HRuntimeType { |
| 3226 HDynamicType(DynamicType dartType, TypeMask instructionType) | 3244 HDynamicType(DynamicType dartType, TypeMask instructionType) |
| 3227 : super(const <HInstruction>[], dartType, instructionType); | 3245 : super(const <HInstruction>[], dartType, instructionType); |
| 3228 | 3246 |
| 3229 accept(HVisitor visitor) => visitor.visitDynamicType(this); | 3247 accept(HVisitor visitor) => visitor.visitDynamicType(this); |
| 3230 | 3248 |
| 3231 int typeCode() => HInstruction.DYNAMIC_TYPE_TYPECODE; | 3249 int typeCode() => HInstruction.DYNAMIC_TYPE_TYPECODE; |
| 3232 | 3250 |
| 3233 bool typeEquals(HInstruction other) => other is HDynamicType; | 3251 bool typeEquals(HInstruction other) => other is HDynamicType; |
| 3234 } | 3252 } |
| OLD | NEW |