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 library js_backend.backend; | 5 library js_backend.backend; |
6 | 6 |
7 import 'dart:async' show Future; | 7 import 'dart:async' show Future; |
8 | 8 |
9 import 'package:js_runtime/shared/embedded_names.dart' as embeddedNames; | 9 import 'package:js_runtime/shared/embedded_names.dart' as embeddedNames; |
10 | 10 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 show | 57 show |
58 ImpactStrategy, | 58 ImpactStrategy, |
59 ImpactUseCase, | 59 ImpactUseCase, |
60 TransformedWorldImpact, | 60 TransformedWorldImpact, |
61 WorldImpact, | 61 WorldImpact, |
62 WorldImpactBuilder, | 62 WorldImpactBuilder, |
63 WorldImpactBuilderImpl, | 63 WorldImpactBuilderImpl, |
64 WorldImpactVisitor, | 64 WorldImpactVisitor, |
65 StagedWorldImpactBuilder; | 65 StagedWorldImpactBuilder; |
66 import '../util/util.dart'; | 66 import '../util/util.dart'; |
67 import '../world.dart' show ClosedWorld; | 67 import '../world.dart' show ClosedWorld, ClosedWorldRefiner; |
68 import 'backend_helpers.dart'; | 68 import 'backend_helpers.dart'; |
69 import 'backend_impact.dart'; | 69 import 'backend_impact.dart'; |
70 import 'backend_serialization.dart' show JavaScriptBackendSerialization; | 70 import 'backend_serialization.dart' show JavaScriptBackendSerialization; |
71 import 'checked_mode_helpers.dart'; | 71 import 'checked_mode_helpers.dart'; |
72 import 'constant_handler_javascript.dart'; | 72 import 'constant_handler_javascript.dart'; |
73 import 'custom_elements_analysis.dart'; | 73 import 'custom_elements_analysis.dart'; |
74 import 'enqueuer.dart'; | 74 import 'enqueuer.dart'; |
75 import 'js_interop_analysis.dart' show JsInteropAnalysis; | 75 import 'js_interop_analysis.dart' show JsInteropAnalysis; |
76 import '../kernel/task.dart'; | 76 import '../kernel/task.dart'; |
77 import 'lookup_map_analysis.dart' show LookupMapAnalysis; | 77 import 'lookup_map_analysis.dart' show LookupMapAnalysis; |
(...skipping 1197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1275 if (TRACE_CALLS) { | 1275 if (TRACE_CALLS) { |
1276 impactTransformer.registerBackendImpact( | 1276 impactTransformer.registerBackendImpact( |
1277 impactBuilder, impacts.traceHelper); | 1277 impactBuilder, impacts.traceHelper); |
1278 } | 1278 } |
1279 impactTransformer.registerBackendImpact( | 1279 impactTransformer.registerBackendImpact( |
1280 impactBuilder, impacts.assertUnreachable); | 1280 impactBuilder, impacts.assertUnreachable); |
1281 _registerCheckedModeHelpers(impactBuilder); | 1281 _registerCheckedModeHelpers(impactBuilder); |
1282 return impactBuilder; | 1282 return impactBuilder; |
1283 } | 1283 } |
1284 | 1284 |
1285 onResolutionComplete() { | 1285 onResolutionComplete(ClosedWorldRefiner closedWorldRefiner) { |
1286 compiler.enqueuer.resolution.processedEntities.forEach(processAnnotations); | 1286 for (Entity entity in compiler.enqueuer.resolution.processedEntities) { |
1287 super.onResolutionComplete(); | 1287 processAnnotations(entity, closedWorldRefiner); |
| 1288 } |
| 1289 super.onResolutionComplete(closedWorldRefiner); |
1288 computeMembersNeededForReflection(); | 1290 computeMembersNeededForReflection(); |
1289 rti.computeClassesNeedingRti(); | 1291 rti.computeClassesNeedingRti(); |
1290 _registeredMetadata.clear(); | 1292 _registeredMetadata.clear(); |
1291 } | 1293 } |
1292 | 1294 |
1293 onTypeInferenceComplete() { | 1295 onTypeInferenceComplete() { |
1294 super.onTypeInferenceComplete(); | 1296 super.onTypeInferenceComplete(); |
1295 noSuchMethodRegistry.onTypeInferenceComplete(); | 1297 noSuchMethodRegistry.onTypeInferenceComplete(); |
1296 } | 1298 } |
1297 | 1299 |
(...skipping 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2383 | 2385 |
2384 WorldImpact onCodegenStart() { | 2386 WorldImpact onCodegenStart() { |
2385 lookupMapAnalysis.onCodegenStart(); | 2387 lookupMapAnalysis.onCodegenStart(); |
2386 if (hasIsolateSupport) { | 2388 if (hasIsolateSupport) { |
2387 return enableIsolateSupport(forResolution: false); | 2389 return enableIsolateSupport(forResolution: false); |
2388 } | 2390 } |
2389 return const WorldImpact(); | 2391 return const WorldImpact(); |
2390 } | 2392 } |
2391 | 2393 |
2392 /// Process backend specific annotations. | 2394 /// Process backend specific annotations. |
2393 void processAnnotations(Element element) { | 2395 void processAnnotations( |
| 2396 Element element, ClosedWorldRefiner closedWorldRefiner) { |
2394 if (element.isMalformed) { | 2397 if (element.isMalformed) { |
2395 // Elements that are marked as malformed during parsing or resolution | 2398 // Elements that are marked as malformed during parsing or resolution |
2396 // might be registered here. These should just be ignored. | 2399 // might be registered here. These should just be ignored. |
2397 return; | 2400 return; |
2398 } | 2401 } |
2399 | 2402 |
2400 Element implementation = element.implementation; | 2403 Element implementation = element.implementation; |
2401 if (element.isFunction || element.isConstructor) { | 2404 if (element.isFunction || element.isConstructor) { |
2402 if (annotations.noInline(implementation)) { | 2405 if (annotations.noInline(implementation)) { |
2403 inlineCache.markAsNonInlinable(implementation); | 2406 inlineCache.markAsNonInlinable(implementation); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2437 !element.isFactoryConstructor) { | 2440 !element.isFactoryConstructor) { |
2438 reporter.internalError( | 2441 reporter.internalError( |
2439 element, | 2442 element, |
2440 "@NoThrows() is currently limited to top-level" | 2443 "@NoThrows() is currently limited to top-level" |
2441 " or static functions and factory constructors."); | 2444 " or static functions and factory constructors."); |
2442 } | 2445 } |
2443 if (VERBOSE_OPTIMIZER_HINTS) { | 2446 if (VERBOSE_OPTIMIZER_HINTS) { |
2444 reporter.reportHintMessage( | 2447 reporter.reportHintMessage( |
2445 element, MessageKind.GENERIC, {'text': "Cannot throw"}); | 2448 element, MessageKind.GENERIC, {'text': "Cannot throw"}); |
2446 } | 2449 } |
2447 compiler.inferenceWorld.registerCannotThrow(element); | 2450 closedWorldRefiner.registerCannotThrow(element); |
2448 } else if (cls == helpers.noSideEffectsClass) { | 2451 } else if (cls == helpers.noSideEffectsClass) { |
2449 hasNoSideEffects = true; | 2452 hasNoSideEffects = true; |
2450 if (VERBOSE_OPTIMIZER_HINTS) { | 2453 if (VERBOSE_OPTIMIZER_HINTS) { |
2451 reporter.reportHintMessage( | 2454 reporter.reportHintMessage( |
2452 element, MessageKind.GENERIC, {'text': "Has no side effects"}); | 2455 element, MessageKind.GENERIC, {'text': "Has no side effects"}); |
2453 } | 2456 } |
2454 compiler.inferenceWorld.registerSideEffectsFree(element); | 2457 closedWorldRefiner.registerSideEffectsFree(element); |
2455 } | 2458 } |
2456 } | 2459 } |
2457 if (hasForceInline && hasNoInline) { | 2460 if (hasForceInline && hasNoInline) { |
2458 reporter.internalError( | 2461 reporter.internalError( |
2459 element, "@ForceInline() must not be used with @NoInline."); | 2462 element, "@ForceInline() must not be used with @NoInline."); |
2460 } | 2463 } |
2461 if (hasNoThrows && !hasNoInline) { | 2464 if (hasNoThrows && !hasNoInline) { |
2462 reporter.internalError( | 2465 reporter.internalError( |
2463 element, "@NoThrows() should always be combined with @NoInline."); | 2466 element, "@NoThrows() should always be combined with @NoInline."); |
2464 } | 2467 } |
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3229 helpers.jsMutableIndexableClass; | 3232 helpers.jsMutableIndexableClass; |
3230 | 3233 |
3231 bool isDefaultEqualityImplementation(Element element) { | 3234 bool isDefaultEqualityImplementation(Element element) { |
3232 assert(element.name == '=='); | 3235 assert(element.name == '=='); |
3233 ClassElement classElement = element.enclosingClass; | 3236 ClassElement classElement = element.enclosingClass; |
3234 return classElement == helpers.coreClasses.objectClass || | 3237 return classElement == helpers.coreClasses.objectClass || |
3235 classElement == helpers.jsInterceptorClass || | 3238 classElement == helpers.jsInterceptorClass || |
3236 classElement == helpers.jsNullClass; | 3239 classElement == helpers.jsNullClass; |
3237 } | 3240 } |
3238 } | 3241 } |
OLD | NEW |