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

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

Issue 2675103003: Refactor BackendHelpers to be reusageable with KernelWorldBuilder (Closed)
Patch Set: Updated cf. comments Created 3 years, 10 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/serialization/equivalence.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 2b69824ee17deda3cf6a5ba3a5a4290ab9483186..3bd4f506079785b8d9625e55d7af09cd34310be3 100644
--- a/pkg/compiler/lib/src/ssa/builder.dart
+++ b/pkg/compiler/lib/src/ssa/builder.dart
@@ -2054,7 +2054,7 @@ class SsaBuilder extends ast.Visitor
HInstruction loadIdConstant = addConstantString(loadId);
String uri = prefixElement.deferredImport.uri.toString();
HInstruction uriConstant = addConstantString(uri);
- Element helper = helpers.checkDeferredIsLoaded;
+ MethodElement helper = helpers.checkDeferredIsLoaded;
pushInvokeStatic(location, helper, [loadIdConstant, uriConstant]);
pop();
}
@@ -2425,14 +2425,14 @@ class SsaBuilder extends ast.Visitor
} else if (type.isTypeVariable) {
HInstruction runtimeType =
typeBuilder.addTypeVariableReference(type, sourceElement);
- Element helper = helpers.checkSubtypeOfRuntimeType;
+ MethodElement helper = helpers.checkSubtypeOfRuntimeType;
List<HInstruction> inputs = <HInstruction>[expression, runtimeType];
pushInvokeStatic(null, helper, inputs, typeMask: commonMasks.boolType);
HInstruction call = pop();
return new HIs.variable(type, expression, call, commonMasks.boolType);
} else if (RuntimeTypes.hasTypeArguments(type)) {
ClassElement element = type.element;
- Element helper = helpers.checkSubtype;
+ MethodElement helper = helpers.checkSubtype;
HInstruction representations =
typeBuilder.buildTypeArgumentRepresentations(type, sourceElement);
add(representations);
@@ -2696,7 +2696,7 @@ class SsaBuilder extends ast.Visitor
// Call a helper method from the isolate library. The isolate
// library uses its own isolate structure, that encapsulates
// Leg's isolate.
- Element element = helpers.currentIsolate;
+ MethodElement element = helpers.currentIsolate;
if (element == null) {
reporter.internalError(node, 'Isolate library and compiler mismatch.');
}
@@ -2890,7 +2890,7 @@ class SsaBuilder extends ast.Visitor
<HInstruction>[pop()], commonMasks.dynamicType));
} else {
// Call a helper method from the isolate library.
- Element element = helpers.callInIsolate;
+ MethodElement element = helpers.callInIsolate;
if (element == null) {
reporter.internalError(node, 'Isolate library and compiler mismatch.');
}
@@ -3040,7 +3040,7 @@ class SsaBuilder extends ast.Visitor
js.Name internalName = backend.namer.invocationName(selector);
- Element createInvocationMirror = helpers.createInvocationMirror;
+ MethodElement createInvocationMirror = helpers.createInvocationMirror;
var argumentsInstruction = buildLiteralList(arguments);
add(argumentsInstruction);
@@ -3269,7 +3269,7 @@ class SsaBuilder extends ast.Visitor
HInstruction callSetRuntimeTypeInfo(
HInstruction typeInfo, HInstruction newObject) {
// Set the runtime type information on the object.
- Element typeInfoSetterElement = helpers.setRuntimeTypeInfo;
+ MethodElement typeInfoSetterElement = helpers.setRuntimeTypeInfo;
pushInvokeStatic(
null, typeInfoSetterElement, <HInstruction>[newObject, typeInfo],
typeMask: commonMasks.dynamicType,
@@ -3291,14 +3291,15 @@ class SsaBuilder extends ast.Visitor
ast.Send send = node.send;
generateIsDeferredLoadedCheckOfSend(send);
+ ConstructorElement constructor = elements[send];
bool isFixedList = false;
bool isFixedListConstructorCall = Elements.isFixedListConstructorCall(
- elements[send], send, closedWorld.commonElements);
+ constructor, send, closedWorld.commonElements);
bool isGrowableListConstructorCall = Elements.isGrowableListConstructorCall(
- elements[send], send, closedWorld.commonElements);
+ constructor, send, closedWorld.commonElements);
TypeMask computeType(element) {
- Element originalElement = elements[send];
+ ConstructorElement originalElement = elements[send];
if (isFixedListConstructorCall ||
Elements.isFilledListConstructorCall(
originalElement, send, closedWorld.commonElements)) {
@@ -3335,7 +3336,6 @@ class SsaBuilder extends ast.Visitor
}
}
- Element constructor = elements[send];
CallStructure callStructure = elements.getSelector(send).callStructure;
ConstructorElement constructorDeclaration = constructor;
ConstructorElement constructorImplementation = constructor.implementation;
@@ -3819,15 +3819,18 @@ class SsaBuilder extends ast.Visitor
}
void generateRuntimeError(ast.Node node, String message) {
- generateError(node, message, helpers.throwRuntimeError);
+ MethodElement helper = helpers.throwRuntimeError;
+ generateError(node, message, helper);
}
void generateTypeError(ast.Node node, String message) {
- generateError(node, message, helpers.throwTypeError);
+ MethodElement helper = helpers.throwTypeError;
+ generateError(node, message, helper);
}
void generateAbstractClassInstantiationError(ast.Node node, String message) {
- generateError(node, message, helpers.throwAbstractClassInstantiationError);
+ MethodElement helper = helpers.throwAbstractClassInstantiationError;
+ generateError(node, message, helper);
}
void generateThrowNoSuchMethod(ast.Node diagnosticNode, String methodName,
@@ -3835,7 +3838,7 @@ class SsaBuilder extends ast.Visitor
List<HInstruction> argumentValues,
List<String> existingArguments,
SourceInformation sourceInformation}) {
- Element helper = helpers.throwNoSuchMethod;
+ MethodElement helper = helpers.throwNoSuchMethod;
ConstantValue receiverConstant =
constantSystem.createString(new ast.DartString.empty());
HInstruction receiver = graph.addConstant(receiverConstant, closedWorld);
@@ -4087,8 +4090,8 @@ class SsaBuilder extends ast.Visitor
if (!compiler.options.trustJSInteropTypeAnnotations ||
type.isObject ||
type.isDynamic) {
- nativeBehavior.typesInstantiated
- .add(backend.helpers.jsJavaScriptObjectClass.thisType);
+ ClassElement cls = backend.helpers.jsJavaScriptObjectClass;
+ nativeBehavior.typesInstantiated.add(cls.thisType);
}
String code;
@@ -4166,9 +4169,11 @@ class SsaBuilder extends ast.Visitor
if (!element.isGetter && selector.isGetter) {
type = TypeMaskFactory.inferredTypeForElement(
element, globalInferenceResults);
- } else {
+ } else if (element.isFunction) {
type = TypeMaskFactory.inferredReturnTypeForElement(
element, globalInferenceResults);
+ } else {
+ type = closedWorld.commonMasks.dynamicType;
}
HInstruction instruction = new HInvokeSuper(element, currentNonClosureClass,
selector, inputs, type, sourceInformation,
@@ -5330,8 +5335,9 @@ class SsaBuilder extends ast.Visitor
visit(node.expression);
HInstruction expression = pop();
- pushInvokeStatic(node, helpers.streamIteratorConstructor,
- [expression, graph.addConstantNull(closedWorld)]);
+ ConstructorElement constructor = helpers.streamIteratorConstructor;
+ pushInvokeStatic(
+ node, constructor, [expression, graph.addConstantNull(closedWorld)]);
streamIterator = pop();
void buildInitializer() {}
@@ -5624,30 +5630,31 @@ class SsaBuilder extends ast.Visitor
listInputs.add(pop());
}
- Element constructor;
+ ConstructorElement listConstructor;
List<HInstruction> inputs = <HInstruction>[];
if (listInputs.isEmpty) {
- constructor = helpers.mapLiteralConstructorEmpty;
+ listConstructor = helpers.mapLiteralConstructorEmpty;
} else {
- constructor = helpers.mapLiteralConstructor;
+ listConstructor = helpers.mapLiteralConstructor;
HLiteralList keyValuePairs = buildLiteralList(listInputs);
add(keyValuePairs);
inputs.add(keyValuePairs);
}
- assert(constructor.isFactoryConstructor);
+ assert(listConstructor.isFactoryConstructor);
- ConstructorElement functionElement = constructor;
- constructor = functionElement.effectiveTarget;
+ ConstructorElement constructorElement = listConstructor;
+ listConstructor = constructorElement.effectiveTarget;
ResolutionInterfaceType type = elements.getType(node);
ResolutionInterfaceType expectedType =
- functionElement.computeEffectiveTargetType(type);
+ constructorElement.computeEffectiveTargetType(type);
expectedType = localsHandler.substInContext(expectedType);
- ClassElement cls = constructor.enclosingClass;
+ ClassElement cls = listConstructor.enclosingClass;
+ MethodElement createFunction = listConstructor;
if (backend.classNeedsRti(cls)) {
List<HInstruction> typeInputs = <HInstruction>[];
expectedType.typeArguments.forEach((ResolutionDartType argument) {
@@ -5659,9 +5666,9 @@ class SsaBuilder extends ast.Visitor
// in the output.
if (typeInputs.every((HInstruction input) => input.isNull())) {
if (listInputs.isEmpty) {
- constructor = helpers.mapLiteralUntypedEmptyMaker;
+ createFunction = helpers.mapLiteralUntypedEmptyMaker;
} else {
- constructor = helpers.mapLiteralUntypedMaker;
+ createFunction = helpers.mapLiteralUntypedMaker;
}
} else {
inputs.addAll(typeInputs);
@@ -5671,7 +5678,8 @@ class SsaBuilder extends ast.Visitor
// If rti is needed and the map literal has no type parameters,
// 'constructor' is a static function that forwards the call to the factory
// constructor without type parameters.
- assert(constructor is ConstructorElement || constructor is FunctionElement);
+ assert(createFunction is ConstructorElement ||
+ createFunction is FunctionElement);
// The instruction type will always be a subtype of the mapLiteralClass, but
// type inference might discover a more specific type, or find nothing (in
@@ -5679,12 +5687,12 @@ class SsaBuilder extends ast.Visitor
TypeMask mapType =
new TypeMask.nonNullSubtype(helpers.mapLiteralClass, closedWorld);
TypeMask returnTypeMask = TypeMaskFactory.inferredReturnTypeForElement(
- constructor, globalInferenceResults);
+ createFunction, globalInferenceResults);
TypeMask instructionType =
mapType.intersection(returnTypeMask, closedWorld);
addInlinedInstantiation(expectedType);
- pushInvokeStatic(node, constructor, inputs,
+ pushInvokeStatic(node, createFunction, inputs,
typeMask: instructionType, instanceType: expectedType);
removeInlinedInstantiation(expectedType);
}
« no previous file with comments | « pkg/compiler/lib/src/serialization/equivalence.dart ('k') | pkg/compiler/lib/src/ssa/codegen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698