annotate src/cpu/sparc/vm/relocInfo_sparc.cpp @ 2230:d673ef06fe96

7028374: race in fix_oop_relocations for scavengeable nmethods Reviewed-by: kvn
author never
date Fri, 18 Mar 2011 15:52:42 -0700
parents f95d63e2154a
children 1d1603768966
rev   line source
duke@0 1 /*
stefank@1885 2 * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
duke@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@0 4 *
duke@0 5 * This code is free software; you can redistribute it and/or modify it
duke@0 6 * under the terms of the GNU General Public License version 2 only, as
duke@0 7 * published by the Free Software Foundation.
duke@0 8 *
duke@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@0 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@0 13 * accompanied this code).
duke@0 14 *
duke@0 15 * You should have received a copy of the GNU General Public License version
duke@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@0 18 *
trims@1472 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1472 20 * or visit www.oracle.com if you need additional information or have any
trims@1472 21 * questions.
duke@0 22 *
duke@0 23 */
duke@0 24
stefank@1885 25 #include "precompiled.hpp"
stefank@1885 26 #include "asm/assembler.inline.hpp"
stefank@1885 27 #include "assembler_sparc.inline.hpp"
stefank@1885 28 #include "code/relocInfo.hpp"
stefank@1885 29 #include "nativeInst_sparc.hpp"
stefank@1885 30 #include "oops/oop.inline.hpp"
stefank@1885 31 #include "runtime/safepoint.hpp"
duke@0 32
never@2230 33 void Relocation::pd_set_data_value(address x, intptr_t o, bool verify_only) {
duke@0 34 NativeInstruction* ip = nativeInstruction_at(addr());
duke@0 35 jint inst = ip->long_at(0);
duke@0 36 assert(inst != NativeInstruction::illegal_instruction(), "no breakpoint");
duke@0 37 switch (Assembler::inv_op(inst)) {
duke@0 38
duke@0 39 case Assembler::ldst_op:
duke@0 40 #ifdef ASSERT
duke@0 41 switch (Assembler::inv_op3(inst)) {
duke@0 42 case Assembler::lduw_op3:
duke@0 43 case Assembler::ldub_op3:
duke@0 44 case Assembler::lduh_op3:
duke@0 45 case Assembler::ldd_op3:
duke@0 46 case Assembler::ldsw_op3:
duke@0 47 case Assembler::ldsb_op3:
duke@0 48 case Assembler::ldsh_op3:
duke@0 49 case Assembler::ldx_op3:
duke@0 50 case Assembler::ldf_op3:
duke@0 51 case Assembler::lddf_op3:
duke@0 52 case Assembler::stw_op3:
duke@0 53 case Assembler::stb_op3:
duke@0 54 case Assembler::sth_op3:
duke@0 55 case Assembler::std_op3:
duke@0 56 case Assembler::stx_op3:
duke@0 57 case Assembler::stf_op3:
duke@0 58 case Assembler::stdf_op3:
duke@0 59 case Assembler::casa_op3:
duke@0 60 case Assembler::casxa_op3:
duke@0 61 break;
duke@0 62 default:
duke@0 63 ShouldNotReachHere();
duke@0 64 }
duke@0 65 goto do_non_sethi;
duke@0 66 #endif
duke@0 67
duke@0 68 case Assembler::arith_op:
duke@0 69 #ifdef ASSERT
duke@0 70 switch (Assembler::inv_op3(inst)) {
duke@0 71 case Assembler::or_op3:
duke@0 72 case Assembler::add_op3:
duke@0 73 case Assembler::jmpl_op3:
duke@0 74 break;
duke@0 75 default:
duke@0 76 ShouldNotReachHere();
duke@0 77 }
duke@0 78 do_non_sethi:;
duke@0 79 #endif
duke@0 80 {
duke@0 81 guarantee(Assembler::inv_immed(inst), "must have a simm13 field");
duke@0 82 int simm13 = Assembler::low10((intptr_t)x) + o;
duke@0 83 guarantee(Assembler::is_simm13(simm13), "offset can't overflow simm13");
duke@0 84 inst &= ~Assembler::simm( -1, 13);
duke@0 85 inst |= Assembler::simm(simm13, 13);
never@2230 86 if (verify_only) {
never@2230 87 assert(ip->long_at(0) == inst, "instructions must match");
never@2230 88 } else {
never@2230 89 ip->set_long_at(0, inst);
never@2230 90 }
duke@0 91 }
duke@0 92 break;
duke@0 93
duke@0 94 case Assembler::branch_op:
duke@0 95 {
duke@0 96 #ifdef _LP64
duke@0 97 jint inst2;
duke@0 98 guarantee(Assembler::inv_op2(inst)==Assembler::sethi_op2, "must be sethi");
kvn@164 99 if (format() != 0) {
kvn@164 100 assert(type() == relocInfo::oop_type, "only narrow oops case");
kvn@164 101 jint np = oopDesc::encode_heap_oop((oop)x);
kvn@164 102 inst &= ~Assembler::hi22(-1);
kvn@164 103 inst |= Assembler::hi22((intptr_t)np);
never@2230 104 if (verify_only) {
never@2230 105 assert(ip->long_at(0) == inst, "instructions must match");
never@2230 106 } else {
never@2230 107 ip->set_long_at(0, inst);
never@2230 108 }
kvn@164 109 inst2 = ip->long_at( NativeInstruction::nop_instruction_size );
kvn@164 110 guarantee(Assembler::inv_op(inst2)==Assembler::arith_op, "arith op");
never@2230 111 if (verify_only) {
never@2230 112 assert(ip->long_at(NativeInstruction::nop_instruction_size) == NativeInstruction::set_data32_simm13( inst2, (intptr_t)np),
never@2230 113 "instructions must match");
never@2230 114 } else {
never@2230 115 ip->set_long_at(NativeInstruction::nop_instruction_size, NativeInstruction::set_data32_simm13( inst2, (intptr_t)np));
never@2230 116 }
kvn@164 117 break;
kvn@164 118 }
never@2230 119 if (verify_only) {
never@2230 120 ip->verify_data64_sethi( ip->addr_at(0), (intptr_t)x );
never@2230 121 } else {
never@2230 122 ip->set_data64_sethi( ip->addr_at(0), (intptr_t)x );
never@2230 123 }
duke@0 124 #else
duke@0 125 guarantee(Assembler::inv_op2(inst)==Assembler::sethi_op2, "must be sethi");
duke@0 126 inst &= ~Assembler::hi22( -1);
duke@0 127 inst |= Assembler::hi22((intptr_t)x);
duke@0 128 // (ignore offset; it doesn't play into the sethi)
never@2230 129 if (verify_only) {
never@2230 130 assert(ip->long_at(0) == inst, "instructions must match");
never@2230 131 } else {
never@2230 132 ip->set_long_at(0, inst);
never@2230 133 }
duke@0 134 #endif
duke@0 135 }
duke@0 136 break;
duke@0 137
duke@0 138 default:
duke@0 139 guarantee(false, "instruction must perform arithmetic or memory access");
duke@0 140 }
duke@0 141 }
duke@0 142
duke@0 143
duke@0 144 address Relocation::pd_call_destination(address orig_addr) {
duke@0 145 intptr_t adj = 0;
duke@0 146 if (orig_addr != NULL) {
duke@0 147 // We just moved this call instruction from orig_addr to addr().
duke@0 148 // This means its target will appear to have grown by addr() - orig_addr.
duke@0 149 adj = -( addr() - orig_addr );
duke@0 150 }
duke@0 151 if (NativeCall::is_call_at(addr())) {
duke@0 152 NativeCall* call = nativeCall_at(addr());
duke@0 153 return call->destination() + adj;
duke@0 154 }
duke@0 155 if (NativeFarCall::is_call_at(addr())) {
duke@0 156 NativeFarCall* call = nativeFarCall_at(addr());
duke@0 157 return call->destination() + adj;
duke@0 158 }
duke@0 159 // Special case: Patchable branch local to the code cache.
duke@0 160 // This will break badly if the code cache grows larger than a few Mb.
duke@0 161 NativeGeneralJump* br = nativeGeneralJump_at(addr());
duke@0 162 return br->jump_destination() + adj;
duke@0 163 }
duke@0 164
duke@0 165
duke@0 166 void Relocation::pd_set_call_destination(address x) {
duke@0 167 if (NativeCall::is_call_at(addr())) {
duke@0 168 NativeCall* call = nativeCall_at(addr());
duke@0 169 call->set_destination(x);
duke@0 170 return;
duke@0 171 }
duke@0 172 if (NativeFarCall::is_call_at(addr())) {
duke@0 173 NativeFarCall* call = nativeFarCall_at(addr());
duke@0 174 call->set_destination(x);
duke@0 175 return;
duke@0 176 }
duke@0 177 // Special case: Patchable branch local to the code cache.
duke@0 178 // This will break badly if the code cache grows larger than a few Mb.
duke@0 179 NativeGeneralJump* br = nativeGeneralJump_at(addr());
duke@0 180 br->set_jump_destination(x);
duke@0 181 }
duke@0 182
duke@0 183
duke@0 184 address* Relocation::pd_address_in_code() {
duke@0 185 // SPARC never embeds addresses in code, at present.
duke@0 186 //assert(type() == relocInfo::oop_type, "only oops are inlined at present");
duke@0 187 return (address*)addr();
duke@0 188 }
duke@0 189
duke@0 190
duke@0 191 address Relocation::pd_get_address_from_code() {
duke@0 192 // SPARC never embeds addresses in code, at present.
duke@0 193 //assert(type() == relocInfo::oop_type, "only oops are inlined at present");
duke@0 194 return *(address*)addr();
duke@0 195 }
duke@0 196
duke@0 197
duke@0 198 int Relocation::pd_breakpoint_size() {
duke@0 199 // minimum breakpoint size, in short words
duke@0 200 return NativeIllegalInstruction::instruction_size / sizeof(short);
duke@0 201 }
duke@0 202
duke@0 203 void Relocation::pd_swap_in_breakpoint(address x, short* instrs, int instrlen) {
duke@0 204 Untested("pd_swap_in_breakpoint");
duke@0 205 // %%% probably do not need a general instrlen; just use the trap size
duke@0 206 if (instrs != NULL) {
duke@0 207 assert(instrlen * sizeof(short) == NativeIllegalInstruction::instruction_size, "enough instrlen in reloc. data");
duke@0 208 for (int i = 0; i < instrlen; i++) {
duke@0 209 instrs[i] = ((short*)x)[i];
duke@0 210 }
duke@0 211 }
duke@0 212 NativeIllegalInstruction::insert(x);
duke@0 213 }
duke@0 214
duke@0 215
duke@0 216 void Relocation::pd_swap_out_breakpoint(address x, short* instrs, int instrlen) {
duke@0 217 Untested("pd_swap_out_breakpoint");
duke@0 218 assert(instrlen * sizeof(short) == sizeof(int), "enough buf");
duke@0 219 union { int l; short s[1]; } u;
duke@0 220 for (int i = 0; i < instrlen; i++) {
duke@0 221 u.s[i] = instrs[i];
duke@0 222 }
duke@0 223 NativeInstruction* ni = nativeInstruction_at(x);
duke@0 224 ni->set_long_at(0, u.l);
duke@0 225 }
never@304 226
never@304 227 void poll_Relocation::fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) {
never@304 228 }
never@304 229
never@304 230 void poll_return_Relocation::fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) {
never@304 231 }