| 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 1410cb06e222bc7346b9fe12ca48a3e9ee72b26a..2c1278855b7d214383b3dcd8118976fcf24f60c8 100644
|
| --- a/pkg/compiler/lib/src/js_backend/backend.dart
|
| +++ b/pkg/compiler/lib/src/js_backend/backend.dart
|
| @@ -45,6 +45,7 @@ import '../js_emitter/js_emitter.dart' show CodeEmitterTask;
|
| import '../library_loader.dart' show LibraryLoader, LoadedLibraries;
|
| import '../native/native.dart' as native;
|
| import '../ssa/ssa.dart' show SsaFunctionCompiler;
|
| +import '../tracer.dart';
|
| import '../tree/tree.dart';
|
| import '../types/types.dart';
|
| import '../universe/call_structure.dart' show CallStructure;
|
| @@ -88,7 +89,7 @@ const VERBOSE_OPTIMIZER_HINTS = false;
|
|
|
| abstract class FunctionCompiler {
|
| /// Generates JavaScript code for `work.element`.
|
| - jsAst.Fun compile(CodegenWorkItem work);
|
| + jsAst.Fun compile(CodegenWorkItem work, ClosedWorld closedWorld);
|
|
|
| Iterable get tasks;
|
| }
|
| @@ -559,6 +560,8 @@ class JavaScriptBackend extends Backend {
|
|
|
| final JSFrontendAccess frontend;
|
|
|
| + Tracer tracer;
|
| +
|
| JavaScriptBackend(Compiler compiler,
|
| {bool generateSourceMap: true,
|
| bool useStartupEmitter: false,
|
| @@ -898,8 +901,7 @@ class JavaScriptBackend extends Backend {
|
| if (elements.isEmpty) return false;
|
| return elements.any((element) {
|
| return selector.applies(element) &&
|
| - (mask == null ||
|
| - mask.canHit(element, selector, compiler.closedWorld));
|
| + (mask == null || mask.canHit(element, selector, _closedWorld));
|
| });
|
| }
|
|
|
| @@ -955,11 +957,10 @@ class JavaScriptBackend extends Backend {
|
| }
|
|
|
| Set<ClassElement> nativeSubclassesOfMixin(ClassElement mixin) {
|
| - ClosedWorld closedWorld = compiler.closedWorld;
|
| - Iterable<MixinApplicationElement> uses = closedWorld.mixinUsesOf(mixin);
|
| + Iterable<MixinApplicationElement> uses = _closedWorld.mixinUsesOf(mixin);
|
| Set<ClassElement> result = null;
|
| for (MixinApplicationElement use in uses) {
|
| - closedWorld.forEachStrictSubclassOf(use, (ClassElement subclass) {
|
| + _closedWorld.forEachStrictSubclassOf(use, (ClassElement subclass) {
|
| if (isNativeOrExtendsNative(subclass)) {
|
| if (result == null) result = new Set<ClassElement>();
|
| result.add(subclass);
|
| @@ -1499,7 +1500,7 @@ class JavaScriptBackend extends Backend {
|
| }
|
| }
|
|
|
| - jsAst.Fun function = functionCompiler.compile(work);
|
| + jsAst.Fun function = functionCompiler.compile(work, _closedWorld);
|
| if (function.sourceInformation == null) {
|
| function = function.withSourceInformation(
|
| sourceInformationStrategy.buildSourceMappedMarker());
|
| @@ -1752,7 +1753,7 @@ class JavaScriptBackend extends Backend {
|
| if (!type.isRaw) return false;
|
| ClassElement classElement = type.element;
|
| if (isInterceptorClass(classElement)) return false;
|
| - return compiler.closedWorld.hasOnlySubclasses(classElement);
|
| + return _closedWorld.hasOnlySubclasses(classElement);
|
| }
|
|
|
| WorldImpact registerUsedElement(Element element, {bool forResolution}) {
|
| @@ -2362,9 +2363,24 @@ class JavaScriptBackend extends Backend {
|
| jsInteropAnalysis.onQueueClosed();
|
| }
|
|
|
| + // TODO(johnniwinther): Create a CodegenPhase object for the backend to hold
|
| + // data only available during code generation.
|
| + ClosedWorld _closedWorldCache;
|
| + ClosedWorld get _closedWorld {
|
| + assert(invariant(NO_LOCATION_SPANNABLE, _closedWorldCache != null,
|
| + message: "ClosedWorld has not be set yet."));
|
| + return _closedWorldCache;
|
| + }
|
| +
|
| + void set _closedWorld(ClosedWorld value) {
|
| + _closedWorldCache = value;
|
| + }
|
| +
|
| WorldImpact onCodegenStart(ClosedWorld closedWorld) {
|
| - _namer = determineNamer(closedWorld);
|
| - emitter.createEmitter(_namer, closedWorld);
|
| + _closedWorld = closedWorld;
|
| + _namer = determineNamer(_closedWorld);
|
| + tracer = new Tracer(_closedWorld, namer, compiler.outputProvider);
|
| + emitter.createEmitter(_namer, _closedWorld);
|
| lookupMapAnalysis.onCodegenStart();
|
| if (hasIsolateSupport) {
|
| return enableIsolateSupport(forResolution: false);
|
| @@ -2372,6 +2388,11 @@ class JavaScriptBackend extends Backend {
|
| return const WorldImpact();
|
| }
|
|
|
| + void onCodegenEnd() {
|
| + sourceInformationStrategy.onComplete();
|
| + tracer.close();
|
| + }
|
| +
|
| /// Process backend specific annotations.
|
| void processAnnotations(
|
| Element element, ClosedWorldRefiner closedWorldRefiner) {
|
|
|