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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 FunctionInlineCache inlineCache = new FunctionInlineCache(); | 271 FunctionInlineCache inlineCache = new FunctionInlineCache(); |
272 | 272 |
273 LibraryElement jsHelperLibrary; | 273 LibraryElement jsHelperLibrary; |
274 LibraryElement asyncLibrary; | 274 LibraryElement asyncLibrary; |
275 LibraryElement interceptorsLibrary; | 275 LibraryElement interceptorsLibrary; |
276 LibraryElement foreignLibrary; | 276 LibraryElement foreignLibrary; |
277 LibraryElement isolateHelperLibrary; | 277 LibraryElement isolateHelperLibrary; |
278 | 278 |
279 ClassElement closureClass; | 279 ClassElement closureClass; |
280 ClassElement boundClosureClass; | 280 ClassElement boundClosureClass; |
281 Element assertMethod; | 281 Element assertTestMethod; |
| 282 Element assertThrowMethod; |
| 283 Element assertHelperMethod; |
282 Element invokeOnMethod; | 284 Element invokeOnMethod; |
283 | 285 |
284 ClassElement jsInterceptorClass; | 286 ClassElement jsInterceptorClass; |
285 ClassElement jsStringClass; | 287 ClassElement jsStringClass; |
286 ClassElement jsArrayClass; | 288 ClassElement jsArrayClass; |
287 ClassElement jsNumberClass; | 289 ClassElement jsNumberClass; |
288 ClassElement jsIntClass; | 290 ClassElement jsIntClass; |
289 ClassElement jsDoubleClass; | 291 ClassElement jsDoubleClass; |
290 ClassElement jsNullClass; | 292 ClassElement jsNullClass; |
291 ClassElement jsBoolClass; | 293 ClassElement jsBoolClass; |
(...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1347 Element element = find(isolateHelperLibrary, name); | 1349 Element element = find(isolateHelperLibrary, name); |
1348 enqueuer.addToWorkList(element); | 1350 enqueuer.addToWorkList(element); |
1349 compiler.globalDependencies.registerDependency(element); | 1351 compiler.globalDependencies.registerDependency(element); |
1350 helpersUsed.add(element.declaration); | 1352 helpersUsed.add(element.declaration); |
1351 } | 1353 } |
1352 } else { | 1354 } else { |
1353 enqueuer.addToWorkList(find(isolateHelperLibrary, START_ROOT_ISOLATE)); | 1355 enqueuer.addToWorkList(find(isolateHelperLibrary, START_ROOT_ISOLATE)); |
1354 } | 1356 } |
1355 } | 1357 } |
1356 | 1358 |
1357 bool isAssertMethod(Element element) => element == assertMethod; | |
1358 | |
1359 void registerRequiredType(DartType type, Element enclosingElement) { | 1359 void registerRequiredType(DartType type, Element enclosingElement) { |
1360 // If [argument] has type variables or is a type variable, this method | 1360 // If [argument] has type variables or is a type variable, this method |
1361 // registers a RTI dependency between the class where the type variable is | 1361 // registers a RTI dependency between the class where the type variable is |
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); |
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2111 jsMutableArrayClass = findClass('JSMutableArray'); | 2111 jsMutableArrayClass = findClass('JSMutableArray'); |
2112 jsFixedArrayClass = findClass('JSFixedArray'); | 2112 jsFixedArrayClass = findClass('JSFixedArray'); |
2113 jsExtendableArrayClass = findClass('JSExtendableArray'); | 2113 jsExtendableArrayClass = findClass('JSExtendableArray'); |
2114 jsUnmodifiableArrayClass = findClass('JSUnmodifiableArray'); | 2114 jsUnmodifiableArrayClass = findClass('JSUnmodifiableArray'); |
2115 jsPlainJavaScriptObjectClass = findClass('PlainJavaScriptObject'); | 2115 jsPlainJavaScriptObjectClass = findClass('PlainJavaScriptObject'); |
2116 jsUnknownJavaScriptObjectClass = findClass('UnknownJavaScriptObject'); | 2116 jsUnknownJavaScriptObjectClass = findClass('UnknownJavaScriptObject'); |
2117 jsIndexableClass = findClass('JSIndexable'); | 2117 jsIndexableClass = findClass('JSIndexable'); |
2118 jsMutableIndexableClass = findClass('JSMutableIndexable'); | 2118 jsMutableIndexableClass = findClass('JSMutableIndexable'); |
2119 } else if (uri == DART_JS_HELPER) { | 2119 } else if (uri == DART_JS_HELPER) { |
2120 initializeHelperClasses(); | 2120 initializeHelperClasses(); |
2121 assertMethod = findHelper('assertHelper'); | 2121 assertTestMethod = findHelper('assertTest'); |
| 2122 assertThrowMethod = findHelper('assertThrow'); |
| 2123 assertHelperMethod = findHelper('assertHelper'); |
2122 | 2124 |
2123 typeLiteralClass = findClass('TypeImpl'); | 2125 typeLiteralClass = findClass('TypeImpl'); |
2124 constMapLiteralClass = findClass('ConstantMap'); | 2126 constMapLiteralClass = findClass('ConstantMap'); |
2125 typeVariableClass = findClass('TypeVariable'); | 2127 typeVariableClass = findClass('TypeVariable'); |
2126 | 2128 |
2127 jsIndexingBehaviorInterface = findClass('JavaScriptIndexingBehavior'); | 2129 jsIndexingBehaviorInterface = findClass('JavaScriptIndexingBehavior'); |
2128 | 2130 |
2129 noSideEffectsClass = findClass('NoSideEffects'); | 2131 noSideEffectsClass = findClass('NoSideEffects'); |
2130 noThrowsClass = findClass('NoThrows'); | 2132 noThrowsClass = findClass('NoThrows'); |
2131 noInlineClass = findClass('NoInline'); | 2133 noInlineClass = findClass('NoInline'); |
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2908 void registerBackendStaticInvocation(Element element, Registry registry) { | 2910 void registerBackendStaticInvocation(Element element, Registry registry) { |
2909 registry.registerStaticInvocation(backend.registerBackendUse(element)); | 2911 registry.registerStaticInvocation(backend.registerBackendUse(element)); |
2910 } | 2912 } |
2911 | 2913 |
2912 void registerBackendInstantiation(ClassElement element, Registry registry) { | 2914 void registerBackendInstantiation(ClassElement element, Registry registry) { |
2913 backend.registerBackendUse(element); | 2915 backend.registerBackendUse(element); |
2914 element.ensureResolved(backend.compiler); | 2916 element.ensureResolved(backend.compiler); |
2915 registry.registerInstantiation(element.rawType); | 2917 registry.registerInstantiation(element.rawType); |
2916 } | 2918 } |
2917 | 2919 |
2918 void onAssert(Send node, Registry registry) { | 2920 void onAssert(bool hasMessage, Registry registry) { |
2919 registerBackendStaticInvocation(backend.assertMethod, registry); | 2921 if (hasMessage) { |
| 2922 registerBackendStaticInvocation(backend.assertTestMethod, registry); |
| 2923 registerBackendStaticInvocation(backend.assertThrowMethod, registry); |
| 2924 } else { |
| 2925 registerBackendStaticInvocation(backend.assertHelperMethod, registry); |
| 2926 } |
2920 } | 2927 } |
2921 | 2928 |
2922 void onAsyncForIn(AsyncForIn node, Registry registry) { | 2929 void onAsyncForIn(AsyncForIn node, Registry registry) { |
2923 registerBackendStaticInvocation(backend.getStreamIteratorConstructor(), | 2930 registerBackendStaticInvocation(backend.getStreamIteratorConstructor(), |
2924 registry); | 2931 registry); |
2925 } | 2932 } |
2926 | 2933 |
2927 void onStringInterpolation(Registry registry) { | 2934 void onStringInterpolation(Registry registry) { |
2928 assert(registry.isForResolution); | 2935 assert(registry.isForResolution); |
2929 registerBackendStaticInvocation( | 2936 registerBackendStaticInvocation( |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3157 } | 3164 } |
3158 } | 3165 } |
3159 | 3166 |
3160 /// Records that [constant] is used by the element behind [registry]. | 3167 /// Records that [constant] is used by the element behind [registry]. |
3161 class Dependency { | 3168 class Dependency { |
3162 final ConstantValue constant; | 3169 final ConstantValue constant; |
3163 final Element annotatedElement; | 3170 final Element annotatedElement; |
3164 | 3171 |
3165 const Dependency(this.constant, this.annotatedElement); | 3172 const Dependency(this.constant, this.annotatedElement); |
3166 } | 3173 } |
OLD | NEW |