src/cpu/sparc/vm/relocInfo_sparc.cpp

Tue, 03 Aug 2010 08:13:38 -0400

author
bobv
date
Tue, 03 Aug 2010 08:13:38 -0400
changeset 2036
126ea7725993
parent 1907
c18cbe5936b8
child 2314
f95d63e2154a
permissions
-rw-r--r--

6953477: Increase portability and flexibility of building Hotspot
Summary: A collection of portability improvements including shared code support for PPC, ARM platforms, software floating point, cross compilation support and improvements in error crash detail.
Reviewed-by: phh, never, coleenp, dholmes

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

mercurial