src/cpu/ppc/vm/relocInfo_ppc.cpp

Tue, 17 Oct 2017 12:58:25 +0800

author
aoqi
date
Tue, 17 Oct 2017 12:58:25 +0800
changeset 7994
04ff2f6cd0eb
parent 6876
710a3c8b516e
child 8856
ac27a9c85bea
permissions
-rw-r--r--

merge

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * Copyright 2012, 2013 SAP AG. All rights reserved.
aoqi@0 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 5 *
aoqi@0 6 * This code is free software; you can redistribute it and/or modify it
aoqi@0 7 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 8 * published by the Free Software Foundation.
aoqi@0 9 *
aoqi@0 10 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 13 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 14 * accompanied this code).
aoqi@0 15 *
aoqi@0 16 * You should have received a copy of the GNU General Public License version
aoqi@0 17 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 19 *
aoqi@0 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 21 * or visit www.oracle.com if you need additional information or have any
aoqi@0 22 * questions.
aoqi@0 23 *
aoqi@0 24 */
aoqi@0 25
aoqi@0 26 #include "precompiled.hpp"
aoqi@0 27 #include "asm/assembler.inline.hpp"
aoqi@0 28 #include "assembler_ppc.inline.hpp"
aoqi@0 29 #include "code/relocInfo.hpp"
aoqi@0 30 #include "nativeInst_ppc.hpp"
aoqi@0 31 #include "oops/oop.inline.hpp"
aoqi@0 32 #include "runtime/safepoint.hpp"
aoqi@0 33
aoqi@0 34 void Relocation::pd_set_data_value(address x, intptr_t o, bool verify_only) {
aoqi@0 35 bool copy_back_to_oop_pool = true; // TODO: PPC port
aoqi@0 36 // The following comment is from the declaration of DataRelocation:
aoqi@0 37 //
aoqi@0 38 // "The "o" (displacement) argument is relevant only to split relocations
aoqi@0 39 // on RISC machines. In some CPUs (SPARC), the set-hi and set-lo ins'ns
aoqi@0 40 // can encode more than 32 bits between them. This allows compilers to
aoqi@0 41 // share set-hi instructions between addresses that differ by a small
aoqi@0 42 // offset (e.g., different static variables in the same class).
aoqi@0 43 // On such machines, the "x" argument to set_value on all set-lo
aoqi@0 44 // instructions must be the same as the "x" argument for the
aoqi@0 45 // corresponding set-hi instructions. The "o" arguments for the
aoqi@0 46 // set-hi instructions are ignored, and must not affect the high-half
aoqi@0 47 // immediate constant. The "o" arguments for the set-lo instructions are
aoqi@0 48 // added into the low-half immediate constant, and must not overflow it."
aoqi@0 49 //
aoqi@0 50 // Currently we don't support splitting of relocations, so o must be
aoqi@0 51 // zero:
aoqi@0 52 assert(o == 0, "tried to split relocations");
aoqi@0 53
aoqi@0 54 if (!verify_only) {
aoqi@0 55 if (format() != 1) {
aoqi@0 56 nativeMovConstReg_at(addr())->set_data_plain(((intptr_t)x), code());
aoqi@0 57 } else {
aoqi@0 58 assert(type() == relocInfo::oop_type || type() == relocInfo::metadata_type,
aoqi@0 59 "how to encode else?");
aoqi@0 60 narrowOop no = (type() == relocInfo::oop_type) ?
aoqi@0 61 oopDesc::encode_heap_oop((oop)x) : Klass::encode_klass((Klass*)x);
aoqi@0 62 nativeMovConstReg_at(addr())->set_narrow_oop(no, code());
aoqi@0 63 }
aoqi@0 64 } else {
aoqi@0 65 assert((address) (nativeMovConstReg_at(addr())->data()) == x, "data must match");
aoqi@0 66 }
aoqi@0 67 }
aoqi@0 68
aoqi@0 69 address Relocation::pd_call_destination(address orig_addr) {
aoqi@0 70 intptr_t adj = 0;
aoqi@0 71 address inst_loc = addr();
aoqi@0 72
aoqi@0 73 if (orig_addr != NULL) {
aoqi@0 74 // We just moved this call instruction from orig_addr to addr().
aoqi@0 75 // This means its target will appear to have grown by addr() - orig_addr.
aoqi@0 76 adj = -(inst_loc - orig_addr);
aoqi@0 77 }
aoqi@0 78 if (NativeFarCall::is_far_call_at(inst_loc)) {
aoqi@0 79 NativeFarCall* call = nativeFarCall_at(inst_loc);
aoqi@0 80 return call->destination() + (intptr_t)(call->is_pcrelative() ? adj : 0);
aoqi@0 81 } else if (NativeJump::is_jump_at(inst_loc)) {
aoqi@0 82 NativeJump* jump = nativeJump_at(inst_loc);
aoqi@0 83 return jump->jump_destination() + (intptr_t)(jump->is_pcrelative() ? adj : 0);
aoqi@0 84 } else if (NativeConditionalFarBranch::is_conditional_far_branch_at(inst_loc)) {
aoqi@0 85 NativeConditionalFarBranch* branch = NativeConditionalFarBranch_at(inst_loc);
aoqi@0 86 return branch->branch_destination();
aoqi@0 87 } else {
aoqi@0 88 // There are two instructions at the beginning of a stub, therefore we
aoqi@0 89 // load at orig_addr + 8.
aoqi@0 90 orig_addr = nativeCall_at(inst_loc)->get_trampoline();
aoqi@0 91 if (orig_addr == NULL) {
aoqi@0 92 return (address) -1;
aoqi@0 93 } else {
aoqi@0 94 return (address) nativeMovConstReg_at(orig_addr + 8)->data();
aoqi@0 95 }
aoqi@0 96 }
aoqi@0 97 }
aoqi@0 98
aoqi@0 99 void Relocation::pd_set_call_destination(address x) {
aoqi@0 100 address inst_loc = addr();
aoqi@0 101
aoqi@0 102 if (NativeFarCall::is_far_call_at(inst_loc)) {
aoqi@0 103 NativeFarCall* call = nativeFarCall_at(inst_loc);
aoqi@0 104 call->set_destination(x);
aoqi@0 105 } else if (NativeJump::is_jump_at(inst_loc)) {
aoqi@0 106 NativeJump* jump= nativeJump_at(inst_loc);
aoqi@0 107 jump->set_jump_destination(x);
aoqi@0 108 } else if (NativeConditionalFarBranch::is_conditional_far_branch_at(inst_loc)) {
aoqi@0 109 NativeConditionalFarBranch* branch = NativeConditionalFarBranch_at(inst_loc);
aoqi@0 110 branch->set_branch_destination(x);
aoqi@0 111 } else {
aoqi@0 112 NativeCall* call = nativeCall_at(inst_loc);
aoqi@0 113 call->set_destination_mt_safe(x, false);
aoqi@0 114 }
aoqi@0 115 }
aoqi@0 116
aoqi@0 117 address* Relocation::pd_address_in_code() {
aoqi@0 118 ShouldNotReachHere();
aoqi@0 119 return 0;
aoqi@0 120 }
aoqi@0 121
aoqi@0 122 address Relocation::pd_get_address_from_code() {
aoqi@0 123 return (address)(nativeMovConstReg_at(addr())->data());
aoqi@0 124 }
aoqi@0 125
aoqi@0 126 void poll_Relocation::fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) {
aoqi@0 127 }
aoqi@0 128
aoqi@0 129 void poll_return_Relocation::fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) {
aoqi@0 130 }
aoqi@0 131
aoqi@0 132 void metadata_Relocation::pd_fix_value(address x) {
aoqi@0 133 }

mercurial