| Index: pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart
|
| diff --git a/pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart b/pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart
|
| index 1d7f7d815c5b114b2bc5fc8f2c0478c453343924..1ac65fc957e85328b52efeb128c5be8b8b8cdb74 100644
|
| --- a/pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart
|
| +++ b/pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart
|
| @@ -25,7 +25,7 @@ import '../universe/call_structure.dart' show CallStructure;
|
| import '../universe/selector.dart' show Selector;
|
| import '../universe/side_effects.dart' show SideEffects;
|
| import '../util/util.dart' show Setlet;
|
| -import '../world.dart' show ClosedWorld;
|
| +import '../world.dart' show ClosedWorld, ClosedWorldRefiner;
|
| import 'closure_tracer.dart';
|
| import 'debug.dart' as debug;
|
| import 'inferrer_visitor.dart' show ArgumentsTypes, TypeSystem;
|
| @@ -36,9 +36,7 @@ import 'type_graph_dump.dart';
|
| import 'type_graph_nodes.dart';
|
|
|
| class TypeInformationSystem extends TypeSystem<TypeInformation> {
|
| - final Compiler compiler;
|
| final ClosedWorld closedWorld;
|
| - final CommonMasks commonMasks;
|
|
|
| /// [ElementTypeInformation]s for elements.
|
| final Map<Element, TypeInformation> typeInformations =
|
| @@ -72,12 +70,12 @@ class TypeInformationSystem extends TypeSystem<TypeInformation> {
|
| allocatedTypes
|
| ].expand((x) => x);
|
|
|
| - TypeInformationSystem(Compiler compiler, this.commonMasks)
|
| - : this.compiler = compiler,
|
| - this.closedWorld = compiler.closedWorld {
|
| - nonNullEmptyType = getConcreteTypeFor(const TypeMask.nonNullEmpty());
|
| + TypeInformationSystem(this.closedWorld) {
|
| + nonNullEmptyType = getConcreteTypeFor(commonMasks.emptyType);
|
| }
|
|
|
| + CommonMasks get commonMasks => closedWorld.commonMasks;
|
| +
|
| /// Used to group [TypeInformation] nodes by the element that triggered their
|
| /// creation.
|
| MemberTypeInformation _currentMember = null;
|
| @@ -365,7 +363,7 @@ class TypeInformationSystem extends TypeSystem<TypeInformation> {
|
| TypeInformation allocateList(
|
| TypeInformation type, ast.Node node, Element enclosing,
|
| [TypeInformation elementType, int length]) {
|
| - ClassElement typedDataClass = compiler.commonElements.typedDataClass;
|
| + ClassElement typedDataClass = closedWorld.commonElements.typedDataClass;
|
| bool isTypedArray = typedDataClass != null &&
|
| closedWorld.isInstantiated(typedDataClass) &&
|
| type.type.satisfies(typedDataClass, closedWorld);
|
| @@ -569,7 +567,6 @@ class TypeGraphInferrerEngine
|
| <CallSiteTypeInformation>[];
|
| final WorkQueue workQueue = new WorkQueue();
|
| final Element mainElement;
|
| - final CommonMasks commonMasks;
|
| final Set<Element> analyzedElements = new Set<Element>();
|
|
|
| /// The maximum number of times we allow a node in the graph to
|
| @@ -580,14 +577,15 @@ class TypeGraphInferrerEngine
|
| int overallRefineCount = 0;
|
| int addedInGraph = 0;
|
|
|
| - TypeGraphInferrerEngine(
|
| - Compiler compiler, CommonMasks commonMasks, this.mainElement)
|
| - : commonMasks = commonMasks,
|
| - super(compiler, new TypeInformationSystem(compiler, commonMasks));
|
| + TypeGraphInferrerEngine(Compiler compiler, ClosedWorld closedWorld,
|
| + ClosedWorldRefiner closedWorldRefiner, this.mainElement)
|
| + : super(compiler, closedWorld, closedWorldRefiner,
|
| + new TypeInformationSystem(closedWorld));
|
|
|
| JavaScriptBackend get backend => compiler.backend;
|
| Annotations get annotations => backend.annotations;
|
| DiagnosticReporter get reporter => compiler.reporter;
|
| + CommonMasks get commonMasks => closedWorld.commonMasks;
|
|
|
| /**
|
| * A set of selector names that [List] implements, that we know return
|
| @@ -703,7 +701,7 @@ class TypeGraphInferrerEngine
|
| tracer.run();
|
| if (!tracer.continueAnalyzing) {
|
| elements.forEach((FunctionElement e) {
|
| - compiler.inferenceWorld.registerMightBePassedToApply(e);
|
| + closedWorldRefiner.registerMightBePassedToApply(e);
|
| if (debug.VERBOSE) print("traced closure $e as ${true} (bail)");
|
| e.functionSignature.forEachParameter((parameter) {
|
| types
|
| @@ -723,11 +721,11 @@ class TypeGraphInferrerEngine
|
| workQueue.add(info);
|
| });
|
| if (tracer.tracedType.mightBePassedToFunctionApply) {
|
| - compiler.inferenceWorld.registerMightBePassedToApply(e);
|
| + closedWorldRefiner.registerMightBePassedToApply(e);
|
| }
|
| if (debug.VERBOSE) {
|
| print("traced closure $e as "
|
| - "${compiler.inferenceWorld
|
| + "${closedWorldRefiner
|
| .getCurrentlyKnownMightBePassedToApply(e)}");
|
| }
|
| });
|
| @@ -914,13 +912,13 @@ class TypeGraphInferrerEngine
|
| allocatedCalls.forEach((info) {
|
| if (!info.inLoop) return;
|
| if (info is StaticCallSiteTypeInformation) {
|
| - compiler.inferenceWorld.addFunctionCalledInLoop(info.calledElement);
|
| + closedWorldRefiner.addFunctionCalledInLoop(info.calledElement);
|
| } else if (info.mask != null && !info.mask.containsAll(closedWorld)) {
|
| // For instance methods, we only register a selector called in a
|
| // loop if it is a typed selector, to avoid marking too many
|
| // methods as being called from within a loop. This cuts down
|
| // on the code bloat.
|
| - info.targets.forEach(compiler.inferenceWorld.addFunctionCalledInLoop);
|
| + info.targets.forEach(closedWorldRefiner.addFunctionCalledInLoop);
|
| }
|
| });
|
| }
|
| @@ -1354,14 +1352,20 @@ class TypeGraphInferrerEngine
|
| class TypeGraphInferrer implements TypesInferrer {
|
| TypeGraphInferrerEngine inferrer;
|
| final Compiler compiler;
|
| - final CommonMasks commonMasks;
|
| - TypeGraphInferrer(this.compiler, this.commonMasks);
|
| + final ClosedWorld closedWorld;
|
| + final ClosedWorldRefiner closedWorldRefiner;
|
| +
|
| + TypeGraphInferrer(this.compiler, this.closedWorld, this.closedWorldRefiner);
|
|
|
| String get name => 'Graph inferrer';
|
| +
|
| + CommonMasks get commonMasks => closedWorld.commonMasks;
|
| +
|
| TypeMask get _dynamicType => commonMasks.dynamicType;
|
|
|
| void analyzeMain(Element main) {
|
| - inferrer = new TypeGraphInferrerEngine(compiler, commonMasks, main);
|
| + inferrer = new TypeGraphInferrerEngine(
|
| + compiler, closedWorld, closedWorldRefiner, main);
|
| inferrer.runOverAllElements();
|
| }
|
|
|
|
|