| 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 import '../closure.dart'; | 5 import '../closure.dart'; |
| 6 import '../common.dart'; | 6 import '../common.dart'; |
| 7 import '../common/backend_api.dart' show BackendClasses; | 7 import '../common/backend_api.dart' show BackendClasses; |
| 8 import '../compiler.dart' show Compiler; | 8 import '../compiler.dart' show Compiler; |
| 9 import '../constants/constant_system.dart'; | 9 import '../constants/constant_system.dart'; |
| 10 import '../constants/values.dart'; | 10 import '../constants/values.dart'; |
| 11 import '../dart_types.dart'; | |
| 12 import '../elements/elements.dart' | 11 import '../elements/elements.dart' |
| 13 show Entity, JumpTarget, LabelDefinition, Local; | 12 show Entity, JumpTarget, LabelDefinition, Local; |
| 14 import '../elements/entities.dart'; | 13 import '../elements/entities.dart'; |
| 14 import '../elements/types.dart'; |
| 15 import '../io/source_information.dart'; | 15 import '../io/source_information.dart'; |
| 16 import '../js/js.dart' as js; | 16 import '../js/js.dart' as js; |
| 17 import '../js_backend/backend_helpers.dart' show BackendHelpers; | 17 import '../js_backend/backend_helpers.dart' show BackendHelpers; |
| 18 import '../js_backend/js_backend.dart'; | 18 import '../js_backend/js_backend.dart'; |
| 19 import '../native/native.dart' as native; | 19 import '../native/native.dart' as native; |
| 20 import '../tree/dartstring.dart' as ast; | 20 import '../tree/dartstring.dart' as ast; |
| 21 import '../types/constants.dart' show computeTypeMask; | 21 import '../types/constants.dart' show computeTypeMask; |
| 22 import '../types/types.dart'; | 22 import '../types/types.dart'; |
| 23 import '../universe/selector.dart' show Selector; | 23 import '../universe/selector.dart' show Selector; |
| 24 import '../universe/side_effects.dart' show SideEffects; | 24 import '../universe/side_effects.dart' show SideEffects; |
| (...skipping 1324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1349 type, kind, closedWorld.commonMasks.dynamicType, this); | 1349 type, kind, closedWorld.commonMasks.dynamicType, this); |
| 1350 } | 1350 } |
| 1351 assert(type.isInterfaceType); | 1351 assert(type.isInterfaceType); |
| 1352 if (kind == HTypeConversion.BOOLEAN_CONVERSION_CHECK) { | 1352 if (kind == HTypeConversion.BOOLEAN_CONVERSION_CHECK) { |
| 1353 // Boolean conversion checks work on non-nullable booleans. | 1353 // Boolean conversion checks work on non-nullable booleans. |
| 1354 return new HTypeConversion( | 1354 return new HTypeConversion( |
| 1355 type, kind, closedWorld.commonMasks.boolType, this); | 1355 type, kind, closedWorld.commonMasks.boolType, this); |
| 1356 } else if (kind == HTypeConversion.CHECKED_MODE_CHECK && !type.treatAsRaw) { | 1356 } else if (kind == HTypeConversion.CHECKED_MODE_CHECK && !type.treatAsRaw) { |
| 1357 throw 'creating compound check to $type (this = ${this})'; | 1357 throw 'creating compound check to $type (this = ${this})'; |
| 1358 } else { | 1358 } else { |
| 1359 Entity cls = type.element; | 1359 InterfaceType interfaceType = type; |
| 1360 TypeMask subtype = new TypeMask.subtype(cls, closedWorld); | 1360 TypeMask subtype = |
| 1361 new TypeMask.subtype(interfaceType.element, closedWorld); |
| 1361 return new HTypeConversion(type, kind, subtype, this); | 1362 return new HTypeConversion(type, kind, subtype, this); |
| 1362 } | 1363 } |
| 1363 } | 1364 } |
| 1364 | 1365 |
| 1365 /** | 1366 /** |
| 1366 * Return whether the instructions do not belong to a loop or | 1367 * Return whether the instructions do not belong to a loop or |
| 1367 * belong to the same loop. | 1368 * belong to the same loop. |
| 1368 */ | 1369 */ |
| 1369 bool hasSameLoopHeaderAs(HInstruction other) { | 1370 bool hasSameLoopHeaderAs(HInstruction other) { |
| 1370 return block.enclosingLoopHeader == other.block.enclosingLoopHeader; | 1371 return block.enclosingLoopHeader == other.block.enclosingLoopHeader; |
| (...skipping 1417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2788 final Selector receiverTypeCheckSelector; | 2789 final Selector receiverTypeCheckSelector; |
| 2789 | 2790 |
| 2790 TypeMask checkedType; // Not final because we refine it. | 2791 TypeMask checkedType; // Not final because we refine it. |
| 2791 | 2792 |
| 2792 HTypeConversion( | 2793 HTypeConversion( |
| 2793 this.typeExpression, this.kind, TypeMask type, HInstruction input, | 2794 this.typeExpression, this.kind, TypeMask type, HInstruction input, |
| 2794 {this.receiverTypeCheckSelector}) | 2795 {this.receiverTypeCheckSelector}) |
| 2795 : checkedType = type, | 2796 : checkedType = type, |
| 2796 super(<HInstruction>[input], type) { | 2797 super(<HInstruction>[input], type) { |
| 2797 assert(!isReceiverTypeCheck || receiverTypeCheckSelector != null); | 2798 assert(!isReceiverTypeCheck || receiverTypeCheckSelector != null); |
| 2798 assert(typeExpression == null || typeExpression.kind != TypeKind.TYPEDEF); | 2799 assert(typeExpression == null || !typeExpression.isTypedef); |
| 2799 sourceElement = input.sourceElement; | 2800 sourceElement = input.sourceElement; |
| 2800 } | 2801 } |
| 2801 | 2802 |
| 2802 HTypeConversion.withTypeRepresentation(this.typeExpression, this.kind, | 2803 HTypeConversion.withTypeRepresentation(this.typeExpression, this.kind, |
| 2803 TypeMask type, HInstruction input, HInstruction typeRepresentation) | 2804 TypeMask type, HInstruction input, HInstruction typeRepresentation) |
| 2804 : checkedType = type, | 2805 : checkedType = type, |
| 2805 super(<HInstruction>[input, typeRepresentation], type), | 2806 super(<HInstruction>[input, typeRepresentation], type), |
| 2806 receiverTypeCheckSelector = null { | 2807 receiverTypeCheckSelector = null { |
| 2807 assert(typeExpression.kind != TypeKind.TYPEDEF); | 2808 assert(!typeExpression.isTypedef); |
| 2808 sourceElement = input.sourceElement; | 2809 sourceElement = input.sourceElement; |
| 2809 } | 2810 } |
| 2810 | 2811 |
| 2811 HTypeConversion.viaMethodOnType(this.typeExpression, this.kind, TypeMask type, | 2812 HTypeConversion.viaMethodOnType(this.typeExpression, this.kind, TypeMask type, |
| 2812 HInstruction reifiedType, HInstruction input) | 2813 HInstruction reifiedType, HInstruction input) |
| 2813 : checkedType = type, | 2814 : checkedType = type, |
| 2814 super(<HInstruction>[reifiedType, input], type), | 2815 super(<HInstruction>[reifiedType, input], type), |
| 2815 receiverTypeCheckSelector = null { | 2816 receiverTypeCheckSelector = null { |
| 2816 // This form is currently used only for function types. | 2817 // This form is currently used only for function types. |
| 2817 assert(typeExpression.isFunctionType); | 2818 assert(typeExpression.isFunctionType); |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3257 HInstruction get object => inputs.single; | 3258 HInstruction get object => inputs.single; |
| 3258 | 3259 |
| 3259 accept(HVisitor visitor) => visitor.visitTypeInfoReadVariable(this); | 3260 accept(HVisitor visitor) => visitor.visitTypeInfoReadVariable(this); |
| 3260 | 3261 |
| 3261 bool canThrow() => false; | 3262 bool canThrow() => false; |
| 3262 | 3263 |
| 3263 int typeCode() => HInstruction.TYPE_INFO_READ_VARIABLE_TYPECODE; | 3264 int typeCode() => HInstruction.TYPE_INFO_READ_VARIABLE_TYPECODE; |
| 3264 bool typeEquals(HInstruction other) => other is HTypeInfoReadVariable; | 3265 bool typeEquals(HInstruction other) => other is HTypeInfoReadVariable; |
| 3265 | 3266 |
| 3266 bool dataEquals(HTypeInfoReadVariable other) { | 3267 bool dataEquals(HTypeInfoReadVariable other) { |
| 3267 return variable.element == other.variable.element; | 3268 return variable == other.variable; |
| 3268 } | 3269 } |
| 3269 | 3270 |
| 3270 String toString() => 'HTypeInfoReadVariable($variable)'; | 3271 String toString() => 'HTypeInfoReadVariable($variable)'; |
| 3271 } | 3272 } |
| 3272 | 3273 |
| 3273 enum TypeInfoExpressionKind { COMPLETE, INSTANCE } | 3274 enum TypeInfoExpressionKind { COMPLETE, INSTANCE } |
| 3274 | 3275 |
| 3275 /// Constructs a representation of a closed or ground-term type (that is, a type | 3276 /// Constructs a representation of a closed or ground-term type (that is, a type |
| 3276 /// without type variables). | 3277 /// without type variables). |
| 3277 /// | 3278 /// |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3375 } | 3376 } |
| 3376 | 3377 |
| 3377 accept(HVisitor visitor) => visitor.visitReadTypeVariable(this); | 3378 accept(HVisitor visitor) => visitor.visitReadTypeVariable(this); |
| 3378 | 3379 |
| 3379 bool canThrow() => false; | 3380 bool canThrow() => false; |
| 3380 | 3381 |
| 3381 int typeCode() => HInstruction.READ_TYPE_VARIABLE_TYPECODE; | 3382 int typeCode() => HInstruction.READ_TYPE_VARIABLE_TYPECODE; |
| 3382 bool typeEquals(HInstruction other) => other is HReadTypeVariable; | 3383 bool typeEquals(HInstruction other) => other is HReadTypeVariable; |
| 3383 | 3384 |
| 3384 bool dataEquals(HReadTypeVariable other) { | 3385 bool dataEquals(HReadTypeVariable other) { |
| 3385 return dartType.element == other.dartType.element && | 3386 return dartType == other.dartType && hasReceiver == other.hasReceiver; |
| 3386 hasReceiver == other.hasReceiver; | |
| 3387 } | 3387 } |
| 3388 } | 3388 } |
| 3389 | 3389 |
| 3390 abstract class HRuntimeType extends HInstruction { | 3390 abstract class HRuntimeType extends HInstruction { |
| 3391 final DartType dartType; | 3391 final DartType dartType; |
| 3392 | 3392 |
| 3393 HRuntimeType( | 3393 HRuntimeType( |
| 3394 List<HInstruction> inputs, this.dartType, TypeMask instructionType) | 3394 List<HInstruction> inputs, this.dartType, TypeMask instructionType) |
| 3395 : super(inputs, instructionType) { | 3395 : super(inputs, instructionType) { |
| 3396 setUseGvn(); | 3396 setUseGvn(); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3449 class HDynamicType extends HRuntimeType { | 3449 class HDynamicType extends HRuntimeType { |
| 3450 HDynamicType(DynamicType dartType, TypeMask instructionType) | 3450 HDynamicType(DynamicType dartType, TypeMask instructionType) |
| 3451 : super(const <HInstruction>[], dartType, instructionType); | 3451 : super(const <HInstruction>[], dartType, instructionType); |
| 3452 | 3452 |
| 3453 accept(HVisitor visitor) => visitor.visitDynamicType(this); | 3453 accept(HVisitor visitor) => visitor.visitDynamicType(this); |
| 3454 | 3454 |
| 3455 int typeCode() => HInstruction.DYNAMIC_TYPE_TYPECODE; | 3455 int typeCode() => HInstruction.DYNAMIC_TYPE_TYPECODE; |
| 3456 | 3456 |
| 3457 bool typeEquals(HInstruction other) => other is HDynamicType; | 3457 bool typeEquals(HInstruction other) => other is HDynamicType; |
| 3458 } | 3458 } |
| OLD | NEW |