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 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1057 | 1057 |
1058 mapLiteralUntypedMaker = getMember('_makeLiteral'); | 1058 mapLiteralUntypedMaker = getMember('_makeLiteral'); |
1059 mapLiteralUntypedEmptyMaker = getMember('_makeEmpty'); | 1059 mapLiteralUntypedEmptyMaker = getMember('_makeEmpty'); |
1060 enqueueInResolution(mapLiteralUntypedMaker, registry); | 1060 enqueueInResolution(mapLiteralUntypedMaker, registry); |
1061 enqueueInResolution(mapLiteralUntypedEmptyMaker, registry); | 1061 enqueueInResolution(mapLiteralUntypedEmptyMaker, registry); |
1062 } | 1062 } |
1063 } | 1063 } |
1064 if (cls == closureClass) { | 1064 if (cls == closureClass) { |
1065 enqueue(enqueuer, findHelper('closureFromTearOff'), registry); | 1065 enqueue(enqueuer, findHelper('closureFromTearOff'), registry); |
1066 } | 1066 } |
1067 ClassElement result = null; | |
1068 if (cls == compiler.stringClass || cls == jsStringClass) { | 1067 if (cls == compiler.stringClass || cls == jsStringClass) { |
1069 addInterceptors(jsStringClass, enqueuer, registry); | 1068 addInterceptors(jsStringClass, enqueuer, registry); |
1070 } else if (cls == compiler.listClass || | 1069 } else if (cls == compiler.listClass || |
1071 cls == jsArrayClass || | 1070 cls == jsArrayClass || |
1072 cls == jsFixedArrayClass || | 1071 cls == jsFixedArrayClass || |
1073 cls == jsExtendableArrayClass || | 1072 cls == jsExtendableArrayClass || |
1074 cls == jsUnmodifiableArrayClass) { | 1073 cls == jsUnmodifiableArrayClass) { |
1075 addInterceptors(jsArrayClass, enqueuer, registry); | 1074 addInterceptors(jsArrayClass, enqueuer, registry); |
1076 addInterceptors(jsMutableArrayClass, enqueuer, registry); | 1075 addInterceptors(jsMutableArrayClass, enqueuer, registry); |
1077 addInterceptors(jsFixedArrayClass, enqueuer, registry); | 1076 addInterceptors(jsFixedArrayClass, enqueuer, registry); |
(...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2015 if (library.isPlatformLibrary && !library.isPatched) { | 2014 if (library.isPlatformLibrary && !library.isPatched) { |
2016 // Apply patch, if any. | 2015 // Apply patch, if any. |
2017 Uri patchUri = compiler.resolvePatchUri(library.canonicalUri.path); | 2016 Uri patchUri = compiler.resolvePatchUri(library.canonicalUri.path); |
2018 if (patchUri != null) { | 2017 if (patchUri != null) { |
2019 return compiler.patchParser.patchLibrary(loader, patchUri, library); | 2018 return compiler.patchParser.patchLibrary(loader, patchUri, library); |
2020 } | 2019 } |
2021 } | 2020 } |
2022 }).then((_) { | 2021 }).then((_) { |
2023 Uri uri = library.canonicalUri; | 2022 Uri uri = library.canonicalUri; |
2024 | 2023 |
2025 VariableElement findVariable(String name) { | |
2026 return find(library, name); | |
2027 } | |
2028 | |
2029 FunctionElement findMethod(String name) { | 2024 FunctionElement findMethod(String name) { |
2030 return find(library, name); | 2025 return find(library, name); |
2031 } | 2026 } |
2032 | 2027 |
2033 ClassElement findClass(String name) { | 2028 ClassElement findClass(String name) { |
2034 return find(library, name); | 2029 return find(library, name); |
2035 } | 2030 } |
2036 | 2031 |
2037 if (uri == DART_INTERCEPTORS) { | 2032 if (uri == DART_INTERCEPTORS) { |
2038 getInterceptorMethod = findMethod('getInterceptor'); | 2033 getInterceptorMethod = findMethod('getInterceptor'); |
2039 getNativeInterceptorMethod = findMethod('getNativeInterceptor'); | 2034 getNativeInterceptorMethod = findMethod('getNativeInterceptor'); |
2040 | 2035 jsInterceptorClass = findClass('Interceptor'); |
2041 List<ClassElement> classes = [ | 2036 jsStringClass = findClass('JSString'); |
2042 jsInterceptorClass = findClass('Interceptor'), | 2037 jsArrayClass = findClass('JSArray'); |
2043 jsStringClass = findClass('JSString'), | 2038 // The int class must be before the double class, because the |
2044 jsArrayClass = findClass('JSArray'), | 2039 // emitter relies on this list for the order of type checks. |
2045 // The int class must be before the double class, because the | 2040 jsIntClass = findClass('JSInt'); |
2046 // emitter relies on this list for the order of type checks. | 2041 jsPositiveIntClass = findClass('JSPositiveInt'); |
2047 jsIntClass = findClass('JSInt'), | 2042 jsUInt32Class = findClass('JSUInt32'); |
2048 jsPositiveIntClass = findClass('JSPositiveInt'), | 2043 jsUInt31Class = findClass('JSUInt31'); |
2049 jsUInt32Class = findClass('JSUInt32'), | 2044 jsDoubleClass = findClass('JSDouble'); |
2050 jsUInt31Class = findClass('JSUInt31'), | 2045 jsNumberClass = findClass('JSNumber'); |
2051 jsDoubleClass = findClass('JSDouble'), | 2046 jsNullClass = findClass('JSNull'); |
2052 jsNumberClass = findClass('JSNumber'), | 2047 jsBoolClass = findClass('JSBool'); |
2053 jsNullClass = findClass('JSNull'), | 2048 jsMutableArrayClass = findClass('JSMutableArray'); |
2054 jsBoolClass = findClass('JSBool'), | 2049 jsFixedArrayClass = findClass('JSFixedArray'); |
2055 jsMutableArrayClass = findClass('JSMutableArray'), | 2050 jsExtendableArrayClass = findClass('JSExtendableArray'); |
2056 jsFixedArrayClass = findClass('JSFixedArray'), | 2051 jsUnmodifiableArrayClass = findClass('JSUnmodifiableArray'); |
2057 jsExtendableArrayClass = findClass('JSExtendableArray'), | 2052 jsPlainJavaScriptObjectClass = findClass('PlainJavaScriptObject'); |
2058 jsUnmodifiableArrayClass = findClass('JSUnmodifiableArray'), | 2053 jsUnknownJavaScriptObjectClass = findClass('UnknownJavaScriptObject'); |
2059 jsPlainJavaScriptObjectClass = findClass('PlainJavaScriptObject'), | |
2060 jsUnknownJavaScriptObjectClass = findClass('UnknownJavaScriptObject'), | |
2061 ]; | |
2062 | |
2063 jsIndexableClass = findClass('JSIndexable'); | 2054 jsIndexableClass = findClass('JSIndexable'); |
2064 jsMutableIndexableClass = findClass('JSMutableIndexable'); | 2055 jsMutableIndexableClass = findClass('JSMutableIndexable'); |
2065 } else if (uri == DART_JS_HELPER) { | 2056 } else if (uri == DART_JS_HELPER) { |
2066 initializeHelperClasses(); | 2057 initializeHelperClasses(); |
2067 assertMethod = findHelper('assertHelper'); | 2058 assertMethod = findHelper('assertHelper'); |
2068 | 2059 |
2069 typeLiteralClass = findClass('TypeImpl'); | 2060 typeLiteralClass = findClass('TypeImpl'); |
2070 constMapLiteralClass = findClass('ConstantMap'); | 2061 constMapLiteralClass = findClass('ConstantMap'); |
2071 typeVariableClass = findClass('TypeVariable'); | 2062 typeVariableClass = findClass('TypeVariable'); |
2072 | 2063 |
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2983 } | 2974 } |
2984 } | 2975 } |
2985 | 2976 |
2986 /// Records that [constant] is used by the element behind [registry]. | 2977 /// Records that [constant] is used by the element behind [registry]. |
2987 class Dependency { | 2978 class Dependency { |
2988 final ConstantValue constant; | 2979 final ConstantValue constant; |
2989 final Element annotatedElement; | 2980 final Element annotatedElement; |
2990 | 2981 |
2991 const Dependency(this.constant, this.annotatedElement); | 2982 const Dependency(this.constant, this.annotatedElement); |
2992 } | 2983 } |
OLD | NEW |