@Test
 public void assignCausesAssignmentOfTheIntervalsRegisterToTheGivenRegister() {
   Register r = new Register(0);
   CompoundInterval ci = new CompoundInterval(DEFAULT_BEGIN, DEFAULT_END, r);
   Register s = new Register(1);
   RegisterAllocatorState regAllocState = new RegisterAllocatorState(0);
   assertThat(ci.isAssigned(regAllocState), is(false));
   assertNull(ci.getAssignment(regAllocState));
   ci.assign(s);
   assertThat(s.mapsToRegister, is(r));
   assertThat(!s.isSpilled() && s.isTouched() && s.isAllocated(), is(true));
   assertThat(r.mapsToRegister, is(s));
   assertThat(!r.isSpilled() && r.isTouched() && r.isAllocated(), is(true));
   assertThat(ci.isAssigned(regAllocState), is(true));
   assertThat(ci.getAssignment(regAllocState), is(s));
 }
コード例 #2
0
ファイル: StackManager.java プロジェクト: JikesRVM/JikesRVM
  @Override
  public void computeNonVolatileArea() {
    GenericPhysicalRegisterSet phys = ir.regpool.getPhysicalRegisterSet();

    if (ir.compiledMethod.isSaveVolatile()) {
      // Record that we use every nonvolatile GPR
      int numGprNv = PhysicalRegisterSet.getNumberOfNonvolatileGPRs();
      ir.compiledMethod.setNumberOfNonvolatileGPRs((short) numGprNv);

      // set the frame size
      frameSize += numGprNv * WORDSIZE;
      frameSize = align(frameSize, STACKFRAME_ALIGNMENT);

      // TODO!!
      ir.compiledMethod.setNumberOfNonvolatileFPRs((short) 0);

      // Record that we need a stack frame.
      setFrameRequired();

      int fpuStateSaveAreaBegin = spillPointer;
      // Calculate FPU state save area for restoreFloatingPointState(..)
      // and saveFloatingPointState(..)
      if (SSE2_FULL) {
        for (int i = 0; i < 8; i++) {
          fsaveLocation = allocateNewSpillLocation(DOUBLE_REG);
        }
      } else {
        // Grab 108 bytes (same as 27 4-byte spills) in the stack
        // frame, as a place to store the floating-point state with FSAVE
        for (int i = 0; i < 27; i++) {
          fsaveLocation = allocateNewSpillLocation(INT_REG);
        }
      }

      int fpuStateSaveAreaEnd = spillPointer;
      int fpuStateSize = fpuStateSaveAreaEnd - fpuStateSaveAreaBegin;
      if (VM.VerifyAssertions) {
        VM._assert(fpuStateSize == OPT_SAVE_VOLATILE_SPACE_FOR_FPU_STATE);
      }

      int volatileGPRSaveAreaBegin = spillPointer;
      // Map each volatile register to a spill location.
      int i = 0;
      for (Enumeration<Register> e = phys.enumerateVolatileGPRs(); e.hasMoreElements(); i++) {
        e.nextElement();
        // Note that as a side effect, the following call bumps up the
        // frame size.
        saveVolatileGPRLocation[i] = allocateNewSpillLocation(INT_REG);
      }
      int volatileGPRSaveAreaEnd = spillPointer;
      int volatileGPRSaveAreaSize = volatileGPRSaveAreaEnd - volatileGPRSaveAreaBegin;
      if (VM.VerifyAssertions) {
        VM._assert(volatileGPRSaveAreaSize == OPT_SAVE_VOLATILE_SPACE_FOR_VOLATILE_GPRS);
        VM._assert((volatileGPRSaveAreaSize + fpuStateSize) == OPT_SAVE_VOLATILE_TOTAL_SIZE);
      }

      // Map each non-volatile register to a spill location.
      i = 0;
      for (Enumeration<Register> e = phys.enumerateNonvolatileGPRs(); e.hasMoreElements(); i++) {
        e.nextElement();
        // Note that as a side effect, the following call bumps up the
        // frame size.
        nonVolatileGPRLocation[i] = allocateNewSpillLocation(INT_REG);
      }

      // Set the offset to find non-volatiles.
      int gprOffset = getNonvolatileGPROffset(0);
      ir.compiledMethod.setUnsignedNonVolatileOffset(gprOffset);

    } else {
      // Count the number of nonvolatiles used.
      int numGprNv = 0;
      int i = 0;
      for (Enumeration<Register> e = phys.enumerateNonvolatileGPRs(); e.hasMoreElements(); ) {
        Register r = e.nextElement();
        if (r.isTouched()) {
          // Note that as a side effect, the following call bumps up the
          // frame size.
          nonVolatileGPRLocation[i++] = allocateNewSpillLocation(INT_REG);
          numGprNv++;
        }
      }
      // Update the OptCompiledMethod object.
      ir.compiledMethod.setNumberOfNonvolatileGPRs((short) numGprNv);
      if (numGprNv > 0) {
        int gprOffset = getNonvolatileGPROffset(0);
        ir.compiledMethod.setUnsignedNonVolatileOffset(gprOffset);
        // record that we need a stack frame
        setFrameRequired();
      } else {
        ir.compiledMethod.setUnsignedNonVolatileOffset(0);
      }

      ir.compiledMethod.setNumberOfNonvolatileFPRs((short) 0);
    }
  }