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

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

Issue 1584543002: dart2js cps: Support inlining constructors with type arguments. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Update status files and unit tests Created 4 years, 11 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/cps_ir_tracer.dart ('k') | pkg/compiler/lib/src/cps_ir/scalar_replacement.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/cps_ir/inline.dart
diff --git a/pkg/compiler/lib/src/cps_ir/inline.dart b/pkg/compiler/lib/src/cps_ir/inline.dart
index cc046eec2c56c6588041c26cee5f3c652ae5b072..024baf2bd1866896640e95d70320643bc7173ab4 100644
--- a/pkg/compiler/lib/src/cps_ir/inline.dart
+++ b/pkg/compiler/lib/src/cps_ir/inline.dart
@@ -128,13 +128,14 @@ class InliningCache {
/// lookup result returns [NO_INLINE]. If there is no cached result,
/// [ABSENT] is returned.
get(ExecutableElement element, CallStructure callStructure, TypeMask receiver,
- List<TypeMask> arguments) {
+ List<TypeMask> arguments, DartType concreteType) {
List<CacheEntry> entries = map[element];
if (entries != null) {
for (CacheEntry entry in entries) {
if (entry.match(callStructure, receiver, arguments)) {
if (entry.decision) {
- FunctionDefinition function = copier.copy(entry.function);
+ FunctionDefinition function = copier.copy(entry.function,
+ concreteType: concreteType);
ParentVisitor.setParents(function);
return function;
}
@@ -359,7 +360,8 @@ class InliningVisitor extends TrampolineRecursiveVisitor {
// if the call was inlined, and the inlined function body is available in
// [_fragment]. If the call was not inlined, null is returned.
Primitive tryInlining(InvocationPrimitive invoke, FunctionElement target,
- CallStructure callStructure) {
+ CallStructure callStructure,
+ {GenericType concreteType}) {
// Quick checks: do not inline or even cache calls to targets without an
// AST node, targets that are asynchronous or generator functions, or
// targets containing a try statement.
@@ -386,7 +388,8 @@ class InliningVisitor extends TrampolineRecursiveVisitor {
invoke.arguments.map(abstractType).toList();
var cachedResult = _inliner.cache.get(target, callStructure,
abstractReceiverInMethod,
- abstractArguments);
+ abstractArguments,
+ concreteType);
// Negative inlining result in the cache.
if (cachedResult == InliningCache.NO_INLINE) return null;
@@ -523,14 +526,6 @@ class InliningVisitor extends TrampolineRecursiveVisitor {
@override
Primitive visitInvokeConstructor(InvokeConstructor node) {
- if (node.dartType is GenericType) {
- // We cannot inline a constructor invocation containing type arguments
- // because CreateInstance in the body does not know the type arguments.
- // We would incorrectly instantiate a class like A instead of A<B>.
- // TODO(kmillikin): try to fix this.
- GenericType generic = node.dartType;
- if (generic.typeArguments.any((DartType t) => !t.isDynamic)) return null;
- }
- return tryInlining(node, node.target, null);
+ return tryInlining(node, node.target, null, concreteType: node.dartType);
}
}
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/cps_ir_tracer.dart ('k') | pkg/compiler/lib/src/cps_ir/scalar_replacement.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698