anchor.diff:      ir.Primitive thenValue = thenBuilder.visit(node.thenExpression);
       ir.Primitive elseValue = elseBuilder.visit(node.elseExpression);
   
  -    // Construct a join in the same way as for if statements, see visitIf.
  -    // There is always control flow out of expressions so thenBuilder.isOpen
  -    // and elseBuilder.isOpen.  There is an extra join-point continuation
  -    // parameter for the expression value.
  -    assert(assignedVars.length == thenBuilder.freeVars.length);
  -    assert(assignedVars.length == elseBuilder.freeVars.length);
  -    assert(assignedVars.length <= thenBuilder.assignedVars.length);
  -    assert(assignedVars.length <= elseBuilder.assignedVars.length);
  -    List<ir.Parameter> parameters = <ir.Parameter>[];
       List<ir.Primitive> thenArguments = <ir.Primitive>[];
       List<ir.Primitive> elseArguments = <ir.Primitive>[];
  -    for (int i = 0; i < assignedVars.length; ++i) {
  -      ir.Definition thenAssignment = thenBuilder.assignedVars[i];
  -      ir.Definition elseAssignment = elseBuilder.assignedVars[i];
  -      if (thenAssignment != null || elseAssignment != null) {
  -        ir.Parameter parameter = new ir.Parameter(null);
  -        parameters.add(parameter);
  -        thenArguments.add(thenAssignment == null
  -                              ? thenBuilder.freeVars[i]
  -                              : thenAssignment);
  -        elseArguments.add(elseAssignment == null
  -                              ? elseBuilder.freeVars[i]
  -                              : elseAssignment);
  -      }
  -    }
  +    List<ir.Parameter> parameters =
  +        createJoinParameters(thenBuilder, thenArguments,
  +                             elseBuilder, elseArguments);
       // Add a continuation parameter for the result of the expression.
       ir.Parameter resultParameter = new ir.Parameter(null);
       parameters.add(resultParameter);
  
positive.code:     // assigned variables in the then and else parts are arguments to the join
      // point continuation if any.
  
      // FreeVars is initially the length of assignedVars of the parent, and it
      // does not grow.  AssignedVars can grow.
      assert(assignedVars.length == thenBuilder.freeVars.length);
      assert(assignedVars.length == elseBuilder.freeVars.length);
      assert(assignedVars.length <= thenBuilder.assignedVars.length);
      assert(assignedVars.length <= elseBuilder.assignedVars.length);
      List<ir.Parameter> parameters = <ir.Parameter>[];
      List<ir.Primitive> thenArguments = <ir.Primitive>[];
      List<ir.Primitive> elseArguments = <ir.Primitive>[];
      for (int i = 0; i < assignedVars.length; ++i) {
        // These are the last assignments, if any, in the then and else
        // continuations respectively (if they can reach the join point).  If a
        // variable is assigned in either branch reaching the join point, it has
        // different values that must be passed as an argument to the join point
        // continuation.
        ir.Definition thenAssignment =
            thenBuilder.isOpen ? thenBuilder.assignedVars[i] : null;
        ir.Definition elseAssignment =
            elseBuilder.isOpen ? elseBuilder.assignedVars[i] : null;
        if (thenAssignment != null || elseAssignment != null) {
          // In the case that not both then and else parts can reach the join
          // point, there will still be a join-point continuation possibly with
          // arguments passed to it.  Such singly-used continuations should be
          // eliminated by shrinking conversions (because they can arise
          // otherwise as the result of optimization).
          ir.Parameter parameter = new ir.Parameter(null);
          parameters.add(parameter);
          thenArguments.add(thenAssignment == null
                                ? thenBuilder.freeVars[i]
                                : thenAssignment);
          elseArguments.add(elseAssignment == null
                                ? elseBuilder.freeVars[i]
                                : elseAssignment);
        }
      }
  
      // Create a then and else continuations and a join continuation if
      // necessary.  Jump to the join continuation from the exits of the then
  
negative.code:     thenContinuation.body = thenBuilder.root;
      elseContinuation.body = elseBuilder.root;
  
      // Capture free occurrences in the then and else bodies and add join
      // continuation parameters as assignments reaching the join body.  This is
      // done after creating invocations of the join continuation so free join
      // continuation arguments are properly captured.
      captureFreeVariables(thenBuilder, elseBuilder, parameters);
  
      ir.Expression branch =
          new ir.LetCont(thenContinuation,
  