src/cpu/ppc/vm/relocInfo_ppc.cpp

Wed, 27 Nov 2013 16:16:21 -0800

author
goetz
date
Wed, 27 Nov 2013 16:16:21 -0800
changeset 6490
41b780b43b74
parent 6463
7687c56b6693
child 6876
710a3c8b516e
child 8647
0b611970fa8b
permissions
-rw-r--r--

8029015: PPC64 (part 216): opto: trap based null and range checks
Summary: On PPC64 use tdi instruction that does a compare and raises SIGTRAP for NULL and range checks.
Reviewed-by: kvn

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

mercurial