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

Unified Diff: pkg/compiler/lib/src/cps_ir/type_propagation.dart

Issue 1784263002: dart2js cps: A few extra RTI optimizations. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix negation Created 4 years, 9 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/cps_ir/gvn.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/cps_ir/type_propagation.dart
diff --git a/pkg/compiler/lib/src/cps_ir/type_propagation.dart b/pkg/compiler/lib/src/cps_ir/type_propagation.dart
index f665897410b5e694f008f1bbb584d07a01a66e6e..7d422706e3c23a28817f5cc320de85eacc1a218a 100644
--- a/pkg/compiler/lib/src/cps_ir/type_propagation.dart
+++ b/pkg/compiler/lib/src/cps_ir/type_propagation.dart
@@ -2518,12 +2518,12 @@ class TransformingVisitor extends DeepRecursiveVisitor {
TypeExpression typeExpression = instance.typeInformation;
assert(typeExpression.kind == TypeExpressionKind.INSTANCE);
ClassElement context = node.variable.element.enclosingClass;
+ ClassElement createdClass = instance.classElement;
// In the general case, a substitution could generate a large type
// term. Avoid this by restricting to direct indexing.
// TODO(sra): Also include cases that require substitution but the end
// result is the same as some indexing or a simple constant type.
- if (!functionCompiler.glue.needsSubstitutionForTypeVariableAccess(
- context)) {
+ if (backend.rti.isTrivialSubstitution(createdClass, context)) {
int index = functionCompiler.glue.getTypeVariableIndex(node.variable);
if (0 <= index && index < typeExpression.argumentRefs.length) {
node.replaceUsesWith(typeExpression.argument(index));
@@ -2534,6 +2534,16 @@ class TransformingVisitor extends DeepRecursiveVisitor {
}
return null;
}
+
+ bool isNullConstant(Primitive prim) => prim is Constant && prim.value.isNull;
+
+ visitCreateInstance(CreateInstance node) {
+ Primitive typeInformation = node.typeInformation;
+ if (typeInformation is TypeExpression &&
+ typeInformation.arguments.every(isNullConstant)) {
+ node..typeInformationRef.unlink()..typeInformationRef = null;
+ }
+ }
}
/**
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/gvn.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698