| Index: sdk/lib/_internal/compiler/implementation/ir/ir_builder.dart
|
| diff --git a/sdk/lib/_internal/compiler/implementation/ir/ir_builder.dart b/sdk/lib/_internal/compiler/implementation/ir/ir_builder.dart
|
| index 984df98062135fb66a56e7bebfc2d5b2864d882e..e2ff907743493aa7c668ba90b1883d57ddbbc3c5 100644
|
| --- a/sdk/lib/_internal/compiler/implementation/ir/ir_builder.dart
|
| +++ b/sdk/lib/_internal/compiler/implementation/ir/ir_builder.dart
|
| @@ -191,6 +191,7 @@ class IrBuilder extends ResolvedVisitor<ir.Primitive> {
|
| // used to determine if a join-point continuation needs to be passed
|
| // arguments, and what the arguments are.
|
| final Map<Element, int> variableIndex;
|
| + final List<Element> index2variable;
|
| final List<ir.Parameter> freeVars;
|
| final List<ir.Primitive> assignedVars;
|
|
|
| @@ -201,6 +202,7 @@ class IrBuilder extends ResolvedVisitor<ir.Primitive> {
|
| variableIndex = <Element, int>{},
|
| freeVars = null,
|
| assignedVars = <ir.Primitive>[],
|
| + index2variable = <Element>[],
|
| super(elements, compiler);
|
|
|
| /// Construct a delimited visitor.
|
| @@ -214,6 +216,7 @@ class IrBuilder extends ResolvedVisitor<ir.Primitive> {
|
| growable: false),
|
| assignedVars = new List<ir.Primitive>.generate(
|
| parent.assignedVars.length, (_) => null),
|
| + index2variable = new List<Element>.from(parent.index2variable),
|
| super(parent.elements, parent.compiler);
|
|
|
| /**
|
| @@ -240,6 +243,7 @@ class IrBuilder extends ResolvedVisitor<ir.Primitive> {
|
| parameters.add(parameter);
|
| variableIndex[parameterElement] = assignedVars.length;
|
| assignedVars.add(parameter);
|
| + index2variable.add(parameterElement);
|
| });
|
|
|
| visit(function.body);
|
| @@ -345,7 +349,7 @@ class IrBuilder extends ResolvedVisitor<ir.Primitive> {
|
| // left and right subterms we will still have a join continuation with
|
| // possibly arguments passed to it. Such singly-used continuations
|
| // are eliminated by the shrinking conversions.
|
| - parameters.add(new ir.Parameter(null));
|
| + parameters.add(new ir.Parameter(index2variable[i]));
|
| ir.Primitive reachingDefinition =
|
| assignedVars[i] == null ? freeVars[i] : assignedVars[i];
|
| leftArguments.add(
|
| @@ -395,7 +399,7 @@ class IrBuilder extends ResolvedVisitor<ir.Primitive> {
|
| // If not, no value needs to be passed to the join point.
|
| if (reachingAssignment == null) continue;
|
|
|
| - parameters.add(new ir.Parameter(null));
|
| + parameters.add(new ir.Parameter(index2variable[i]));
|
| ir.Definition entryAssignment = assignedVars[i];
|
| entryArguments.add(
|
| entryAssignment == null ? freeVars[i] : entryAssignment);
|
| @@ -628,16 +632,22 @@ class IrBuilder extends ResolvedVisitor<ir.Primitive> {
|
| assert(!definition.arguments.isEmpty);
|
| assert(definition.arguments.tail.isEmpty);
|
| ir.Primitive initialValue = visit(definition.arguments.head);
|
| + // If a temporary was introduced for the initializer expression,
|
| + // do not use a separate variable for it.
|
| + useElementForVariable(initialValue, element);
|
| variableIndex[element] = assignedVars.length;
|
| assignedVars.add(initialValue);
|
| + index2variable.add(element);
|
| } else {
|
| assert(definition is ast.Identifier);
|
| // The initial value is null.
|
| // TODO(kmillikin): Consider pooling constants.
|
| ir.Constant constant = new ir.Constant(constantSystem.createNull());
|
| + useElementForVariable(constant, element);
|
| add(new ir.LetPrim(constant));
|
| variableIndex[element] = assignedVars.length;
|
| assignedVars.add(constant);
|
| + index2variable.add(element);
|
| }
|
| }
|
| return null;
|
| @@ -1084,6 +1094,7 @@ class IrBuilder extends ResolvedVisitor<ir.Primitive> {
|
| assert(!node.arguments.isEmpty);
|
| assert(node.arguments.tail.isEmpty);
|
| ir.Primitive result = visit(node.arguments.head);
|
| + useElementForVariable(result, element);
|
| assignedVars[variableIndex[element]] = result;
|
| return result;
|
| } else if (Elements.isStaticOrTopLevel(element)) {
|
| @@ -1164,6 +1175,16 @@ class IrBuilder extends ResolvedVisitor<ir.Primitive> {
|
| return v;
|
| }
|
|
|
| + /// Associates [primitive] with the given [element].
|
| + /// This is used as a hint when choosing variables names later when
|
| + /// translating out of the IR again.
|
| + void useElementForVariable(ir.Primitive primitive, Element element) {
|
| + // Use the first assigned element
|
| + if (primitive.element != null) return;
|
| +
|
| + primitive.element = element;
|
| + }
|
| +
|
| static final String ABORT_IRNODE_BUILDER = "IrNode builder aborted";
|
|
|
| ir.Primitive giveup() => throw ABORT_IRNODE_BUILDER;
|
| @@ -1214,6 +1235,8 @@ class SupportedTypeVerifier extends DartTypeVisitor<bool, Null> {
|
|
|
| bool visitType(DartType type, Null _) => false;
|
|
|
| + bool visitDynamicType(DynamicType type, Null _) => true;
|
| +
|
| bool visitVoidType(VoidType type, Null _) => true;
|
|
|
| // Currently, InterfaceType and TypedefType are supported so long as they
|
|
|