| Index: sdk/lib/_internal/compiler/implementation/ssa/builder.dart
|
| diff --git a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
|
| index 3202bdce2f1842838659c62b522a305d4d5f006f..75ea249b49c6987c1ba99f22171be26cb12b7ff6 100644
|
| --- a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
|
| +++ b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
|
| @@ -1646,21 +1646,24 @@ class SsaBuilder extends ResolvedVisitor {
|
| // the current type. [InterfaceType.asInstanceOf] takes care
|
| // of both.
|
| InterfaceType type = currentClass.thisType.asInstanceOf(enclosingClass);
|
| - Link<DartType> typeVariables = enclosingClass.typeVariables;
|
| - type.typeArguments.forEach((DartType argument) {
|
| - localsHandler.updateLocal(
|
| - typeVariables.head.element,
|
| - analyzeTypeArgument(argument));
|
| - typeVariables = typeVariables.tail;
|
| - });
|
| - // If the supertype is a raw type, we need to set to null the
|
| - // type variables.
|
| - assert(typeVariables.isEmpty
|
| - || enclosingClass.typeVariables == typeVariables);
|
| - while (!typeVariables.isEmpty) {
|
| - localsHandler.updateLocal(typeVariables.head.element,
|
| - graph.addConstantNull(compiler));
|
| - typeVariables = typeVariables.tail;
|
| + List<DartType> arguments = type.typeArguments;
|
| + List<DartType> typeVariables = enclosingClass.typeVariables;
|
| + if (!type.isRaw) {
|
| + assert(arguments.length == typeVariables.length);
|
| + Iterator<DartType> variables = typeVariables.iterator;
|
| + type.typeArguments.forEach((DartType argument) {
|
| + variables.moveNext();
|
| + localsHandler.updateLocal(
|
| + variables.current.element,
|
| + analyzeTypeArgument(argument));
|
| + });
|
| + } else {
|
| + // If the supertype is a raw type, we need to set to null the
|
| + // type variables.
|
| + for (DartType variable in typeVariables) {
|
| + localsHandler.updateLocal(variable.element,
|
| + graph.addConstantNull(compiler));
|
| + }
|
| }
|
| }
|
|
|
| @@ -1967,7 +1970,8 @@ class SsaBuilder extends ResolvedVisitor {
|
| bool allIndexed = true;
|
| int expectedIndex = 0;
|
| ClassElement contextClass; // The class of `this`.
|
| - Link typeVariables; // The list of 'remaining type variables' of `this`.
|
| + int remainingTypeVariables; // The number of 'remaining type variables'
|
| + // of `this`.
|
|
|
| /// Helper to identify instructions that read a type variable without
|
| /// substitution (that is, directly use the index). These instructions
|
| @@ -1993,15 +1997,15 @@ class SsaBuilder extends ResolvedVisitor {
|
| // many arguments we need to process.
|
| source = newSource;
|
| contextClass = source.sourceElement.getEnclosingClass();
|
| - typeVariables = contextClass.typeVariables;
|
| + remainingTypeVariables = contextClass.typeVariables.length;
|
| } else {
|
| assert(source == newSource);
|
| }
|
| // If there are no more type variables, then there are more type
|
| // arguments for the new object than the source has, and it can't be
|
| // a copy. Otherwise remove one argument.
|
| - if (typeVariables.isEmpty) return false;
|
| - typeVariables = typeVariables.tail;
|
| + if (remainingTypeVariables == 0) return false;
|
| + remainingTypeVariables--;
|
| // Check that the index is the one we expect.
|
| IntConstant constant = index.constant;
|
| return constant.value == expectedIndex++;
|
| @@ -2016,7 +2020,7 @@ class SsaBuilder extends ResolvedVisitor {
|
| typeArguments.add(argument);
|
| });
|
|
|
| - if (source != null && allIndexed && typeVariables.isEmpty) {
|
| + if (source != null && allIndexed && remainingTypeVariables == 0) {
|
| copyRuntimeTypeInfo(source, newObject);
|
| } else {
|
| newObject =
|
| @@ -3967,14 +3971,7 @@ class SsaBuilder extends ResolvedVisitor {
|
| generateAbstractClassInstantiationError(send, cls.name);
|
| return;
|
| }
|
| - if (backend.classNeedsRti(cls)) {
|
| - Link<DartType> typeVariable = cls.typeVariables;
|
| - expectedType.typeArguments.forEach((DartType argument) {
|
| - inputs.add(analyzeTypeArgument(argument));
|
| - typeVariable = typeVariable.tail;
|
| - });
|
| - assert(typeVariable.isEmpty);
|
| - }
|
| + potentiallyAddTypeArguments(inputs, cls, expectedType);
|
|
|
| addInlinedInstantiation(expectedType);
|
| pushInvokeStatic(node, constructor, inputs, elementType);
|
| @@ -4010,6 +4007,16 @@ class SsaBuilder extends ResolvedVisitor {
|
| }
|
| }
|
|
|
| + void potentiallyAddTypeArguments(List<HInstruction> inputs, ClassElement cls,
|
| + InterfaceType expectedType) {
|
| + if (!backend.classNeedsRti(cls)) return;
|
| + assert(expectedType.typeArguments.isEmpty ||
|
| + cls.typeVariables.length == expectedType.typeArguments.length);
|
| + expectedType.typeArguments.forEach((DartType argument) {
|
| + inputs.add(analyzeTypeArgument(argument));
|
| + });
|
| + }
|
| +
|
| /// In checked mode checks the [type] of [node] to be well-bounded. The method
|
| /// returns [:true:] if an error can be statically determined.
|
| bool checkTypeVariableBounds(ast.NewExpression node, InterfaceType type) {
|
| @@ -4692,17 +4699,8 @@ class SsaBuilder extends ResolvedVisitor {
|
| for (; i < calleeOptionals.length; i++) {
|
| inputs.add(handleConstantForOptionalParameter(calleeOptionals[i]));
|
| }
|
| -
|
| - if (backend.classNeedsRti(element.getEnclosingClass())) {
|
| - ClassElement cls = function.getEnclosingClass();
|
| - Link<DartType> typeVariable = cls.typeVariables;
|
| - InterfaceType type = elements.getType(node.expression);
|
| - type.typeArguments.forEach((DartType argument) {
|
| - inputs.add(analyzeTypeArgument(argument));
|
| - typeVariable = typeVariable.tail;
|
| - });
|
| - assert(typeVariable.isEmpty);
|
| - }
|
| + potentiallyAddTypeArguments(inputs, element.getEnclosingClass(),
|
| + elements.getType(node.expression));
|
| pushInvokeStatic(node, element, inputs);
|
| value = pop();
|
| } else if (node.expression == null) {
|
| @@ -6069,14 +6067,14 @@ class TypeBuilder implements DartTypeVisitor<dynamic, SsaBuilder> {
|
| inputs.add(builder.pop());
|
| }
|
|
|
| - Link<DartType> namedParameterTypes = type.namedParameterTypes;
|
| - for (String name in type.namedParameters) {
|
| - ast.DartString dartString = new ast.DartString.literal(name);
|
| + List<DartType> namedParameterTypes = type.namedParameterTypes;
|
| + List<String> names = type.namedParameters;
|
| + for (int index = 0; index < names.length; index++) {
|
| + ast.DartString dartString = new ast.DartString.literal(names[index]);
|
| inputs.add(
|
| builder.graph.addConstantString(dartString, builder.compiler));
|
| - namedParameterTypes.head.accept(this, builder);
|
| + namedParameterTypes[index].accept(this, builder);
|
| inputs.add(builder.pop());
|
| - namedParameterTypes = namedParameterTypes.tail;
|
| }
|
|
|
| ClassElement cls = builder.compiler.findHelper('RuntimeFunctionType');
|
|
|