| 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 '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../common/backend_api.dart' | 8 import '../common/backend_api.dart' |
| 9 show ForeignResolver, NativeRegistry, ImpactTransformer; | 9 show ForeignResolver, NativeRegistry, ImpactTransformer; |
| 10 import '../common/codegen.dart' show CodegenImpact, CodegenWorkItem; | 10 import '../common/codegen.dart' show CodegenImpact, CodegenWorkItem; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 import '../elements/elements.dart'; | 21 import '../elements/elements.dart'; |
| 22 import '../elements/entities.dart'; | 22 import '../elements/entities.dart'; |
| 23 import '../elements/resolution_types.dart'; | 23 import '../elements/resolution_types.dart'; |
| 24 import '../elements/types.dart'; | 24 import '../elements/types.dart'; |
| 25 import '../enqueue.dart' | 25 import '../enqueue.dart' |
| 26 show | 26 show |
| 27 DirectEnqueuerStrategy, | 27 DirectEnqueuerStrategy, |
| 28 Enqueuer, | 28 Enqueuer, |
| 29 EnqueueTask, | 29 EnqueueTask, |
| 30 ResolutionEnqueuer, | 30 ResolutionEnqueuer, |
| 31 ResolutionWorkItemBuilder, | |
| 32 TreeShakingEnqueuerStrategy; | 31 TreeShakingEnqueuerStrategy; |
| 33 import '../frontend_strategy.dart'; | 32 import '../frontend_strategy.dart'; |
| 34 import '../io/multi_information.dart' show MultiSourceInformationStrategy; | 33 import '../io/multi_information.dart' show MultiSourceInformationStrategy; |
| 35 import '../io/position_information.dart' show PositionSourceInformationStrategy; | 34 import '../io/position_information.dart' show PositionSourceInformationStrategy; |
| 36 import '../io/source_information.dart' show SourceInformationStrategy; | 35 import '../io/source_information.dart' show SourceInformationStrategy; |
| 37 import '../io/start_end_information.dart' | 36 import '../io/start_end_information.dart' |
| 38 show StartEndSourceInformationStrategy; | 37 show StartEndSourceInformationStrategy; |
| 39 import '../js/js.dart' as jsAst; | 38 import '../js/js.dart' as jsAst; |
| 40 import '../js/js.dart' show js; | 39 import '../js/js.dart' show js; |
| 41 import '../js/js_source_mapping.dart' show JavaScriptSourceInformationStrategy; | 40 import '../js/js_source_mapping.dart' show JavaScriptSourceInformationStrategy; |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 final Set<ClassElement> specialOperatorEqClasses = new Set<ClassElement>(); | 353 final Set<ClassElement> specialOperatorEqClasses = new Set<ClassElement>(); |
| 355 | 354 |
| 356 List<CompilerTask> get tasks { | 355 List<CompilerTask> get tasks { |
| 357 List<CompilerTask> result = functionCompiler.tasks; | 356 List<CompilerTask> result = functionCompiler.tasks; |
| 358 result.add(emitter); | 357 result.add(emitter); |
| 359 result.add(patchResolverTask); | 358 result.add(patchResolverTask); |
| 360 result.add(kernelTask); | 359 result.add(kernelTask); |
| 361 return result; | 360 return result; |
| 362 } | 361 } |
| 363 | 362 |
| 364 final RuntimeTypesNeedBuilder _rtiNeedBuilder = | 363 final RuntimeTypesNeedBuilder _rtiNeedBuilder; |
| 365 new _RuntimeTypesNeedBuilder(); | |
| 366 RuntimeTypesNeed _rtiNeed; | 364 RuntimeTypesNeed _rtiNeed; |
| 367 final _RuntimeTypes _rti; | 365 final _RuntimeTypes _rti; |
| 368 | 366 |
| 369 RuntimeTypesEncoder _rtiEncoder; | 367 RuntimeTypesEncoder _rtiEncoder; |
| 370 | 368 |
| 371 /// True if the html library has been loaded. | 369 /// True if the html library has been loaded. |
| 372 bool htmlLibraryIsLoaded = false; | 370 bool htmlLibraryIsLoaded = false; |
| 373 | 371 |
| 374 /// Resolution analysis for tracking reflective access to type variables. | 372 /// Resolution analysis for tracking reflective access to type variables. |
| 375 TypeVariableResolutionAnalysis _typeVariableResolutionAnalysis; | 373 TypeVariableResolutionAnalysis _typeVariableResolutionAnalysis; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 bool useMultiSourceInfo: false, | 477 bool useMultiSourceInfo: false, |
| 480 bool useNewSourceInfo: false, | 478 bool useNewSourceInfo: false, |
| 481 bool useKernel: false}) | 479 bool useKernel: false}) |
| 482 : _rti = new _RuntimeTypes(compiler), | 480 : _rti = new _RuntimeTypes(compiler), |
| 483 annotations = new Annotations(compiler), | 481 annotations = new Annotations(compiler), |
| 484 this.sourceInformationStrategy = createSourceInformationStrategy( | 482 this.sourceInformationStrategy = createSourceInformationStrategy( |
| 485 generateSourceMap: generateSourceMap, | 483 generateSourceMap: generateSourceMap, |
| 486 useMultiSourceInfo: useMultiSourceInfo, | 484 useMultiSourceInfo: useMultiSourceInfo, |
| 487 useNewSourceInfo: useNewSourceInfo), | 485 useNewSourceInfo: useNewSourceInfo), |
| 488 constantCompilerTask = new JavaScriptConstantTask(compiler), | 486 constantCompilerTask = new JavaScriptConstantTask(compiler), |
| 489 _nativeDataResolver = new NativeDataResolverImpl(compiler) { | 487 _nativeDataResolver = new NativeDataResolverImpl(compiler), |
| 488 _rtiNeedBuilder = |
| 489 compiler.frontEndStrategy.createRuntimeTypesNeedBuilder() { |
| 490 _target = new JavaScriptBackendTarget(this); | 490 _target = new JavaScriptBackendTarget(this); |
| 491 impacts = new BackendImpacts(compiler.options, commonElements); | 491 impacts = new BackendImpacts(compiler.options, commonElements); |
| 492 _mirrorsData = new MirrorsDataImpl( | 492 _mirrorsData = compiler.frontEndStrategy.createMirrorsDataBuilder(); |
| 493 compiler, compiler.options, commonElements, constants); | |
| 494 _backendUsageBuilder = new BackendUsageBuilderImpl(commonElements); | 493 _backendUsageBuilder = new BackendUsageBuilderImpl(commonElements); |
| 495 _checkedModeHelpers = new CheckedModeHelpers(commonElements); | 494 _checkedModeHelpers = new CheckedModeHelpers(commonElements); |
| 496 emitter = | 495 emitter = |
| 497 new CodeEmitterTask(compiler, generateSourceMap, useStartupEmitter); | 496 new CodeEmitterTask(compiler, generateSourceMap, useStartupEmitter); |
| 498 | 497 |
| 499 _typeVariableResolutionAnalysis = new TypeVariableResolutionAnalysis( | 498 _typeVariableResolutionAnalysis = new TypeVariableResolutionAnalysis( |
| 500 compiler.elementEnvironment, impacts, backendUsageBuilder); | 499 compiler.elementEnvironment, impacts, backendUsageBuilder); |
| 501 jsInteropAnalysis = new JsInteropAnalysis(this); | 500 jsInteropAnalysis = new JsInteropAnalysis(this); |
| 502 _mirrorsResolutionAnalysis = | 501 _mirrorsResolutionAnalysis = |
| 503 new MirrorsResolutionAnalysisImpl(this, compiler.resolution); | 502 compiler.frontEndStrategy.createMirrorsResolutionAnalysis(this); |
| 504 lookupMapResolutionAnalysis = | 503 lookupMapResolutionAnalysis = |
| 505 new LookupMapResolutionAnalysis(reporter, compiler.elementEnvironment); | 504 new LookupMapResolutionAnalysis(reporter, compiler.elementEnvironment); |
| 506 | 505 |
| 507 noSuchMethodRegistry = new NoSuchMethodRegistry( | 506 noSuchMethodRegistry = new NoSuchMethodRegistry( |
| 508 commonElements, new NoSuchMethodResolverImpl()); | 507 commonElements, compiler.frontEndStrategy.createNoSuchMethodResolver()); |
| 509 kernelTask = new KernelTask(compiler); | 508 kernelTask = new KernelTask(compiler); |
| 510 patchResolverTask = new PatchResolverTask(compiler); | 509 patchResolverTask = new PatchResolverTask(compiler); |
| 511 functionCompiler = | 510 functionCompiler = |
| 512 new SsaFunctionCompiler(this, sourceInformationStrategy, useKernel); | 511 new SsaFunctionCompiler(this, sourceInformationStrategy, useKernel); |
| 513 serialization = new JavaScriptBackendSerialization(this); | 512 serialization = new JavaScriptBackendSerialization(this); |
| 514 } | 513 } |
| 515 | 514 |
| 516 /// The [ConstantSystem] used to interpret compile-time constants for this | 515 /// The [ConstantSystem] used to interpret compile-time constants for this |
| 517 /// backend. | 516 /// backend. |
| 518 ConstantSystem get constantSystem => constants.constantSystem; | 517 ConstantSystem get constantSystem => constants.constantSystem; |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 CompilerTask task, Compiler compiler) { | 825 CompilerTask task, Compiler compiler) { |
| 827 _nativeBasicData = | 826 _nativeBasicData = |
| 828 nativeBasicDataBuilder.close(compiler.elementEnvironment); | 827 nativeBasicDataBuilder.close(compiler.elementEnvironment); |
| 829 _nativeResolutionEnqueuer = new native.NativeResolutionEnqueuer( | 828 _nativeResolutionEnqueuer = new native.NativeResolutionEnqueuer( |
| 830 compiler.options, | 829 compiler.options, |
| 831 compiler.elementEnvironment, | 830 compiler.elementEnvironment, |
| 832 commonElements, | 831 commonElements, |
| 833 backendUsageBuilder, | 832 backendUsageBuilder, |
| 834 compiler.frontEndStrategy.createNativeClassResolver(nativeBasicData)); | 833 compiler.frontEndStrategy.createNativeClassResolver(nativeBasicData)); |
| 835 _nativeData = new NativeDataImpl(nativeBasicData); | 834 _nativeData = new NativeDataImpl(nativeBasicData); |
| 836 _customElementsResolutionAnalysis = new CustomElementsResolutionAnalysis( | 835 _customElementsResolutionAnalysis = compiler.frontEndStrategy |
| 837 compiler.resolution, | 836 .createCustomElementsResolutionAnalysis( |
| 838 constantSystem, | 837 nativeBasicData, backendUsageBuilder); |
| 839 commonElements, | |
| 840 nativeBasicData, | |
| 841 backendUsageBuilder); | |
| 842 impactTransformer = new JavaScriptImpactTransformer( | 838 impactTransformer = new JavaScriptImpactTransformer( |
| 843 compiler.options, | 839 compiler.options, |
| 844 compiler.elementEnvironment, | 840 compiler.elementEnvironment, |
| 845 commonElements, | 841 commonElements, |
| 846 impacts, | 842 impacts, |
| 847 nativeBasicData, | 843 nativeBasicData, |
| 848 _nativeResolutionEnqueuer, | 844 _nativeResolutionEnqueuer, |
| 849 backendUsageBuilder, | 845 backendUsageBuilder, |
| 850 mirrorsDataBuilder, | 846 mirrorsDataBuilder, |
| 851 customElementsResolutionAnalysis, | 847 customElementsResolutionAnalysis, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 870 rtiNeedBuilder, | 866 rtiNeedBuilder, |
| 871 mirrorsDataBuilder, | 867 mirrorsDataBuilder, |
| 872 noSuchMethodRegistry, | 868 noSuchMethodRegistry, |
| 873 customElementsResolutionAnalysis, | 869 customElementsResolutionAnalysis, |
| 874 lookupMapResolutionAnalysis, | 870 lookupMapResolutionAnalysis, |
| 875 mirrorsResolutionAnalysis, | 871 mirrorsResolutionAnalysis, |
| 876 typeVariableResolutionAnalysis, | 872 typeVariableResolutionAnalysis, |
| 877 _nativeResolutionEnqueuer, | 873 _nativeResolutionEnqueuer, |
| 878 compiler.deferredLoadTask, | 874 compiler.deferredLoadTask, |
| 879 kernelTask), | 875 kernelTask), |
| 880 new ElementResolutionWorldBuilder( | 876 compiler.frontEndStrategy.createResolutionWorldBuilder( |
| 881 this, compiler.resolution, const OpenWorldStrategy()), | 877 nativeBasicData, const OpenWorldStrategy()), |
| 882 new ResolutionWorkItemBuilder(compiler.resolution)); | 878 compiler.frontEndStrategy |
| 879 .createResolutionWorkItemBuilder(impactTransformer)); |
| 883 } | 880 } |
| 884 | 881 |
| 885 /// Creates an [Enqueuer] for code generation specific to this backend. | 882 /// Creates an [Enqueuer] for code generation specific to this backend. |
| 886 CodegenEnqueuer createCodegenEnqueuer( | 883 CodegenEnqueuer createCodegenEnqueuer( |
| 887 CompilerTask task, Compiler compiler, ClosedWorld closedWorld) { | 884 CompilerTask task, Compiler compiler, ClosedWorld closedWorld) { |
| 888 _typeVariableCodegenAnalysis = new TypeVariableCodegenAnalysis( | 885 _typeVariableCodegenAnalysis = new TypeVariableCodegenAnalysis( |
| 889 compiler.elementEnvironment, this, commonElements, mirrorsData); | 886 compiler.elementEnvironment, this, commonElements, mirrorsData); |
| 890 _lookupMapAnalysis = new LookupMapAnalysis( | 887 _lookupMapAnalysis = new LookupMapAnalysis( |
| 891 reporter, | 888 reporter, |
| 892 constantSystem, | 889 constantSystem, |
| (...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1451 | 1448 |
| 1452 bool canUseAliasedSuperMember(MemberEntity member, Selector selector) { | 1449 bool canUseAliasedSuperMember(MemberEntity member, Selector selector) { |
| 1453 return !selector.isGetter; | 1450 return !selector.isGetter; |
| 1454 } | 1451 } |
| 1455 | 1452 |
| 1456 /// Returns `true` if [member] is called from a subclass via `super`. | 1453 /// Returns `true` if [member] is called from a subclass via `super`. |
| 1457 bool isAliasedSuperMember(MemberEntity member) { | 1454 bool isAliasedSuperMember(MemberEntity member) { |
| 1458 return _aliasedSuperMembers.contains(member); | 1455 return _aliasedSuperMembers.contains(member); |
| 1459 } | 1456 } |
| 1460 } | 1457 } |
| OLD | NEW |