| 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 js_backend; | 5 part of js_backend; |
| 6 | 6 |
| 7 const VERBOSE_OPTIMIZER_HINTS = false; | 7 const VERBOSE_OPTIMIZER_HINTS = false; |
| 8 | 8 |
| 9 class JavaScriptItemCompilationContext extends ItemCompilationContext { | 9 class JavaScriptItemCompilationContext extends ItemCompilationContext { |
| 10 final Set<HInstruction> boundsChecked = new Set<HInstruction>(); | 10 final Set<HInstruction> boundsChecked = new Set<HInstruction>(); |
| (...skipping 1351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1362 // defined (that is the enclosing class of the current element being | 1362 // defined (that is the enclosing class of the current element being |
| 1363 // resolved) and the class of [type]. If the class of [type] requires RTI, | 1363 // resolved) and the class of [type]. If the class of [type] requires RTI, |
| 1364 // then the class of the type variable does too. | 1364 // then the class of the type variable does too. |
| 1365 ClassElement contextClass = Types.getClassContext(type); | 1365 ClassElement contextClass = Types.getClassContext(type); |
| 1366 if (contextClass != null) { | 1366 if (contextClass != null) { |
| 1367 assert(contextClass == enclosingElement.enclosingClass.declaration); | 1367 assert(contextClass == enclosingElement.enclosingClass.declaration); |
| 1368 rti.registerRtiDependency(type.element, contextClass); | 1368 rti.registerRtiDependency(type.element, contextClass); |
| 1369 } | 1369 } |
| 1370 } | 1370 } |
| 1371 | 1371 |
| 1372 void registerClassUsingVariableExpression(ClassElement cls) { | |
| 1373 rti.classesUsingTypeVariableExpression.add(cls); | |
| 1374 } | |
| 1375 | |
| 1376 bool classNeedsRti(ClassElement cls) { | 1372 bool classNeedsRti(ClassElement cls) { |
| 1377 return rti.classesNeedingRti.contains(cls.declaration) || | 1373 return rti.classesNeedingRti.contains(cls.declaration) || |
| 1378 compiler.enabledRuntimeType; | 1374 compiler.enabledRuntimeType; |
| 1379 } | 1375 } |
| 1380 | 1376 |
| 1381 bool isComplexNoSuchMethod(FunctionElement element) => | 1377 bool isComplexNoSuchMethod(FunctionElement element) => |
| 1382 noSuchMethodRegistry.isComplex(element); | 1378 noSuchMethodRegistry.isComplex(element); |
| 1383 | 1379 |
| 1384 bool isDefaultEqualityImplementation(Element element) { | 1380 bool isDefaultEqualityImplementation(Element element) { |
| 1385 assert(element.name == '=='); | 1381 assert(element.name == '=='); |
| (...skipping 1593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2979 } | 2975 } |
| 2980 | 2976 |
| 2981 void onSyncForIn(Registry registry) { | 2977 void onSyncForIn(Registry registry) { |
| 2982 assert(registry.isForResolution); | 2978 assert(registry.isForResolution); |
| 2983 // The SSA builder recognizes certain for-in loops and can generate calls to | 2979 // The SSA builder recognizes certain for-in loops and can generate calls to |
| 2984 // throwConcurrentModificationError. | 2980 // throwConcurrentModificationError. |
| 2985 registerBackendStaticInvocation( | 2981 registerBackendStaticInvocation( |
| 2986 backend.getCheckConcurrentModificationError(), registry); | 2982 backend.getCheckConcurrentModificationError(), registry); |
| 2987 } | 2983 } |
| 2988 | 2984 |
| 2989 void onTypeVariableExpression(Registry registry) { | 2985 void onTypeVariableExpression(Registry registry, |
| 2986 TypeVariableElement variable) { |
| 2990 assert(registry.isForResolution); | 2987 assert(registry.isForResolution); |
| 2991 registerBackendStaticInvocation(backend.getSetRuntimeTypeInfo(), registry); | 2988 registerBackendStaticInvocation(backend.getSetRuntimeTypeInfo(), registry); |
| 2992 registerBackendStaticInvocation(backend.getGetRuntimeTypeInfo(), registry); | 2989 registerBackendStaticInvocation(backend.getGetRuntimeTypeInfo(), registry); |
| 2993 backend.registerGetRuntimeTypeArgument(registry); | 2990 backend.registerGetRuntimeTypeArgument(registry); |
| 2994 registerBackendInstantiation(backend.compiler.listClass, registry); | 2991 registerBackendInstantiation(backend.compiler.listClass, registry); |
| 2995 registerBackendStaticInvocation(backend.getRuntimeTypeToString(), registry); | 2992 registerBackendStaticInvocation(backend.getRuntimeTypeToString(), registry); |
| 2996 registerBackendStaticInvocation(backend.getCreateRuntimeType(), registry); | 2993 registerBackendStaticInvocation(backend.getCreateRuntimeType(), registry); |
| 2997 needsInt(registry, 'Needed for accessing a type variable literal on this.'); | 2994 needsInt(registry, 'Needed for accessing a type variable literal on this.'); |
| 2995 ClassElement cls = variable.enclosingClass; |
| 2996 backend.rti.classesUsingTypeVariableExpression.add(cls); |
| 2998 } | 2997 } |
| 2999 | 2998 |
| 3000 // TODO(johnniwinther): Maybe split this into [onAssertType] and [onTestType]. | 2999 // TODO(johnniwinther): Maybe split this into [onAssertType] and [onTestType]. |
| 3001 void onIsCheck(DartType type, Registry registry) { | 3000 void onIsCheck(DartType type, Registry registry) { |
| 3002 assert(registry.isForResolution); | 3001 assert(registry.isForResolution); |
| 3003 type = type.unalias(backend.compiler); | 3002 type = type.unalias(backend.compiler); |
| 3004 registerBackendInstantiation(backend.compiler.boolClass, registry); | 3003 registerBackendInstantiation(backend.compiler.boolClass, registry); |
| 3005 bool inCheckedMode = backend.compiler.enableTypeAssertions; | 3004 bool inCheckedMode = backend.compiler.enableTypeAssertions; |
| 3006 if (inCheckedMode) { | 3005 if (inCheckedMode) { |
| 3007 registerBackendStaticInvocation(backend.getThrowRuntimeError(), registry); | 3006 registerBackendStaticInvocation(backend.getThrowRuntimeError(), registry); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3160 } | 3159 } |
| 3161 } | 3160 } |
| 3162 | 3161 |
| 3163 /// Records that [constant] is used by the element behind [registry]. | 3162 /// Records that [constant] is used by the element behind [registry]. |
| 3164 class Dependency { | 3163 class Dependency { |
| 3165 final ConstantValue constant; | 3164 final ConstantValue constant; |
| 3166 final Element annotatedElement; | 3165 final Element annotatedElement; |
| 3167 | 3166 |
| 3168 const Dependency(this.constant, this.annotatedElement); | 3167 const Dependency(this.constant, this.annotatedElement); |
| 3169 } | 3168 } |
| OLD | NEW |