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

Unified Diff: pkg/compiler/lib/src/ssa/builder_kernel.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
« no previous file with comments | « pkg/compiler/lib/src/ssa/builder.dart ('k') | pkg/compiler/lib/src/ssa/graph_builder.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_kernel.dart
diff --git a/pkg/compiler/lib/src/ssa/builder_kernel.dart b/pkg/compiler/lib/src/ssa/builder_kernel.dart
index 510815a424e88b96d68f91c936709882ddb80546..110307ad9c6a1021b863c34ddcc23f9f56b2bfb2 100644
--- a/pkg/compiler/lib/src/ssa/builder_kernel.dart
+++ b/pkg/compiler/lib/src/ssa/builder_kernel.dart
@@ -16,6 +16,7 @@ import '../js_backend/backend.dart' show JavaScriptBackend;
import '../kernel/kernel.dart';
import '../resolution/tree_elements.dart';
import '../tree/dartstring.dart';
+import '../tree/tree.dart' as ast;
import '../types/masks.dart';
import '../universe/call_structure.dart' show CallStructure;
import '../universe/selector.dart';
@@ -28,6 +29,7 @@ import 'loop_handler.dart';
import 'nodes.dart';
import 'ssa_branch_builder.dart';
import 'type_builder.dart';
+import 'types.dart' show TypeMaskFactory;
class SsaKernelBuilderTask extends CompilerTask {
final JavaScriptBackend backend;
@@ -206,6 +208,40 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder {
Element get sourceElement => astAdapter.getElement(target);
@override
+ void pushInvokeStatic(MethodElement element, List<HInstruction> arguments,
Harry Terkelsen 2016/11/15 22:44:48 This class should not have any methods with Elemen
Emily Fortuna 2016/11/16 01:53:44 Thank you, I intended to get rid of this, but got
+ {TypeMask typeMask,
+ InterfaceType instanceType,
+ SourceInformation sourceInformation,
+ // TODO(efortuna): Leaving this part of the signature for consistency with
+ // builder.dart. Remove this parameter once we are no longer using
+ // builder.dart.
+ ast.Node location}) {
+ assert(element.isDeclaration);
+ // TODO(efortuna): try to inline method.
+
+ if (typeMask == null) {
+ typeMask =
+ TypeMaskFactory.inferredReturnTypeForElement(element, compiler);
+ }
+ bool targetCanThrow = !compiler.closedWorld.getCannotThrow(element);
+ // TODO(5346): Try to avoid the need for calling [declaration] before
Harry Terkelsen 2016/11/15 22:44:48 this TODO makes no sense to me?
Emily Fortuna 2016/11/16 01:53:44 Agreed.... it was copied from builder.dart. Is it
+ var instruction;
+ if (backend.isJsInterop(element)) {
+ // TODO(efortuna): Implement JS Introp function.
+ } else {
+ // creating an [HInvokeStatic].
+ instruction = new HInvokeStatic(element, arguments, typeMask,
+ targetCanThrow: targetCanThrow)
+ ..sourceInformation = sourceInformation;
+ // TODO(efortuna): Test if we have any inlined instantiations here.
+ instruction.sideEffects =
+ compiler.closedWorld.getSideEffectsOfElement(element);
+ }
+ // TODO(efortuna): Attach source information if available from location.
+ push(instruction);
+ }
+
+ @override
void visitBlock(ir.Block block) {
assert(!isAborted());
for (ir.Statement statement in block.statements) {
@@ -542,6 +578,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 +607,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);
}
TypeMask type = astAdapter.typeOfNewList(targetElement, listLiteral);
« no previous file with comments | « pkg/compiler/lib/src/ssa/builder.dart ('k') | pkg/compiler/lib/src/ssa/graph_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698