address Relocation::pd_call_destination(address orig_addr) { intptr_t adj = 0; address inst_loc = addr(); if (orig_addr != NULL) { // We just moved this call instruction from orig_addr to addr(). // This means its target will appear to have grown by addr() - orig_addr. adj = -(inst_loc - orig_addr); } if (NativeFarCall::is_far_call_at(inst_loc)) { NativeFarCall* call = nativeFarCall_at(inst_loc); return call->destination() + (intptr_t)(call->is_pcrelative() ? adj : 0); } else if (NativeJump::is_jump_at(inst_loc)) { NativeJump* jump = nativeJump_at(inst_loc); return jump->jump_destination() + (intptr_t)(jump->is_pcrelative() ? adj : 0); } else if (NativeConditionalFarBranch::is_conditional_far_branch_at(inst_loc)) { NativeConditionalFarBranch* branch = NativeConditionalFarBranch_at(inst_loc); return branch->branch_destination(); } else { // There are two instructions at the beginning of a stub, therefore we // load at orig_addr + 8. orig_addr = nativeCall_at(inst_loc)->get_trampoline(); if (orig_addr == NULL) { return (address) -1; } else { return (address) nativeMovConstReg_at(orig_addr + 8)->data(); } } }