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 997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1008 }); | 1008 }); |
1009 | 1009 |
1010 if (elements == null) return false; | 1010 if (elements == null) return false; |
1011 if (elements.isEmpty) return false; | 1011 if (elements.isEmpty) return false; |
1012 return elements.any((element) { | 1012 return elements.any((element) { |
1013 return selector.applies(element, compiler.world) && | 1013 return selector.applies(element, compiler.world) && |
1014 (mask == null || mask.canHit(element, selector, compiler.world)); | 1014 (mask == null || mask.canHit(element, selector, compiler.world)); |
1015 }); | 1015 }); |
1016 } | 1016 } |
1017 | 1017 |
1018 /// True if the given class is an internal class used for type inference | |
1019 /// and never exists at runtime. | |
1020 bool isCompileTimeOnlyClass(ClassElement class_) { | |
1021 return class_ == jsPositiveIntClass || | |
sra1
2015/10/28 02:31:52
indent
asgerf
2015/10/28 10:06:31
Done.
| |
1022 class_ == jsUInt32Class || | |
1023 class_ == jsUInt31Class || | |
1024 class_ == jsFixedArrayClass || | |
1025 class_ == jsUnmodifiableArrayClass || | |
1026 class_ == jsMutableArrayClass || | |
1027 class_ == jsExtendableArrayClass; | |
1028 } | |
1029 | |
1030 /// Maps compile-time classes to their runtime class. The runtime class is | |
1031 /// always a superclass or the class itself. | |
1032 ClassElement getRuntimeClass(ClassElement class_) { | |
1033 if (class_.isSubclassOf(jsIntClass)) return jsIntClass; | |
1034 if (class_.isSubclassOf(jsArrayClass)) return jsArrayClass; | |
1035 return class_; | |
1036 } | |
1037 | |
1018 final Map<String, Set<ClassElement>> interceptedClassesCache = | 1038 final Map<String, Set<ClassElement>> interceptedClassesCache = |
1019 new Map<String, Set<ClassElement>>(); | 1039 new Map<String, Set<ClassElement>>(); |
1020 | 1040 |
1021 /** | 1041 /** |
1022 * Returns a set of interceptor classes that contain a member named | 1042 * Returns a set of interceptor classes that contain a member named |
1023 * [name]. Returns [:null:] if there is no class. | 1043 * [name]. Returns [:null:] if there is no class. |
1024 */ | 1044 */ |
1025 Set<ClassElement> getInterceptedClassesOn(String name) { | 1045 Set<ClassElement> getInterceptedClassesOn(String name) { |
1026 Set<Element> intercepted = interceptedElements[name]; | 1046 Set<Element> intercepted = interceptedElements[name]; |
1027 if (intercepted == null) return null; | 1047 if (intercepted == null) return null; |
1028 return interceptedClassesCache.putIfAbsent(name, () { | 1048 return interceptedClassesCache.putIfAbsent(name, () { |
1029 // Populate the cache by running through all the elements and | 1049 // Populate the cache by running through all the elements and |
1030 // determine if the given selector applies to them. | 1050 // determine if the given selector applies to them. |
1031 Set<ClassElement> result = new Set<ClassElement>(); | 1051 Set<ClassElement> result = new Set<ClassElement>(); |
1032 for (Element element in intercepted) { | 1052 for (Element element in intercepted) { |
1033 ClassElement classElement = element.enclosingClass; | 1053 ClassElement classElement = element.enclosingClass; |
1054 if (isCompileTimeOnlyClass(classElement)) continue; | |
1034 if (isNativeOrExtendsNative(classElement) | 1055 if (isNativeOrExtendsNative(classElement) |
1035 || interceptedClasses.contains(classElement)) { | 1056 || interceptedClasses.contains(classElement)) { |
1036 result.add(classElement); | 1057 result.add(classElement); |
1037 } | 1058 } |
1038 if (classesMixedIntoInterceptedClasses.contains(classElement)) { | 1059 if (classesMixedIntoInterceptedClasses.contains(classElement)) { |
1039 Set<ClassElement> nativeSubclasses = | 1060 Set<ClassElement> nativeSubclasses = |
1040 nativeSubclassesOfMixin(classElement); | 1061 nativeSubclassesOfMixin(classElement); |
1041 if (nativeSubclasses != null) result.addAll(nativeSubclasses); | 1062 if (nativeSubclasses != null) result.addAll(nativeSubclasses); |
1042 } | 1063 } |
1043 } | 1064 } |
(...skipping 2169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3213 } | 3234 } |
3214 } | 3235 } |
3215 | 3236 |
3216 /// Records that [constant] is used by the element behind [registry]. | 3237 /// Records that [constant] is used by the element behind [registry]. |
3217 class Dependency { | 3238 class Dependency { |
3218 final ConstantValue constant; | 3239 final ConstantValue constant; |
3219 final Element annotatedElement; | 3240 final Element annotatedElement; |
3220 | 3241 |
3221 const Dependency(this.constant, this.annotatedElement); | 3242 const Dependency(this.constant, this.annotatedElement); |
3222 } | 3243 } |
3223 | |
OLD | NEW |