VM._assert(spillCandidate.getRegister().getType() == r.getType());
VM._assert((spillCandidate.getRegister().getType() == r.getType()) || (spillCandidate.getRegister().isNatural() && r.isNatural()));
    void allocate(BasicInterval newInterval, CompoundInterval container) {      if (debug) System.out.println("Allocate " + newInterval + " " +                                           container.getRegister());      OPT_Register r = container.getRegister();      if (container.isSpilled()) {        // We previously decided to spill the compound interval.  No further        // action is needed.        if (verboseDebug) System.out.println("Previously spilled " + container);        return;      } else {        if (container.isAssigned()) {          // The compound interval was previously assigned to a physical          // register.          OPT_Register phys = container.getAssignment();          if (!currentlyActive(phys)) {            // The assignment of newInterval to phys is still OK.            // Update the live ranges of phys to include the new basic            // interval            if (verboseDebug) System.out.println("Previously assigned to " + phys +                                                 " " + container +                                                  " phys interval " +                                                 getInterval(phys));            updatePhysicalInterval(phys,newInterval);            if (verboseDebug) System.out.println(" now phys interval " +                                                  getInterval(phys));            // Mark the physical register as currently allocated            phys.allocateRegister();            return;          } else {            // The previous assignment is not OK, since the physical            // register is now in use elsewhere.              if (debug) System.out.println(                                          "Previously assigned, " + phys + " " + container);            // first look and see if there's another free register for            // container.             if (verboseDebug) System.out.println( "Looking for free register");            OPT_Register freeR = findAvailableRegister(container);            if (verboseDebug) System.out.println( "Free register? " + freeR);            if (freeR == null) {              // Did not find a free register to assign.  So, spill one of              // the two intervals concurrently allocated to phys.              CompoundInterval currentAssignment = getCurrentInterval(phys);               // choose which of the two intervals to spill              double costA = spillCost.getCost(container.getRegister());              double costB = spillCost.getCost(currentAssignment.getRegister());              if (verboseDebug) System.out.println( "Current assignment " +                                                    currentAssignment + " cost "                                                    + costB);              if (verboseDebug) System.out.println( "Cost of spilling" +                                                    container + " cost "                                                    + costA);              CompoundInterval toSpill = (costA < costB) ? container :                 currentAssignment;              // spill it.              OPT_Register p = toSpill.getAssignment();              toSpill.spill(spillManager);              spilled=true;              if (verboseDebug) System.out.println("Spilled " + toSpill+                                                   " from " + p);              CompoundInterval physInterval = getInterval(p);              physInterval.removeAll(toSpill);              if (verboseDebug) System.out.println("  after spill phys" + getInterval(p));              if (toSpill != container) updatePhysicalInterval(p,newInterval);                     if (verboseDebug) System.out.println(" now phys interval " +                                                    getInterval(p));            } else {              // found a free register for container! use it!              if (debug) System.out.println("Switch container "                                             + container + "from " + phys + " to " + freeR);               CompoundInterval physInterval = getInterval(phys);              if (debug) System.out.println("Before switch phys interval"                                            + physInterval);              physInterval.removeAll(container);              if (debug) System.out.println("Intervals of "                                             + phys + " now " +                                            physInterval);               container.assign(freeR);              updatePhysicalInterval(freeR,container,newInterval);              if (verboseDebug) System.out.println("Intervals of "                                                    + freeR + " now " +                                                   getInterval(freeR));               // mark the free register found as currently allocated.              freeR.allocateRegister();            }          }        } else {          // This is the first attempt to allocate the compound interval.          // Attempt to find a free physical register for this interval.          OPT_Register phys = findAvailableRegister(r);          if (phys != null) {            // Found a free register.  Perfom the register assignment.            container.assign(phys);            if (debug) System.out.println("First allocation "                                           + phys + " " + container);             updatePhysicalInterval(phys,newInterval);                   if (verboseDebug) System.out.println("  now phys" + getInterval(phys));            // Mark the physical register as currently allocated.            phys.allocateRegister();          } else {            // Could not find a free physical register.  Some member of the            // active set must be spilled.  Choose a spill candidate.            CompoundInterval spillCandidate = getSpillCandidate(container);            if (VM.VerifyAssertions) {              VM._assert(!spillCandidate.isSpilled());              VM._assert(spillCandidate.getRegister().getType() ==                        r.getType());              VM._assert(!ir.stackManager.getRestrictions().mustNotSpill                        (spillCandidate.getRegister()));              if (spillCandidate.getAssignment() != null) {                VM._assert(!ir.stackManager.getRestrictions().                          isForbidden(r,spillCandidate.getAssignment()));              }            }            if (spillCandidate != container) {              // spill a previously allocated interval.              phys = spillCandidate.getAssignment();              spillCandidate.spill(spillManager);              spilled=true;              if (verboseDebug) System.out.println("Spilled " + spillCandidate +                                                   " from " + phys);              CompoundInterval physInterval = getInterval(phys);              if (verboseDebug) System.out.println(" assigned "                                                    + phys + " to " + container);              physInterval.removeAll(spillCandidate);              if (verboseDebug) System.out.println("  after spill phys" + getInterval(phys));              updatePhysicalInterval(phys,newInterval);                     if (verboseDebug) System.out.println(" now phys interval " +                                                    getInterval(phys));              container.assign(phys);            } else {              // spill the new interval.              if (verboseDebug) System.out.println("spilled " + container);              container.spill(spillManager);              spilled=true;            }          }        }      }    }