| Index: pkg/compiler/lib/src/js_backend/backend.dart
|
| diff --git a/pkg/compiler/lib/src/js_backend/backend.dart b/pkg/compiler/lib/src/js_backend/backend.dart
|
| index aa761c550cb717dcdfad4d91a41bbe27ae6728cf..f9bf86f03aa51f4ef37bb2ba9c1bee99e789a0f2 100644
|
| --- a/pkg/compiler/lib/src/js_backend/backend.dart
|
| +++ b/pkg/compiler/lib/src/js_backend/backend.dart
|
| @@ -365,18 +365,13 @@ class JavaScriptBackend {
|
| return result;
|
| }
|
|
|
| - final RuntimeTypesNeedBuilder _rtiNeedBuilder;
|
| - RuntimeTypesNeed _rtiNeed;
|
| - final RuntimeTypesImpl _rti;
|
| + RuntimeTypesImpl _rti;
|
|
|
| RuntimeTypesEncoder _rtiEncoder;
|
|
|
| /// True if the html library has been loaded.
|
| bool htmlLibraryIsLoaded = false;
|
|
|
| - /// Resolution analysis for tracking reflective access to type variables.
|
| - TypeVariableResolutionAnalysis _typeVariableResolutionAnalysis;
|
| -
|
| /// Codegen handler for reflective access to type variables.
|
| TypeVariableCodegenAnalysis _typeVariableCodegenAnalysis;
|
|
|
| @@ -427,9 +422,6 @@ class JavaScriptBackend {
|
| JavaScriptBackendSerialization serialization;
|
|
|
| NativeDataBuilderImpl _nativeDataBuilder;
|
| - final NativeBasicDataBuilderImpl _nativeBasicDataBuilder =
|
| - new NativeBasicDataBuilderImpl();
|
| - NativeBasicDataImpl _nativeBasicData;
|
| NativeDataBuilder get nativeDataBuilder => _nativeDataBuilder;
|
| final NativeDataResolver _nativeDataResolver;
|
| OneShotInterceptorData _oneShotInterceptorData;
|
| @@ -442,8 +434,6 @@ class JavaScriptBackend {
|
| native.NativeResolutionEnqueuer _nativeResolutionEnqueuer;
|
| native.NativeCodegenEnqueuer _nativeCodegenEnqueuer;
|
|
|
| - BackendImpacts impacts;
|
| -
|
| Target _target;
|
|
|
| Tracer tracer;
|
| @@ -454,31 +444,20 @@ class JavaScriptBackend {
|
| bool useMultiSourceInfo: false,
|
| bool useNewSourceInfo: false,
|
| bool useKernel: false})
|
| - : _rti = new RuntimeTypesImpl(
|
| - compiler.frontendStrategy.elementEnvironment,
|
| - compiler.frontendStrategy.dartTypes),
|
| - optimizerHints = new OptimizerHintsForTests(
|
| + : optimizerHints = new OptimizerHintsForTests(
|
| compiler.frontendStrategy.elementEnvironment,
|
| compiler.frontendStrategy.commonElements),
|
| this.sourceInformationStrategy =
|
| compiler.backendStrategy.sourceInformationStrategy,
|
| constantCompilerTask = new JavaScriptConstantTask(compiler),
|
| - _nativeDataResolver = new NativeDataResolverImpl(compiler),
|
| - _rtiNeedBuilder =
|
| - compiler.frontendStrategy.createRuntimeTypesNeedBuilder() {
|
| + _nativeDataResolver = new NativeDataResolverImpl(compiler) {
|
| CommonElements commonElements = compiler.frontendStrategy.commonElements;
|
| _target = new JavaScriptBackendTarget(this);
|
| - impacts = new BackendImpacts(compiler.options, commonElements);
|
| _mirrorsData = compiler.frontendStrategy.createMirrorsDataBuilder();
|
| _backendUsageBuilder = new BackendUsageBuilderImpl(commonElements);
|
| _checkedModeHelpers = new CheckedModeHelpers(commonElements);
|
| emitter =
|
| new CodeEmitterTask(compiler, generateSourceMap, useStartupEmitter);
|
| -
|
| - _typeVariableResolutionAnalysis = new TypeVariableResolutionAnalysis(
|
| - compiler.frontendStrategy.elementEnvironment,
|
| - impacts,
|
| - _backendUsageBuilder);
|
| jsInteropAnalysis = new JsInteropAnalysis(this);
|
| _mirrorsResolutionAnalysis =
|
| compiler.frontendStrategy.createMirrorsResolutionAnalysis(this);
|
| @@ -524,25 +503,6 @@ class JavaScriptBackend {
|
| return _customElementsCodegenAnalysis;
|
| }
|
|
|
| - NativeBasicData get nativeBasicData {
|
| - assert(
|
| - _nativeBasicData != null,
|
| - failedAt(NO_LOCATION_SPANNABLE,
|
| - "NativeBasicData has not been computed yet."));
|
| - return _nativeBasicData;
|
| - }
|
| -
|
| - NativeBasicDataBuilder get nativeBasicDataBuilder => _nativeBasicDataBuilder;
|
| -
|
| - /// Resolution analysis for tracking reflective access to type variables.
|
| - TypeVariableResolutionAnalysis get typeVariableResolutionAnalysis {
|
| - assert(
|
| - _typeVariableCodegenAnalysis == null,
|
| - failedAt(NO_LOCATION_SPANNABLE,
|
| - "TypeVariableHandler has already been created."));
|
| - return _typeVariableResolutionAnalysis;
|
| - }
|
| -
|
| /// Codegen handler for reflective access to type variables.
|
| TypeVariableCodegenAnalysis get typeVariableCodegenAnalysis {
|
| assert(
|
| @@ -586,32 +546,26 @@ class JavaScriptBackend {
|
| return _oneShotInterceptorData;
|
| }
|
|
|
| - RuntimeTypesNeed get rtiNeed {
|
| + RuntimeTypesChecksBuilder get rtiChecksBuilder {
|
| assert(
|
| - _rtiNeed != null,
|
| + _rti != null,
|
| failedAt(NO_LOCATION_SPANNABLE,
|
| - "RuntimeTypesNeed has not been computed yet."));
|
| - return _rtiNeed;
|
| - }
|
| -
|
| - RuntimeTypesNeedBuilder get rtiNeedBuilder {
|
| + "RuntimeTypesChecksBuilder has not been created yet."));
|
| assert(
|
| - _rtiNeed == null,
|
| + !_rti.rtiChecksBuilderClosed,
|
| failedAt(NO_LOCATION_SPANNABLE,
|
| - "RuntimeTypesNeed has already been computed."));
|
| - return _rtiNeedBuilder;
|
| + "RuntimeTypesChecks has already been computed."));
|
| + return _rti;
|
| }
|
|
|
| - RuntimeTypesChecksBuilder get rtiChecksBuilder {
|
| + RuntimeTypesSubstitutions get rtiSubstitutions {
|
| assert(
|
| - !_rti.rtiChecksBuilderClosed,
|
| + _rti != null,
|
| failedAt(NO_LOCATION_SPANNABLE,
|
| - "RuntimeTypesChecks has already been computed."));
|
| + "RuntimeTypesSubstitutions has not been created yet."));
|
| return _rti;
|
| }
|
|
|
| - RuntimeTypesSubstitutions get rtiSubstitutions => _rti;
|
| -
|
| RuntimeTypesEncoder get rtiEncoder {
|
| assert(
|
| _rtiEncoder != null,
|
| @@ -726,8 +680,8 @@ class JavaScriptBackend {
|
|
|
| /// Called when the resolution queue has been closed.
|
| void onResolutionEnd() {
|
| - frontendStrategy.annotationProcesser
|
| - .processJsInteropAnnotations(nativeBasicData, nativeDataBuilder);
|
| + frontendStrategy.annotationProcesser.processJsInteropAnnotations(
|
| + frontendStrategy.nativeBasicData, nativeDataBuilder);
|
| }
|
|
|
| /// Called when the closed world from resolution has been computed.
|
| @@ -740,11 +694,6 @@ class JavaScriptBackend {
|
| }
|
| mirrorsDataBuilder.computeMembersNeededForReflection(
|
| compiler.enqueuer.resolution.worldBuilder, closedWorld);
|
| - _rtiNeed = rtiNeedBuilder.computeRuntimeTypesNeed(
|
| - compiler.enqueuer.resolution.worldBuilder,
|
| - closedWorld,
|
| - compiler.frontendStrategy.dartTypes,
|
| - enableTypeAssertions: compiler.options.enableTypeAssertions);
|
| mirrorsResolutionAnalysis.onResolutionComplete();
|
| }
|
|
|
| @@ -789,7 +738,16 @@ class JavaScriptBackend {
|
| ElementEnvironment elementEnvironment =
|
| compiler.frontendStrategy.elementEnvironment;
|
| CommonElements commonElements = compiler.frontendStrategy.commonElements;
|
| - _nativeBasicData = nativeBasicDataBuilder.close(elementEnvironment);
|
| + NativeBasicData nativeBasicData = compiler.frontendStrategy.nativeBasicData;
|
| + RuntimeTypesNeedBuilder rtiNeedBuilder =
|
| + compiler.frontendStrategy.createRuntimeTypesNeedBuilder();
|
| + BackendImpacts impacts =
|
| + new BackendImpacts(compiler.options, commonElements);
|
| + TypeVariableResolutionAnalysis typeVariableResolutionAnalysis =
|
| + new TypeVariableResolutionAnalysis(
|
| + compiler.frontendStrategy.elementEnvironment,
|
| + impacts,
|
| + _backendUsageBuilder);
|
| _nativeResolutionEnqueuer = new native.NativeResolutionEnqueuer(
|
| compiler.options,
|
| elementEnvironment,
|
| @@ -848,6 +806,8 @@ class JavaScriptBackend {
|
| _nativeDataBuilder,
|
| interceptorDataBuilder,
|
| _backendUsageBuilder,
|
| + rtiNeedBuilder,
|
| + _nativeResolutionEnqueuer,
|
| const OpenWorldStrategy()),
|
| compiler.frontendStrategy.createResolutionWorkItemBuilder(
|
| nativeBasicData, _nativeDataBuilder, impactTransformer));
|
| @@ -858,6 +818,8 @@ class JavaScriptBackend {
|
| CompilerTask task, Compiler compiler, ClosedWorld closedWorld) {
|
| ElementEnvironment elementEnvironment = closedWorld.elementEnvironment;
|
| CommonElements commonElements = closedWorld.commonElements;
|
| + BackendImpacts impacts =
|
| + new BackendImpacts(compiler.options, commonElements);
|
| _typeVariableCodegenAnalysis = new TypeVariableCodegenAnalysis(
|
| closedWorld.elementEnvironment, this, commonElements, mirrorsData);
|
| _lookupMapAnalysis = new LookupMapAnalysis(
|
| @@ -869,28 +831,31 @@ class JavaScriptBackend {
|
| lookupMapResolutionAnalysis);
|
| _mirrorsCodegenAnalysis = mirrorsResolutionAnalysis.close();
|
| _customElementsCodegenAnalysis = new CustomElementsCodegenAnalysis(
|
| - constantSystem, commonElements, elementEnvironment, nativeBasicData);
|
| + constantSystem,
|
| + commonElements,
|
| + elementEnvironment,
|
| + closedWorld.nativeData);
|
| _nativeCodegenEnqueuer = new native.NativeCodegenEnqueuer(
|
| compiler.options,
|
| elementEnvironment,
|
| commonElements,
|
| - compiler.frontendStrategy.dartTypes,
|
| + closedWorld.dartTypes,
|
| emitter,
|
| - _nativeResolutionEnqueuer,
|
| + closedWorld.liveNativeClasses,
|
| closedWorld.nativeData);
|
| return new CodegenEnqueuer(
|
| task,
|
| compiler.options,
|
| const TreeShakingEnqueuerStrategy(),
|
| compiler.backendStrategy.createCodegenWorldBuilder(
|
| - nativeBasicData, closedWorld, const TypeMaskStrategy()),
|
| + closedWorld.nativeData, closedWorld, const TypeMaskStrategy()),
|
| compiler.backendStrategy.createCodegenWorkItemBuilder(closedWorld),
|
| new CodegenEnqueuerListener(
|
| elementEnvironment,
|
| commonElements,
|
| impacts,
|
| closedWorld.backendUsage,
|
| - rtiNeed,
|
| + closedWorld.rtiNeed,
|
| customElementsCodegenAnalysis,
|
| typeVariableCodegenAnalysis,
|
| lookupMapAnalysis,
|
| @@ -938,8 +903,8 @@ class JavaScriptBackend {
|
|
|
| native.NativeEnqueuer get nativeCodegenEnqueuer => _nativeCodegenEnqueuer;
|
|
|
| - ClassElement defaultSuperclass(
|
| - CommonElements commonElements, ClassElement element) {
|
| + ClassElement defaultSuperclass(CommonElements commonElements,
|
| + NativeBasicData nativeBasicData, ClassElement element) {
|
| if (nativeBasicData.isJsInteropClass(element)) {
|
| return commonElements.jsJavaScriptObjectClass;
|
| }
|
| @@ -1026,9 +991,9 @@ class JavaScriptBackend {
|
| AnnotationProcessor processor =
|
| compiler.frontendStrategy.annotationProcesser;
|
| if (canLibraryUseNative(library)) {
|
| - processor.extractNativeAnnotations(library, nativeBasicDataBuilder);
|
| + processor.extractNativeAnnotations(library);
|
| }
|
| - processor.extractJsInteropAnnotations(library, nativeBasicDataBuilder);
|
| + processor.extractJsInteropAnnotations(library);
|
| }
|
| Uri uri = library.canonicalUri;
|
| if (uri == Uris.dart_html) {
|
| @@ -1066,6 +1031,12 @@ class JavaScriptBackend {
|
| _rtiEncoder = _namer.rtiEncoder = new RuntimeTypesEncoderImpl(
|
| namer, closedWorld.elementEnvironment, closedWorld.commonElements);
|
| emitter.createEmitter(namer, closedWorld, codegenWorldBuilder, sorter);
|
| + // TODO(johnniwinther): Share the impact object created in
|
| + // createCodegenEnqueuer.
|
| + BackendImpacts impacts =
|
| + new BackendImpacts(compiler.options, closedWorld.commonElements);
|
| + _rti = new RuntimeTypesImpl(
|
| + closedWorld.elementEnvironment, closedWorld.dartTypes);
|
| _codegenImpactTransformer = new CodegenImpactTransformer(
|
| compiler.options,
|
| closedWorld.elementEnvironment,
|
| @@ -1074,7 +1045,7 @@ class JavaScriptBackend {
|
| checkedModeHelpers,
|
| closedWorld.nativeData,
|
| closedWorld.backendUsage,
|
| - rtiNeed,
|
| + closedWorld.rtiNeed,
|
| nativeCodegenEnqueuer,
|
| namer,
|
| oneShotInterceptorData,
|
| @@ -1362,12 +1333,13 @@ class JavaScriptBackendTarget extends Target {
|
|
|
| @override
|
| ClassElement defaultSuperclass(ClassElement element) {
|
| - return _backend.defaultSuperclass(_commonElements, element);
|
| + return _backend.defaultSuperclass(
|
| + _commonElements, _backend.frontendStrategy.nativeBasicData, element);
|
| }
|
|
|
| @override
|
| bool isNativeClass(ClassEntity element) =>
|
| - _backend.nativeBasicData.isNativeClass(element);
|
| + _backend.compiler.frontendStrategy.nativeBasicData.isNativeClass(element);
|
|
|
| @override
|
| bool isForeign(Element element) =>
|
|
|