| 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 |
| 11 import '../closure.dart'; | 11 import '../closure.dart'; |
| 12 import '../common.dart'; | 12 import '../common.dart'; |
| 13 import '../common/backend_api.dart' | 13 import '../common/backend_api.dart' |
| 14 show Backend, ImpactTransformer, ForeignResolver, NativeRegistry; | 14 show Backend, ImpactTransformer, ForeignResolver, NativeRegistry; |
| 15 import '../common/codegen.dart' show CodegenImpact, CodegenWorkItem; | 15 import '../common/codegen.dart' show CodegenImpact, CodegenWorkItem; |
| 16 import '../common/names.dart' show Identifiers, Selectors, Uris; | 16 import '../common/names.dart' show Identifiers, Selectors, Uris; |
| 17 import '../common/registry.dart' show EagerRegistry, Registry; | 17 import '../common/registry.dart' show EagerRegistry, Registry; |
| 18 import '../common/resolution.dart' show Frontend, Resolution, ResolutionImpact; | 18 import '../common/resolution.dart' show Frontend, Resolution, ResolutionImpact; |
| 19 import '../common/tasks.dart' show CompilerTask; | 19 import '../common/tasks.dart' show CompilerTask; |
| 20 import '../common/work.dart' show ItemCompilationContext; | 20 import '../common/work.dart' show ItemCompilationContext; |
| 21 import '../compiler.dart' show Compiler; | 21 import '../compiler.dart' show Compiler; |
| 22 import '../constants/constant_system.dart'; | 22 import '../constants/constant_system.dart'; |
| 23 import '../constants/expressions.dart'; | 23 import '../constants/expressions.dart'; |
| 24 import '../constants/values.dart'; | 24 import '../constants/values.dart'; |
| 25 import '../core_types.dart' show CoreClasses, CoreTypes; | 25 import '../core_types.dart' show CoreClasses, CoreTypes; |
| 26 import '../dart_types.dart'; | 26 import '../dart_types.dart'; |
| 27 import '../deferred_load.dart' show DeferredLoadTask; | 27 import '../deferred_load.dart' show DeferredLoadTask; |
| 28 import '../dump_info.dart' show DumpInfoTask; | 28 import '../dump_info.dart' show DumpInfoTask; |
| 29 import '../elements/elements.dart'; | 29 import '../elements/elements.dart'; |
| 30 import '../enqueue.dart' show Enqueuer, ResolutionEnqueuer; | 30 import '../enqueue.dart' |
| 31 show Enqueuer, ResolutionEnqueuer, TreeShakingEnqueuerStrategy; |
| 31 import '../io/position_information.dart' show PositionSourceInformationStrategy; | 32 import '../io/position_information.dart' show PositionSourceInformationStrategy; |
| 32 import '../io/source_information.dart' show SourceInformationStrategy; | 33 import '../io/source_information.dart' show SourceInformationStrategy; |
| 33 import '../io/start_end_information.dart' | 34 import '../io/start_end_information.dart' |
| 34 show StartEndSourceInformationStrategy; | 35 show StartEndSourceInformationStrategy; |
| 35 import '../js/js.dart' as jsAst; | 36 import '../js/js.dart' as jsAst; |
| 36 import '../js/js.dart' show js; | 37 import '../js/js.dart' show js; |
| 37 import '../js/js_source_mapping.dart' show JavaScriptSourceInformationStrategy; | 38 import '../js/js_source_mapping.dart' show JavaScriptSourceInformationStrategy; |
| 38 import '../js/rewrite_async.dart'; | 39 import '../js/rewrite_async.dart'; |
| 39 import '../js_emitter/js_emitter.dart' show CodeEmitterTask; | 40 import '../js_emitter/js_emitter.dart' show CodeEmitterTask; |
| 40 import '../library_loader.dart' show LibraryLoader, LoadedLibraries; | 41 import '../library_loader.dart' show LibraryLoader, LoadedLibraries; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 57 WorldImpact, | 58 WorldImpact, |
| 58 WorldImpactVisitor; | 59 WorldImpactVisitor; |
| 59 import '../util/util.dart'; | 60 import '../util/util.dart'; |
| 60 import '../world.dart' show ClassWorld; | 61 import '../world.dart' show ClassWorld; |
| 61 import 'backend_helpers.dart'; | 62 import 'backend_helpers.dart'; |
| 62 import 'backend_impact.dart'; | 63 import 'backend_impact.dart'; |
| 63 import 'backend_serialization.dart' show JavaScriptBackendSerialization; | 64 import 'backend_serialization.dart' show JavaScriptBackendSerialization; |
| 64 import 'checked_mode_helpers.dart'; | 65 import 'checked_mode_helpers.dart'; |
| 65 import 'constant_handler_javascript.dart'; | 66 import 'constant_handler_javascript.dart'; |
| 66 import 'custom_elements_analysis.dart'; | 67 import 'custom_elements_analysis.dart'; |
| 68 import 'enqueuer.dart'; |
| 67 import 'js_interop_analysis.dart' show JsInteropAnalysis; | 69 import 'js_interop_analysis.dart' show JsInteropAnalysis; |
| 68 import 'lookup_map_analysis.dart' show LookupMapAnalysis; | 70 import 'lookup_map_analysis.dart' show LookupMapAnalysis; |
| 69 import 'namer.dart'; | 71 import 'namer.dart'; |
| 70 import 'native_data.dart' show NativeData; | 72 import 'native_data.dart' show NativeData; |
| 71 import 'no_such_method_registry.dart'; | 73 import 'no_such_method_registry.dart'; |
| 72 import 'patch_resolver.dart'; | 74 import 'patch_resolver.dart'; |
| 73 import 'type_variable_handler.dart'; | 75 import 'type_variable_handler.dart'; |
| 74 | 76 |
| 75 part 'runtime_types.dart'; | 77 part 'runtime_types.dart'; |
| 76 | 78 |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 | 395 |
| 394 TypeMask _unmodifiableArrayTypeCache; | 396 TypeMask _unmodifiableArrayTypeCache; |
| 395 TypeMask get unmodifiableArrayType { | 397 TypeMask get unmodifiableArrayType { |
| 396 if (_unmodifiableArrayTypeCache == null) { | 398 if (_unmodifiableArrayTypeCache == null) { |
| 397 _unmodifiableArrayTypeCache = new TypeMask.nonNullExact( | 399 _unmodifiableArrayTypeCache = new TypeMask.nonNullExact( |
| 398 helpers.jsUnmodifiableArrayClass, compiler.world); | 400 helpers.jsUnmodifiableArrayClass, compiler.world); |
| 399 } | 401 } |
| 400 return _fixedArrayTypeCache; | 402 return _fixedArrayTypeCache; |
| 401 } | 403 } |
| 402 | 404 |
| 403 | |
| 404 /// Maps special classes to their implementation (JSXxx) class. | 405 /// Maps special classes to their implementation (JSXxx) class. |
| 405 Map<ClassElement, ClassElement> implementationClasses; | 406 Map<ClassElement, ClassElement> implementationClasses; |
| 406 | 407 |
| 407 bool needToInitializeIsolateAffinityTag = false; | 408 bool needToInitializeIsolateAffinityTag = false; |
| 408 bool needToInitializeDispatchProperty = false; | 409 bool needToInitializeDispatchProperty = false; |
| 409 | 410 |
| 410 final Namer namer; | 411 final Namer namer; |
| 411 | 412 |
| 412 /** | 413 /** |
| 413 * A collection of selectors that must have a one shot interceptor | 414 * A collection of selectors that must have a one shot interceptor |
| (...skipping 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1556 enqueueType(enqueuer, type, registry); | 1557 enqueueType(enqueuer, type, registry); |
| 1557 } | 1558 } |
| 1558 for (ClassElement cls in impact.instantiatedClasses) { | 1559 for (ClassElement cls in impact.instantiatedClasses) { |
| 1559 enqueueClass(enqueuer, cls, registry); | 1560 enqueueClass(enqueuer, cls, registry); |
| 1560 } | 1561 } |
| 1561 for (BackendImpact otherImpact in impact.otherImpacts) { | 1562 for (BackendImpact otherImpact in impact.otherImpacts) { |
| 1562 enqueueImpact(enqueuer, otherImpact, registry); | 1563 enqueueImpact(enqueuer, otherImpact, registry); |
| 1563 } | 1564 } |
| 1564 } | 1565 } |
| 1565 | 1566 |
| 1567 CodegenEnqueuer createCodegenEnqueuer(Compiler compiler) { |
| 1568 return new CodegenEnqueuer(compiler, createItemCompilationContext, |
| 1569 const TreeShakingEnqueuerStrategy()); |
| 1570 } |
| 1571 |
| 1566 WorldImpact codegen(CodegenWorkItem work) { | 1572 WorldImpact codegen(CodegenWorkItem work) { |
| 1567 Element element = work.element; | 1573 Element element = work.element; |
| 1568 if (compiler.elementHasCompileTimeError(element)) { | 1574 if (compiler.elementHasCompileTimeError(element)) { |
| 1569 DiagnosticMessage message = | 1575 DiagnosticMessage message = |
| 1570 // If there's more than one error, the first is probably most | 1576 // If there's more than one error, the first is probably most |
| 1571 // informative, as the following errors may be side-effects of the | 1577 // informative, as the following errors may be side-effects of the |
| 1572 // first error. | 1578 // first error. |
| 1573 compiler.elementsWithCompileTimeErrors[element].first; | 1579 compiler.elementsWithCompileTimeErrors[element].first; |
| 1574 String messageText = message.message.computeMessage(); | 1580 String messageText = message.message.computeMessage(); |
| 1575 jsAst.LiteralString messageLiteral = | 1581 jsAst.LiteralString messageLiteral = |
| (...skipping 1616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3192 | 3198 |
| 3193 @override | 3199 @override |
| 3194 void onImpactUsed(ImpactUseCase impactUse) { | 3200 void onImpactUsed(ImpactUseCase impactUse) { |
| 3195 if (impactUse == DeferredLoadTask.IMPACT_USE && !supportSerialization) { | 3201 if (impactUse == DeferredLoadTask.IMPACT_USE && !supportSerialization) { |
| 3196 // TODO(johnniwinther): Allow emptying when serialization has been | 3202 // TODO(johnniwinther): Allow emptying when serialization has been |
| 3197 // performed. | 3203 // performed. |
| 3198 resolution.emptyCache(); | 3204 resolution.emptyCache(); |
| 3199 } | 3205 } |
| 3200 } | 3206 } |
| 3201 } | 3207 } |
| OLD | NEW |