| 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 922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 933 /// Maps compile-time classes to their runtime class. The runtime class is | 933 /// Maps compile-time classes to their runtime class. The runtime class is |
| 934 /// always a superclass or the class itself. | 934 /// always a superclass or the class itself. |
| 935 ClassElement getRuntimeClass(ClassElement class_) { | 935 ClassElement getRuntimeClass(ClassElement class_) { |
| 936 if (class_.isSubclassOf(helpers.jsIntClass)) return helpers.jsIntClass; | 936 if (class_.isSubclassOf(helpers.jsIntClass)) return helpers.jsIntClass; |
| 937 if (class_.isSubclassOf(helpers.jsArrayClass)) return helpers.jsArrayClass; | 937 if (class_.isSubclassOf(helpers.jsArrayClass)) return helpers.jsArrayClass; |
| 938 return class_; | 938 return class_; |
| 939 } | 939 } |
| 940 | 940 |
| 941 final Map<String, Set<ClassElement>> interceptedClassesCache = | 941 final Map<String, Set<ClassElement>> interceptedClassesCache = |
| 942 new Map<String, Set<ClassElement>>(); | 942 new Map<String, Set<ClassElement>>(); |
| 943 final Set<ClassElement> _noClasses = new Set<ClassElement>(); |
| 943 | 944 |
| 944 /** | 945 /// Returns a set of interceptor classes that contain a member named [name] |
| 945 * Returns a set of interceptor classes that contain a member named | 946 /// |
| 946 * [name]. Returns [:null:] if there is no class. | 947 /// Returns an empty set if there is no class. Do not modify the returned set. |
| 947 */ | |
| 948 Set<ClassElement> getInterceptedClassesOn(String name) { | 948 Set<ClassElement> getInterceptedClassesOn(String name) { |
| 949 Set<Element> intercepted = interceptedElements[name]; | 949 Set<Element> intercepted = interceptedElements[name]; |
| 950 if (intercepted == null) return null; | 950 if (intercepted == null) return _noClasses; |
| 951 return interceptedClassesCache.putIfAbsent(name, () { | 951 return interceptedClassesCache.putIfAbsent(name, () { |
| 952 // Populate the cache by running through all the elements and | 952 // Populate the cache by running through all the elements and |
| 953 // determine if the given selector applies to them. | 953 // determine if the given selector applies to them. |
| 954 Set<ClassElement> result = new Set<ClassElement>(); | 954 Set<ClassElement> result = new Set<ClassElement>(); |
| 955 for (Element element in intercepted) { | 955 for (Element element in intercepted) { |
| 956 ClassElement classElement = element.enclosingClass; | 956 ClassElement classElement = element.enclosingClass; |
| 957 if (isCompileTimeOnlyClass(classElement)) continue; | 957 if (isCompileTimeOnlyClass(classElement)) continue; |
| 958 if (isNativeOrExtendsNative(classElement) | 958 if (isNativeOrExtendsNative(classElement) |
| 959 || interceptedClasses.contains(classElement)) { | 959 || interceptedClasses.contains(classElement)) { |
| 960 result.add(classElement); | 960 result.add(classElement); |
| (...skipping 2203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3164 } | 3164 } |
| 3165 } | 3165 } |
| 3166 | 3166 |
| 3167 @override | 3167 @override |
| 3168 void onImpactUsed(ImpactUseCase impactUse) { | 3168 void onImpactUsed(ImpactUseCase impactUse) { |
| 3169 if (impactUse == DeferredLoadTask.IMPACT_USE) { | 3169 if (impactUse == DeferredLoadTask.IMPACT_USE) { |
| 3170 resolution.emptyCache(); | 3170 resolution.emptyCache(); |
| 3171 } | 3171 } |
| 3172 } | 3172 } |
| 3173 } | 3173 } |
| OLD | NEW |