Index: pkg/compiler/lib/src/ssa/builder.dart |
diff --git a/pkg/compiler/lib/src/ssa/builder.dart b/pkg/compiler/lib/src/ssa/builder.dart |
index 77025b0cc96e44c2c2224bc462b7a3d62b9d76ad..a9fb15cf09c86aa17a2398e0bc53663a1b74d155 100644 |
--- a/pkg/compiler/lib/src/ssa/builder.dart |
+++ b/pkg/compiler/lib/src/ssa/builder.dart |
@@ -2292,39 +2292,7 @@ class SsaBuilder extends ast.Visitor |
} |
}, includeSuperAndInjectedMembers: true); |
- InterfaceType type = classElement.thisType; |
- TypeMask ssaType = |
- new TypeMask.nonNullExact(classElement.declaration, compiler.world); |
- List<DartType> instantiatedTypes; |
- addInlinedInstantiation(type); |
- if (!currentInlinedInstantiations.isEmpty) { |
- instantiatedTypes = new List<DartType>.from(currentInlinedInstantiations); |
- } |
- HInstruction newObject; |
- if (!isNativeUpgradeFactory) { |
- newObject = new HForeignNew( |
- classElement, ssaType, constructorArguments, instantiatedTypes); |
- if (function != null) { |
- // TODO(johnniwinther): Provide source information for creation |
- // through synthetic constructors. |
- newObject.sourceInformation = |
- sourceInformationBuilder.buildCreate(function); |
- } |
- add(newObject); |
- } else { |
- // Bulk assign to the initialized fields. |
- newObject = graph.explicitReceiverParameter; |
- // Null guard ensures an error if we are being called from an explicit |
- // 'new' of the constructor instead of via an upgrade. It is optimized out |
- // if there are field initializers. |
- add(new HFieldGet(null, newObject, backend.dynamicType, |
- isAssignable: false)); |
- for (int i = 0; i < fields.length; i++) { |
- add(new HFieldSet(fields[i], newObject, constructorArguments[i])); |
- } |
- } |
- removeInlinedInstantiation(type); |
// Create the runtime type information, if needed. |
if (backend.classNeedsRti(classElement)) { |
// Read the values of the type arguments and create a list to set on the |
@@ -2391,13 +2359,56 @@ class SsaBuilder extends ast.Visitor |
}); |
if (source != null && allIndexed && remainingTypeVariables == 0) { |
- copyRuntimeTypeInfo(source, newObject); |
+ // TODO(sra): Make this an instruction. |
+ js.Template code = js.js.parseForeignJS(r'#.$ti'); |
+ HInstruction typeInfo = new HForeignCode( |
+ code, backend.stringType, |
+ <HInstruction>[source], |
+ nativeBehavior: native.NativeBehavior.PURE); |
+ add(typeInfo); |
+ constructorArguments.add(typeInfo); |
} else { |
- newObject = |
- callSetRuntimeTypeInfo(classElement, typeArguments, newObject); |
+ HInstruction typeInfo = buildLiteralList(typeArguments); |
+ add(typeInfo); |
+ constructorArguments.add(typeInfo); |
} |
} |
+ InterfaceType type = classElement.thisType; |
Siggi Cherem (dart-lang)
2016/08/19 16:39:46
just to make sure I didn't miss anything: this cod
sra1
2017/02/23 23:46:41
Yes. Since the type arguments are now a parameter,
|
+ TypeMask ssaType = |
+ new TypeMask.nonNullExact(classElement.declaration, compiler.world); |
+ List<DartType> instantiatedTypes; |
+ addInlinedInstantiation(type); |
+ if (!currentInlinedInstantiations.isEmpty) { |
+ instantiatedTypes = new List<DartType>.from(currentInlinedInstantiations); |
+ } |
+ |
+ HInstruction newObject; |
+ if (!isNativeUpgradeFactory) { |
+ newObject = new HForeignNew( |
+ classElement, ssaType, constructorArguments, instantiatedTypes); |
+ if (function != null) { |
+ // TODO(johnniwinther): Provide source information for creation |
+ // through synthetic constructors. |
+ newObject.sourceInformation = |
+ sourceInformationBuilder.buildCreate(function); |
+ } |
+ add(newObject); |
+ } else { |
+ // Bulk assign to the initialized fields. |
+ newObject = graph.explicitReceiverParameter; |
+ // Null guard ensures an error if we are being called from an explicit |
+ // 'new' of the constructor instead of via an upgrade. It is optimized out |
+ // if there are field initializers. |
+ add(new HFieldGet(null, newObject, backend.dynamicType, |
+ isAssignable: false)); |
+ for (int i = 0; i < fields.length; i++) { |
+ add(new HFieldSet(fields[i], newObject, constructorArguments[i])); |
+ } |
+ } |
+ removeInlinedInstantiation(type); |
+ |
+ |
// Generate calls to the constructor bodies. |
HInstruction interceptor = null; |
for (int index = constructorResolvedAsts.length - 1; index >= 0; index--) { |
@@ -4856,7 +4867,7 @@ class SsaBuilder extends ast.Visitor |
HInstruction callSetRuntimeTypeInfo(ClassElement element, |
List<HInstruction> rtiInputs, HInstruction newObject) { |
- if (!backend.classNeedsRti(element) || element.typeVariables.isEmpty) { |
+ if (!backend.classNeedsRti(element)) { |
return newObject; |
} |
@@ -5103,8 +5114,7 @@ class SsaBuilder extends ast.Visitor |
List<HInstruction> inputs, ClassElement cls, InterfaceType expectedType, |
{SourceInformation sourceInformation}) { |
if (!backend.classNeedsRti(cls)) return; |
- assert(expectedType.typeArguments.isEmpty || |
- cls.typeVariables.length == expectedType.typeArguments.length); |
+ assert(cls.typeVariables.length == expectedType.typeArguments.length); |
expectedType.typeArguments.forEach((DartType argument) { |
inputs.add( |
analyzeTypeArgument(argument, sourceInformation: sourceInformation)); |