| Index: pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart
|
| diff --git a/pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart b/pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart
|
| index 0a6984b2c272ea8764a6b7d9fda55b66dd1c1f6d..5c9da0f5390f60913e6effbc266e70271eabcffa 100644
|
| --- a/pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart
|
| +++ b/pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart
|
| @@ -397,7 +397,7 @@ abstract class IrBuilder {
|
| ir.Parameter v = new ir.Parameter(null);
|
| ir.Continuation k = new ir.Continuation([v]);
|
| ir.Expression expression = build(k);
|
| - add(new ir.LetCont(<ir.Continuation>[k], expression));
|
| + add(new ir.LetCont(k, expression));
|
| return v;
|
| }
|
|
|
| @@ -541,15 +541,16 @@ abstract class IrBuilder {
|
| ir.Continuation elseContinuation = new ir.Continuation([]);
|
| thenContinuation.body = thenBuilder._root;
|
| elseContinuation.body = elseBuilder._root;
|
| - add(new ir.LetCont(<ir.Continuation>[joinContinuation],
|
| - new ir.LetCont(<ir.Continuation>[thenContinuation,
|
| - elseContinuation],
|
| - new ir.Branch(new ir.IsTrue(condition),
|
| - thenContinuation,
|
| - elseContinuation))));
|
| + add(new ir.LetCont(joinContinuation,
|
| + new ir.LetCont(thenContinuation,
|
| + new ir.LetCont(elseContinuation,
|
| + new ir.Branch(new ir.IsTrue(condition),
|
| + thenContinuation,
|
| + elseContinuation)))));
|
| return (thenValue == elseValue)
|
| ? thenValue
|
| : joinContinuation.parameters.last;
|
| +
|
| }
|
|
|
| /**
|
| @@ -792,19 +793,13 @@ abstract class IrBuilder {
|
| // if condition (then, else)
|
| ir.Continuation thenContinuation = new ir.Continuation([]);
|
| ir.Continuation elseContinuation = new ir.Continuation([]);
|
| - // If exactly one of the then and else continuation bodies is open (i.e.,
|
| - // the other one has an exit on all paths), then Continuation.plug expects
|
| - // that continuation to be listed first. Arbitrarily use [then, else]
|
| - // order otherwise.
|
| - List<ir.Continuation> arms = !thenBuilder.isOpen && elseBuilder.isOpen
|
| - ? <ir.Continuation>[elseContinuation, thenContinuation]
|
| - : <ir.Continuation>[thenContinuation, elseContinuation];
|
| -
|
| - ir.Expression result =
|
| - new ir.LetCont(arms,
|
| - new ir.Branch(new ir.IsTrue(condition),
|
| - thenContinuation,
|
| - elseContinuation));
|
| + ir.Expression letElse =
|
| + new ir.LetCont(elseContinuation,
|
| + new ir.Branch(new ir.IsTrue(condition),
|
| + thenContinuation,
|
| + elseContinuation));
|
| + ir.Expression letThen = new ir.LetCont(thenContinuation, letElse);
|
| + ir.Expression result = letThen;
|
|
|
| ir.Continuation joinContinuation; // Null if there is no join.
|
| if (thenBuilder.isOpen && elseBuilder.isOpen) {
|
| @@ -815,7 +810,7 @@ abstract class IrBuilder {
|
| jumps.addJump(thenBuilder);
|
| jumps.addJump(elseBuilder);
|
| joinContinuation = createJoin(environment.length, jumps);
|
| - result = new ir.LetCont(<ir.Continuation>[joinContinuation], result);
|
| + result = new ir.LetCont(joinContinuation, result);
|
| }
|
|
|
| // The then or else term root could be null, but not both. If there is
|
| @@ -832,10 +827,12 @@ abstract class IrBuilder {
|
| if (joinContinuation == null) {
|
| // At least one subexpression is closed.
|
| if (thenBuilder.isOpen) {
|
| - if (thenBuilder._root != null) _current = thenBuilder._current;
|
| + _current =
|
| + (thenBuilder._root == null) ? letThen : thenBuilder._current;
|
| environment = thenBuilder.environment;
|
| } else if (elseBuilder.isOpen) {
|
| - if (elseBuilder._root != null) _current = elseBuilder._current;
|
| + _current =
|
| + (elseBuilder._root == null) ? letElse : elseBuilder._current;
|
| environment = elseBuilder.environment;
|
| } else {
|
| _current = null;
|
| @@ -961,13 +958,12 @@ abstract class IrBuilder {
|
| // Create body entry and loop exit continuations and a branch to them.
|
| ir.Continuation bodyContinuation = new ir.Continuation([]);
|
| ir.Continuation exitContinuation = new ir.Continuation([]);
|
| - // Note the order of continuations: the first one is the one that will
|
| - // be filled by LetCont.plug.
|
| ir.LetCont branch =
|
| - new ir.LetCont(<ir.Continuation>[exitContinuation, bodyContinuation],
|
| - new ir.Branch(new ir.IsTrue(condition),
|
| - bodyContinuation,
|
| - exitContinuation));
|
| + new ir.LetCont(exitContinuation,
|
| + new ir.LetCont(bodyContinuation,
|
| + new ir.Branch(new ir.IsTrue(condition),
|
| + bodyContinuation,
|
| + exitContinuation)));
|
| // If there are breaks in the body, then there must be a join-point
|
| // continuation for the normal exit and the breaks.
|
| bool hasBreaks = !breakCollector.isEmpty;
|
| @@ -1000,22 +996,20 @@ abstract class IrBuilder {
|
| if (hasContinues) {
|
| continueContinuation.body = updateBuilder._root;
|
| bodyContinuation.body =
|
| - new ir.LetCont(<ir.Continuation>[continueContinuation],
|
| - bodyBuilder._root);
|
| + new ir.LetCont(continueContinuation, bodyBuilder._root);
|
| } else {
|
| bodyContinuation.body = bodyBuilder._root;
|
| }
|
|
|
| loopContinuation.body = condBuilder._root;
|
| - add(new ir.LetCont(<ir.Continuation>[loopContinuation],
|
| + add(new ir.LetCont(loopContinuation,
|
| new ir.InvokeContinuation(loopContinuation,
|
| environment.index2value)));
|
| if (hasBreaks) {
|
| _current = branch;
|
| environment = condBuilder.environment;
|
| breakCollector.addJump(this);
|
| - letJoin.continuations =
|
| - <ir.Continuation>[createJoin(environment.length, breakCollector)];
|
| + letJoin.continuation = createJoin(environment.length, breakCollector);
|
| _current = letJoin;
|
| } else {
|
| _current = condBuilder._current;
|
| @@ -1066,14 +1060,14 @@ abstract class IrBuilder {
|
|
|
| ir.Parameter iterator = new ir.Parameter(null);
|
| ir.Continuation iteratorInvoked = new ir.Continuation([iterator]);
|
| - add(new ir.LetCont(<ir.Continuation>[iteratorInvoked],
|
| + add(new ir.LetCont(iteratorInvoked,
|
| new ir.InvokeMethod(expressionReceiver,
|
| new Selector.getter("iterator", null), iteratorInvoked,
|
| emptyArguments)));
|
|
|
| ir.Parameter condition = new ir.Parameter(null);
|
| ir.Continuation moveNextInvoked = new ir.Continuation([condition]);
|
| - condBuilder.add(new ir.LetCont(<ir.Continuation>[moveNextInvoked],
|
| + condBuilder.add(new ir.LetCont(moveNextInvoked,
|
| new ir.InvokeMethod(iterator,
|
| new Selector.call("moveNext", null, 0),
|
| moveNextInvoked, emptyArguments)));
|
| @@ -1091,7 +1085,7 @@ abstract class IrBuilder {
|
|
|
| ir.Parameter currentValue = new ir.Parameter(null);
|
| ir.Continuation currentInvoked = new ir.Continuation([currentValue]);
|
| - bodyBuilder.add(new ir.LetCont(<ir.Continuation>[currentInvoked],
|
| + bodyBuilder.add(new ir.LetCont(currentInvoked,
|
| new ir.InvokeMethod(iterator, new Selector.getter("current", null),
|
| currentInvoked, emptyArguments)));
|
| if (Elements.isLocal(variableElement)) {
|
| @@ -1113,13 +1107,12 @@ abstract class IrBuilder {
|
| // Create body entry and loop exit continuations and a branch to them.
|
| ir.Continuation bodyContinuation = new ir.Continuation([]);
|
| ir.Continuation exitContinuation = new ir.Continuation([]);
|
| - // Note the order of continuations: the first one is the one that will
|
| - // be filled by LetCont.plug.
|
| ir.LetCont branch =
|
| - new ir.LetCont(<ir.Continuation>[exitContinuation, bodyContinuation],
|
| - new ir.Branch(new ir.IsTrue(condition),
|
| - bodyContinuation,
|
| - exitContinuation));
|
| + new ir.LetCont(exitContinuation,
|
| + new ir.LetCont(bodyContinuation,
|
| + new ir.Branch(new ir.IsTrue(condition),
|
| + bodyContinuation,
|
| + exitContinuation)));
|
| // If there are breaks in the body, then there must be a join-point
|
| // continuation for the normal exit and the breaks.
|
| bool hasBreaks = !breakCollector.isEmpty;
|
| @@ -1139,15 +1132,14 @@ abstract class IrBuilder {
|
| bodyContinuation.body = bodyBuilder._root;
|
|
|
| loopContinuation.body = condBuilder._root;
|
| - add(new ir.LetCont(<ir.Continuation>[loopContinuation],
|
| + add(new ir.LetCont(loopContinuation,
|
| new ir.InvokeContinuation(loopContinuation,
|
| environment.index2value)));
|
| if (hasBreaks) {
|
| _current = branch;
|
| environment = condBuilder.environment;
|
| breakCollector.addJump(this);
|
| - letJoin.continuations =
|
| - <ir.Continuation>[createJoin(environment.length, breakCollector)];
|
| + letJoin.continuation = createJoin(environment.length, breakCollector);
|
| _current = letJoin;
|
| } else {
|
| _current = condBuilder._current;
|
| @@ -1201,13 +1193,12 @@ abstract class IrBuilder {
|
| // Create body entry and loop exit continuations and a branch to them.
|
| ir.Continuation bodyContinuation = new ir.Continuation([]);
|
| ir.Continuation exitContinuation = new ir.Continuation([]);
|
| - // Note the order of continuations: the first one is the one that will
|
| - // be filled by LetCont.plug.
|
| ir.LetCont branch =
|
| - new ir.LetCont(<ir.Continuation>[exitContinuation, bodyContinuation],
|
| - new ir.Branch(new ir.IsTrue(condition),
|
| - bodyContinuation,
|
| - exitContinuation));
|
| + new ir.LetCont(exitContinuation,
|
| + new ir.LetCont(bodyContinuation,
|
| + new ir.Branch(new ir.IsTrue(condition),
|
| + bodyContinuation,
|
| + exitContinuation)));
|
| // If there are breaks in the body, then there must be a join-point
|
| // continuation for the normal exit and the breaks.
|
| bool hasBreaks = !breakCollector.isEmpty;
|
| @@ -1226,15 +1217,14 @@ abstract class IrBuilder {
|
| bodyContinuation.body = bodyBuilder._root;
|
|
|
| loopContinuation.body = condBuilder._root;
|
| - add(new ir.LetCont(<ir.Continuation>[loopContinuation],
|
| + add(new ir.LetCont(loopContinuation,
|
| new ir.InvokeContinuation(loopContinuation,
|
| environment.index2value)));
|
| if (hasBreaks) {
|
| _current = branch;
|
| environment = condBuilder.environment;
|
| breakCollector.addJump(this);
|
| - letJoin.continuations =
|
| - <ir.Continuation>[createJoin(environment.length, breakCollector)];
|
| + letJoin.continuation = createJoin(environment.length, breakCollector);
|
| _current = letJoin;
|
| } else {
|
| _current = condBuilder._current;
|
| @@ -1333,11 +1323,12 @@ abstract class IrBuilder {
|
| elseContinuation.body = new ir.LetPrim(trueConstant)
|
| ..plug(new ir.InvokeContinuation(joinContinuation, [trueConstant]));
|
|
|
| - add(new ir.LetCont(<ir.Continuation>[joinContinuation],
|
| - new ir.LetCont(<ir.Continuation>[thenContinuation, elseContinuation],
|
| + add(new ir.LetCont(joinContinuation,
|
| + new ir.LetCont(thenContinuation,
|
| + new ir.LetCont(elseContinuation,
|
| new ir.Branch(new ir.IsTrue(condition),
|
| thenContinuation,
|
| - elseContinuation))));
|
| + elseContinuation)))));
|
| return resultParameter;
|
| }
|
|
|
| @@ -1416,11 +1407,11 @@ abstract class IrBuilder {
|
| rightFalseContinuation.body = rightFalseBuilder._root;
|
| // The right subexpression has two continuations.
|
| rightBuilder.add(
|
| - new ir.LetCont(<ir.Continuation>[rightTrueContinuation,
|
| - rightFalseContinuation],
|
| - new ir.Branch(new ir.IsTrue(rightValue),
|
| - rightTrueContinuation,
|
| - rightFalseContinuation)));
|
| + new ir.LetCont(rightTrueContinuation,
|
| + new ir.LetCont(rightFalseContinuation,
|
| + new ir.Branch(new ir.IsTrue(rightValue),
|
| + rightTrueContinuation,
|
| + rightFalseContinuation))));
|
| // Depending on the operator, the left subexpression's continuations are
|
| // either the right subexpression or an invocation of the join-point
|
| // continuation.
|
| @@ -1432,12 +1423,12 @@ abstract class IrBuilder {
|
| leftFalseContinuation.body = emptyBuilder._root;
|
| }
|
|
|
| - add(new ir.LetCont(<ir.Continuation>[joinContinuation],
|
| - new ir.LetCont(<ir.Continuation>[leftTrueContinuation,
|
| - leftFalseContinuation],
|
| - new ir.Branch(new ir.IsTrue(leftValue),
|
| - leftTrueContinuation,
|
| - leftFalseContinuation))));
|
| + add(new ir.LetCont(joinContinuation,
|
| + new ir.LetCont(leftTrueContinuation,
|
| + new ir.LetCont(leftFalseContinuation,
|
| + new ir.Branch(new ir.IsTrue(leftValue),
|
| + leftTrueContinuation,
|
| + leftFalseContinuation)))));
|
| // There is always a join parameter for the result value, because it
|
| // is different on at least two paths.
|
| return joinContinuation.parameters.last;
|
|
|