Пример #1
0
void Label::patch_instructions(MacroAssembler* masm) {
  assert(is_bound(), "Label is bound");
  CodeBuffer* cb = masm->code();
  int target_sect = CodeBuffer::locator_sect(loc());
  address target = cb->locator_address(loc());
  while (_patch_index > 0) {
    --_patch_index;
    int branch_loc;
    if (_patch_index >= PatchCacheSize) {
      branch_loc = _patch_overflow->pop();
    } else {
      branch_loc = _patches[_patch_index];
    }
    int branch_sect = CodeBuffer::locator_sect(branch_loc);
    address branch = cb->locator_address(branch_loc);
    if (branch_sect == CodeBuffer::SECT_CONSTS) {
      // The thing to patch is a constant word.
      *(address*)branch = target;
      continue;
    }

#ifdef ASSERT
    // Cross-section branches only work if the
    // intermediate section boundaries are frozen.
    if (target_sect != branch_sect) {
      for (int n = MIN2(target_sect, branch_sect),
               nlimit = (target_sect + branch_sect) - n;
           n < nlimit; n++) {
        CodeSection* cs = cb->code_section(n);
        assert(cs->is_frozen(), "cross-section branch needs stable offsets");
      }
    }
#endif //ASSERT

    // Push the target offset into the branch instruction.
    masm->pd_patch_instruction(branch, target);
  }
}
Пример #2
0
void Label::print_instructions(MacroAssembler* masm) const {
  CodeBuffer* cb = masm->code();
  for (int i = 0; i < _patch_index; ++i) {
    int branch_loc;
    if (i >= PatchCacheSize) {
      branch_loc = _patch_overflow->at(i - PatchCacheSize);
    } else {
      branch_loc = _patches[i];
    }
    int branch_pos  = CodeBuffer::locator_pos(branch_loc);
    int branch_sect = CodeBuffer::locator_sect(branch_loc);
    address branch = cb->locator_address(branch_loc);
    tty->print_cr("unbound label");
    tty->print("@ %d|%d ", branch_pos, branch_sect);
    if (branch_sect == CodeBuffer::SECT_CONSTS) {
      tty->print_cr(PTR_FORMAT, *(address*)branch);
      continue;
    }
    masm->pd_print_patched_instruction(branch);
    tty->cr();
  }
}