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

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

Issue 2502033002: Set runtime type information when converting list literals. (Closed)
Patch Set: . Created 4 years, 1 month 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
Index: pkg/compiler/lib/src/ssa/graph_builder.dart
diff --git a/pkg/compiler/lib/src/ssa/graph_builder.dart b/pkg/compiler/lib/src/ssa/graph_builder.dart
index 7f112300128be9a7242f31585426ada8f9e9858f..abb3169270a4723c606f2f0f37a601c2d6bb45df 100644
--- a/pkg/compiler/lib/src/ssa/graph_builder.dart
+++ b/pkg/compiler/lib/src/ssa/graph_builder.dart
@@ -215,6 +215,47 @@ abstract class GraphBuilder {
localsHandler.directLocals[local] != null;
}
+ HInstruction callSetRuntimeTypeInfoWithTypeArguments(
+ DartType type, List<HInstruction> rtiInputs, HInstruction newObject) {
+ if (!backend.classNeedsRti(type.element)) {
+ return newObject;
+ }
+
+ HInstruction typeInfo = new HTypeInfoExpression(
+ TypeInfoExpressionKind.INSTANCE,
+ (type.element as ClassElement).thisType,
+ rtiInputs,
+ backend.dynamicType);
+ add(typeInfo);
+ return callSetRuntimeTypeInfo(typeInfo, newObject);
+ }
+
+ HInstruction callSetRuntimeTypeInfo(
+ HInstruction typeInfo, HInstruction newObject) {
+ // Set the runtime type information on the object.
+ Element typeInfoSetterElement = backend.helpers.setRuntimeTypeInfo;
+ pushInvokeStatic(typeInfoSetterElement, <HInstruction>[newObject, typeInfo],
+ typeMask: backend.dynamicType,
+ sourceInformation: newObject.sourceInformation);
+
+ // The new object will now be referenced through the
+ // `setRuntimeTypeInfo` call. We therefore set the type of that
+ // instruction to be of the object's type.
+ assert(invariant(CURRENT_ELEMENT_SPANNABLE,
+ stack.last is HInvokeStatic || stack.last == newObject,
+ message: "Unexpected `stack.last`: Found ${stack.last}, "
+ "expected ${newObject} or an HInvokeStatic. "
+ "State: typeInfo=$typeInfo, stack=$stack."));
+ stack.last.instructionType = newObject.instructionType;
+ return pop();
+ }
+
+ void pushInvokeStatic(MethodElement element, List<HInstruction> arguments,
+ {TypeMask typeMask,
+ InterfaceType instanceType,
+ SourceInformation sourceInformation,
+ ast.Node location});
+
/// The element for which this SSA builder is being used.
Element get targetElement;
TypeBuilder get typeBuilder;
« pkg/compiler/lib/src/ssa/builder_kernel.dart ('K') | « pkg/compiler/lib/src/ssa/builder_kernel.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698