Example #1
0
static int find_start(jvm_agent_t* J, uint64_t ptr, uint64_t *startp) {
  int err;
  int i;

  for (i = 0; i < J->Number_of_heaps; ++i) {
    *startp = 0;
    if (codeheap_contains(i, J, ptr)) {
      int32_t used;
      uint64_t segment = segment_for(i, J, ptr);
      uint64_t block = J->Heap_segmap_low[i];
      uint8_t tag;
      err = ps_pread(J->P, block + segment, &tag, sizeof(tag));
      CHECK_FAIL(err);
      if (tag == 0xff)
        return PS_OK;
      while (tag > 0) {
        err = ps_pread(J->P, block + segment, &tag, sizeof(tag));
        CHECK_FAIL(err);
        segment -= tag;
      }
      block = block_at(i, J, segment);
      err = ps_pread(J->P, block + OFFSET_HeapBlockHeader_used, &used, sizeof(used));
      CHECK_FAIL(err);
      if (used) {
        *startp = block + SIZE_HeapBlockHeader;
      }
    }
    return PS_OK;
  }

 fail:
  return -1;
}
Example #2
0
static int find_start(jvm_agent_t* J, uint64_t ptr, uint64_t *startp) {
  int err;

  *startp = 0;
  if (J->CodeCache_low <= ptr && ptr < J->CodeCache_high) {
    int32_t used;
    uint64_t segment = segment_for(J, ptr);
    uint64_t block = J->CodeCache_segmap_low;
    uint8_t tag;
    err = ps_pread(J->P, block + segment, &tag, sizeof(tag));
    CHECK_FAIL(err);
    if (tag == 0xff)
      return PS_OK;
    while (tag > 0) {
      err = ps_pread(J->P, block + segment, &tag, sizeof(tag));
      CHECK_FAIL(err);
      segment -= tag;
    }
    block = block_at(J, segment);
    err = ps_pread(J->P, block + OFFSET_HeapBlockHeader_used, &used, sizeof(used));
    CHECK_FAIL(err);
    if (used) {
      *startp = block + SIZE_HeapBlockHeader;
    }
  }
  return PS_OK;

 fail:
  return -1;
}
Example #3
0
void LinearScan::allocate_fpu_stack() {
  // First compute which FPU registers are live at the start of each basic block
  // (To minimize the amount of work we have to do if we have to merge FPU stacks)
  if (ComputeExactFPURegisterUsage) {
    Interval* intervals_in_register, *intervals_in_memory;
    create_unhandled_lists(&intervals_in_register, &intervals_in_memory, is_in_fpu_register, NULL);

    // ignore memory intervals by overwriting intervals_in_memory
    // the dummy interval is needed to enforce the walker to walk until the given id:
    // without it, the walker stops when the unhandled-list is empty -> live information
    // beyond this point would be incorrect.
    Interval* dummy_interval = new Interval(any_reg);
    dummy_interval->add_range(max_jint - 2, max_jint - 1);
    dummy_interval->set_next(Interval::end());
    intervals_in_memory = dummy_interval;

    IntervalWalker iw(this, intervals_in_register, intervals_in_memory);

    const int num_blocks = block_count();
    for (int i = 0; i < num_blocks; i++) {
      BlockBegin* b = block_at(i);

      // register usage is only needed for merging stacks -> compute only
      // when more than one predecessor.
      // the block must not have any spill moves at the beginning (checked by assertions)
      // spill moves would use intervals that are marked as handled and so the usage bit
      // would been set incorrectly

      // NOTE: the check for number_of_preds > 1 is necessary. A block with only one
      //       predecessor may have spill moves at the begin of the block.
      //       If an interval ends at the current instruction id, it is not possible
      //       to decide if the register is live or not at the block begin -> the
      //       register information would be incorrect.
      if (b->number_of_preds() > 1) {
        int id = b->first_lir_instruction_id();
        ResourceBitMap regs(FrameMap::nof_fpu_regs);

        iw.walk_to(id);   // walk after the first instruction (always a label) of the block
        assert(iw.current_position() == id, "did not walk completely to id");

        // Only consider FPU values in registers
        Interval* interval = iw.active_first(fixedKind);
        while (interval != Interval::end()) {
          int reg = interval->assigned_reg();
          assert(reg >= pd_first_fpu_reg && reg <= pd_last_fpu_reg, "no fpu register");
          assert(interval->assigned_regHi() == -1, "must not have hi register (doubles stored in one register)");
          assert(interval->from() <= id && id < interval->to(), "interval out of range");

#ifndef PRODUCT
          if (TraceFPURegisterUsage) {
            tty->print("fpu reg %d is live because of ", reg - pd_first_fpu_reg); interval->print();
          }
#endif

          regs.set_bit(reg - pd_first_fpu_reg);
          interval = interval->next();
        }

        b->set_fpu_register_usage(regs);

#ifndef PRODUCT
        if (TraceFPURegisterUsage) {
          tty->print("FPU regs for block %d, LIR instr %d): ", b->block_id(), id); regs.print_on(tty); tty->cr();
        }
#endif
      }
    }
  }

  FpuStackAllocator alloc(ir()->compilation(), this);
  _fpu_stack_allocator = &alloc;
  alloc.allocate();
  _fpu_stack_allocator = NULL;
}