Chromium Code Reviews| Index: pkg/compiler/lib/src/ssa/builder_kernel.dart |
| diff --git a/pkg/compiler/lib/src/ssa/builder_kernel.dart b/pkg/compiler/lib/src/ssa/builder_kernel.dart |
| index 510815a424e88b96d68f91c936709882ddb80546..f411ebd7f8862eccf2e2905006a6ef7a6e4c9e7e 100644 |
| --- a/pkg/compiler/lib/src/ssa/builder_kernel.dart |
| +++ b/pkg/compiler/lib/src/ssa/builder_kernel.dart |
| @@ -443,6 +443,26 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder { |
| forInStatement, buildInitializer, buildCondition, () {}, buildBody); |
| } |
| + HInstruction callSetRuntimeTypeInfo( |
| + HInstruction typeInfo, HInstruction newObject) { |
| + // Set the runtime type information on the object. |
| + ir.Procedure typeInfoSetterFn = astAdapter.setRuntimeTypeInfo; |
| + // TODO(efortuna): Insert source information in this static invocation. |
| + _pushStaticInvocation(typeInfoSetterFn, <HInstruction>[newObject, typeInfo], |
| + backend.dynamicType); |
| + |
| + // 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(); |
| + } |
| + |
| @override |
| void visitWhileStatement(ir.WhileStatement whileStatement) { |
| assert(isReachable); |
| @@ -542,6 +562,21 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder { |
| stack.add(graph.addConstantNull(compiler)); |
| } |
| + HInstruction setRtiIfNeeded(HInstruction object, ir.ListLiteral listLiteral) { |
| + InterfaceType type = localsHandler |
| + .substInContext(elements.getType(astAdapter.getNode(listLiteral))); |
| + if (!backend.classNeedsRti(type.element) || type.treatAsRaw) { |
| + return object; |
| + } |
| + List<HInstruction> arguments = <HInstruction>[]; |
| + for (DartType argument in type.typeArguments) { |
| + arguments.add(typeBuilder.analyzeTypeArgument(argument, sourceElement)); |
| + } |
| + // TODO(15489): Register at codegen. |
| + registry?.registerInstantiation(type); |
| + return callSetRuntimeTypeInfoWithTypeArguments(type, arguments, object); |
| + } |
| + |
| @override |
| void visitListLiteral(ir.ListLiteral listLiteral) { |
| HInstruction listInstruction; |
| @@ -556,7 +591,7 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder { |
| } |
| listInstruction = new HLiteralList(elements, backend.extendableArrayType); |
| add(listInstruction); |
| - // TODO(het): set runtime type info |
| + listInstruction = setRtiIfNeeded(listInstruction, listLiteral); |
|
Harry Terkelsen
2016/11/16 17:26:47
should we 'add' it after we set rti?
Emily Fortuna
2016/11/16 18:53:23
I talked to Stephen. The answer is no; we need to
|
| } |
| TypeMask type = astAdapter.typeOfNewList(targetElement, listLiteral); |