Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Unified Diff: pkg/compiler/lib/src/ssa/builder.dart

Issue 2314703002: Split World usage into open, inference, and closed world. (Closed)
Patch Set: Updated cf. comments Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/kernel/accessors.dart ('k') | pkg/compiler/lib/src/ssa/codegen.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/ssa/builder.dart
diff --git a/pkg/compiler/lib/src/ssa/builder.dart b/pkg/compiler/lib/src/ssa/builder.dart
index 042ac75d1b569b5cdba7d3af37d1698eca6ad3dd..0269ab2ce67abee3aef9a2799da043cffaf9c87c 100644
--- a/pkg/compiler/lib/src/ssa/builder.dart
+++ b/pkg/compiler/lib/src/ssa/builder.dart
@@ -554,7 +554,7 @@ class SsaBuilder extends ast.Visitor
*/
List<HInstruction> completeDynamicSendArgumentsList(Selector selector,
FunctionElement function, List<HInstruction> providedArguments) {
- assert(selector.applies(function, compiler.world));
+ assert(selector.applies(function, compiler.closedWorld));
FunctionSignature signature = function.functionSignature;
List<HInstruction> compiledArguments = new List<HInstruction>(
signature.parameterCount + 1); // Plus one for receiver.
@@ -648,8 +648,9 @@ class SsaBuilder extends ast.Visitor
element.isGenerativeConstructorBody,
message: "Missing selector for inlining of $element."));
if (selector != null) {
- if (!selector.applies(function, compiler.world)) return false;
- if (mask != null && !mask.canHit(function, selector, compiler.world)) {
+ if (!selector.applies(function, compiler.closedWorld)) return false;
+ if (mask != null &&
+ !mask.canHit(function, selector, compiler.closedWorld)) {
return false;
}
}
@@ -894,7 +895,7 @@ class SsaBuilder extends ast.Visitor
*/
HGraph buildMethod(FunctionElement functionElement) {
assert(invariant(functionElement, functionElement.isImplementation));
- graph.calledInLoop = compiler.world.isCalledInLoop(functionElement);
+ graph.calledInLoop = compiler.closedWorld.isCalledInLoop(functionElement);
ast.FunctionExpression function = resolvedAst.node;
assert(function != null);
assert(elements.getFunctionDefinition(function) != null);
@@ -1482,8 +1483,8 @@ class SsaBuilder extends ast.Visitor
}, includeSuperAndInjectedMembers: true);
InterfaceType type = classElement.thisType;
- TypeMask ssaType =
- new TypeMask.nonNullExact(classElement.declaration, compiler.world);
+ TypeMask ssaType = new TypeMask.nonNullExact(
+ classElement.declaration, compiler.closedWorld);
List<DartType> instantiatedTypes;
addInlinedInstantiation(type);
if (!currentInlinedInstantiations.isEmpty) {
@@ -1596,7 +1597,7 @@ class SsaBuilder extends ast.Visitor
HInvokeConstructorBody invoke = new HInvokeConstructorBody(
body.declaration, bodyCallInputs, backend.nonNullType);
invoke.sideEffects =
- compiler.world.getSideEffectsOfElement(constructor);
+ compiler.closedWorld.getSideEffectsOfElement(constructor);
add(invoke);
}
}
@@ -1738,7 +1739,8 @@ class SsaBuilder extends ast.Visitor
type = type.unaliased;
assert(assertTypeInContext(type, original));
if (type.isInterfaceType && !type.treatAsRaw) {
- TypeMask subtype = new TypeMask.subtype(type.element, compiler.world);
+ TypeMask subtype =
+ new TypeMask.subtype(type.element, compiler.closedWorld);
HInstruction representations = buildTypeArgumentRepresentations(type);
add(representations);
return new HTypeConversion.withTypeRepresentation(
@@ -1779,7 +1781,7 @@ class SsaBuilder extends ast.Visitor
if (type.isObject) return original;
// The type element is either a class or the void element.
Element element = type.element;
- TypeMask mask = new TypeMask.subtype(element, compiler.world);
+ TypeMask mask = new TypeMask.subtype(element, compiler.closedWorld);
return new HTypeKnown.pinned(mask, original);
}
@@ -2424,7 +2426,7 @@ class SsaBuilder extends ast.Visitor
});
TypeMask type =
- new TypeMask.nonNullExact(closureClassElement, compiler.world);
+ new TypeMask.nonNullExact(closureClassElement, compiler.closedWorld);
push(new HCreate(closureClassElement, capturedVariables, type)
..sourceInformation = sourceInformationBuilder.buildCreate(node));
@@ -2696,7 +2698,8 @@ class SsaBuilder extends ast.Visitor
// handler in the case of lists, because the constant handler
// does not look at elements in the list.
TypeMask type = TypeMaskFactory.inferredTypeForElement(field, compiler);
- if (!type.containsAll(compiler.world) && !instruction.isConstantNull()) {
+ if (!type.containsAll(compiler.closedWorld) &&
+ !instruction.isConstantNull()) {
// TODO(13429): The inferrer should know that an element
// cannot be null.
instruction.instructionType = type.nonNullable();
@@ -3042,7 +3045,8 @@ class SsaBuilder extends ast.Visitor
add(representations);
js.Name operator = backend.namer.operatorIs(element);
HInstruction isFieldName = addConstantStringFromName(operator);
- HInstruction asFieldName = compiler.world.hasAnyStrictSubtype(element)
+ HInstruction asFieldName = compiler.closedWorld
+ .hasAnyStrictSubtype(element)
? addConstantStringFromName(backend.namer.substitutionName(element))
: graph.addConstantNull(compiler);
List<HInstruction> inputs = <HInstruction>[
@@ -3066,7 +3070,7 @@ class SsaBuilder extends ast.Visitor
}
HInstruction buildFunctionType(FunctionType type) {
- type.accept(new TypeBuilder(compiler.world), this);
+ type.accept(new TypeBuilder(compiler.closedWorld), this);
return pop();
}
@@ -3683,7 +3687,7 @@ class SsaBuilder extends ast.Visitor
// calling [makeStaticArgumentList].
Selector selector = elements.getSelector(node);
assert(invariant(
- node, selector.applies(function.implementation, compiler.world),
+ node, selector.applies(function.implementation, compiler.closedWorld),
message: "$selector does not apply to ${function.implementation}"));
List<HInstruction> inputs = makeStaticArgumentList(
selector.callStructure, node.arguments, function.implementation);
@@ -3848,10 +3852,11 @@ class SsaBuilder extends ast.Visitor
}
bool needsSubstitutionForTypeVariableAccess(ClassElement cls) {
- ClassWorld classWorld = compiler.world;
+ ClassWorld classWorld = compiler.closedWorld;
if (classWorld.isUsedAsMixin(cls)) return true;
- return compiler.world.anyStrictSubclassOf(cls, (ClassElement subclass) {
+ return compiler.closedWorld.anyStrictSubclassOf(cls,
+ (ClassElement subclass) {
return !rti.isTrivialSubstitution(subclass, cls);
});
}
@@ -4033,13 +4038,13 @@ class SsaBuilder extends ast.Visitor
isFixedList = true;
TypeMask inferred =
TypeMaskFactory.inferredForNode(sourceElement, send, compiler);
- return inferred.containsAll(compiler.world)
+ return inferred.containsAll(compiler.closedWorld)
? backend.fixedArrayType
: inferred;
} else if (isGrowableListConstructorCall) {
TypeMask inferred =
TypeMaskFactory.inferredForNode(sourceElement, send, compiler);
- return inferred.containsAll(compiler.world)
+ return inferred.containsAll(compiler.closedWorld)
? backend.extendableArrayType
: inferred;
} else if (Elements.isConstructorOfTypedArraySubclass(
@@ -4049,8 +4054,9 @@ class SsaBuilder extends ast.Visitor
TypeMaskFactory.inferredForNode(sourceElement, send, compiler);
ClassElement cls = element.enclosingClass;
assert(backend.isNative(cls.thisType.element));
- return inferred.containsAll(compiler.world)
- ? new TypeMask.nonNullExact(cls.thisType.element, compiler.world)
+ return inferred.containsAll(compiler.closedWorld)
+ ? new TypeMask.nonNullExact(
+ cls.thisType.element, compiler.closedWorld)
: inferred;
} else if (element.isGenerativeConstructor) {
ClassElement cls = element.enclosingClass;
@@ -4059,7 +4065,7 @@ class SsaBuilder extends ast.Visitor
return new TypeMask.nonNullEmpty();
} else {
return new TypeMask.nonNullExact(
- cls.thisType.element, compiler.world);
+ cls.thisType.element, compiler.closedWorld);
}
} else {
return TypeMaskFactory.inferredReturnTypeForElement(
@@ -4683,10 +4689,11 @@ class SsaBuilder extends ast.Visitor
bool isOptimizableOperationOnIndexable(Selector selector, Element element) {
bool isLength = selector.isGetter && selector.name == "length";
if (isLength || selector.isIndex) {
- return compiler.world.isSubtypeOf(
+ return compiler.closedWorld.isSubtypeOf(
element.enclosingClass.declaration, helpers.jsIndexableClass);
} else if (selector.isIndexSet) {
- return compiler.world.isSubtypeOf(element.enclosingClass.declaration,
+ return compiler.closedWorld.isSubtypeOf(
+ element.enclosingClass.declaration,
helpers.jsMutableIndexableClass);
} else {
return false;
@@ -4709,7 +4716,7 @@ class SsaBuilder extends ast.Visitor
return false;
}
- Element element = compiler.world.locateSingleElement(selector, mask);
+ Element element = compiler.closedWorld.locateSingleElement(selector, mask);
if (element != null &&
!element.isField &&
!(element.isGetter && selector.isCall) &&
@@ -4856,7 +4863,7 @@ class SsaBuilder extends ast.Visitor
typeMask =
TypeMaskFactory.inferredReturnTypeForElement(element, compiler);
}
- bool targetCanThrow = !compiler.world.getCannotThrow(element);
+ bool targetCanThrow = !compiler.closedWorld.getCannotThrow(element);
// TODO(5346): Try to avoid the need for calling [declaration] before
var instruction;
if (backend.isJsInterop(element)) {
@@ -4871,7 +4878,8 @@ class SsaBuilder extends ast.Visitor
instruction.instantiatedTypes =
new List<DartType>.from(currentInlinedInstantiations);
}
- instruction.sideEffects = compiler.world.getSideEffectsOfElement(element);
+ instruction.sideEffects =
+ compiler.closedWorld.getSideEffectsOfElement(element);
}
if (location == null) {
push(instruction);
@@ -4905,7 +4913,7 @@ class SsaBuilder extends ast.Visitor
selector, inputs, type, sourceInformation,
isSetter: selector.isSetter || selector.isIndexSet);
instruction.sideEffects =
- compiler.world.getSideEffectsOfSelector(selector, null);
+ compiler.closedWorld.getSideEffectsOfSelector(selector, null);
return instruction;
}
@@ -4935,7 +4943,7 @@ class SsaBuilder extends ast.Visitor
void generateSuperSendSet() {
Selector setterSelector = elements.getSelector(node);
if (Elements.isUnresolved(element) ||
- !setterSelector.applies(element, compiler.world)) {
+ !setterSelector.applies(element, compiler.closedWorld)) {
generateSuperNoSuchMethodSend(node, setterSelector, setterInputs);
pop();
} else {
@@ -5908,7 +5916,7 @@ class SsaBuilder extends ast.Visitor
HInstruction awaited = pop();
// TODO(herhut): Improve this type.
push(new HAwait(awaited,
- new TypeMask.subclass(coreClasses.objectClass, compiler.world)));
+ new TypeMask.subclass(coreClasses.objectClass, compiler.closedWorld)));
}
visitTypeAnnotation(ast.TypeAnnotation node) {
@@ -5969,7 +5977,8 @@ class SsaBuilder extends ast.Visitor
TypeMask type =
TypeMaskFactory.inferredForNode(sourceElement, node, compiler);
- if (!type.containsAll(compiler.world)) instruction.instructionType = type;
+ if (!type.containsAll(compiler.closedWorld))
+ instruction.instructionType = type;
stack.add(instruction);
}
@@ -6069,8 +6078,10 @@ class SsaBuilder extends ast.Visitor
TypeMask mask = elements.getMoveNextTypeMask(node);
pushInvokeDynamic(node, selector, mask, [streamIterator]);
HInstruction future = pop();
- push(new HAwait(future,
- new TypeMask.subclass(coreClasses.objectClass, compiler.world)));
+ push(new HAwait(
+ future,
+ new TypeMask.subclass(
+ coreClasses.objectClass, compiler.closedWorld)));
return popBoolified();
}
@@ -6107,8 +6118,10 @@ class SsaBuilder extends ast.Visitor
node, buildInitializer, buildCondition, buildUpdate, buildBody);
}, () {
pushInvokeDynamic(node, Selectors.cancel, null, [streamIterator]);
- push(new HAwait(pop(),
- new TypeMask.subclass(coreClasses.objectClass, compiler.world)));
+ push(new HAwait(
+ pop(),
+ new TypeMask.subclass(
+ coreClasses.objectClass, compiler.closedWorld)));
pop();
});
}
@@ -6126,7 +6139,7 @@ class SsaBuilder extends ast.Visitor
TypeMask mask = elements.getIteratorTypeMask(node);
- ClassWorld classWorld = compiler.world;
+ ClassWorld classWorld = compiler.closedWorld;
if (mask != null &&
mask.satisfies(helpers.jsIndexableClass, classWorld) &&
// String is indexable but not iterable.
@@ -6404,12 +6417,12 @@ class SsaBuilder extends ast.Visitor
// The instruction type will always be a subtype of the mapLiteralClass, but
// type inference might discover a more specific type, or find nothing (in
// dart2js unit tests).
- TypeMask mapType =
- new TypeMask.nonNullSubtype(helpers.mapLiteralClass, compiler.world);
+ TypeMask mapType = new TypeMask.nonNullSubtype(
+ helpers.mapLiteralClass, compiler.closedWorld);
TypeMask returnTypeMask =
TypeMaskFactory.inferredReturnTypeForElement(constructor, compiler);
TypeMask instructionType =
- mapType.intersection(returnTypeMask, compiler.world);
+ mapType.intersection(returnTypeMask, compiler.closedWorld);
addInlinedInstantiation(expectedType);
pushInvokeStatic(node, constructor, inputs,
@@ -7237,7 +7250,7 @@ class StringBuilderVisitor extends ast.Visitor {
Selector selector = Selectors.toString_;
TypeMask type = TypeMaskFactory.inferredTypeForSelector(
selector, expression.instructionType, compiler);
- if (type.containsOnlyString(compiler.world)) {
+ if (type.containsOnlyString(compiler.closedWorld)) {
builder.pushInvokeDynamic(node, selector, expression.instructionType,
<HInstruction>[expression]);
append(builder.pop());
« no previous file with comments | « pkg/compiler/lib/src/kernel/accessors.dart ('k') | pkg/compiler/lib/src/ssa/codegen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698