src/cpu/sparc/vm/relocInfo_sparc.cpp

Thu, 12 Mar 2009 10:37:46 -0700

author
kvn
date
Thu, 12 Mar 2009 10:37:46 -0700
changeset 1077
660978a2a31a
parent 739
dc7f315e41f7
child 1162
6b2273dd6fa9
permissions
-rw-r--r--

6791178: Specialize for zero as the compressed oop vm heap base
Summary: Use zero based compressed oops if java heap is below 32gb and unscaled compressed oops if java heap is below 4gb.
Reviewed-by: never, twisti, jcoomes, coleenp

duke@435 1 /*
xdono@631 2 * Copyright 1998-2008 Sun Microsystems, Inc. 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 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any 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 #ifdef COMPILER2
duke@435 103 // [RGV] Someone must have missed putting in a reloc entry for the
duke@435 104 // add in compiler2.
duke@435 105 inst2 = ip->long_at( NativeMovConstReg::add_offset );
duke@435 106 guarantee(Assembler::inv_op(inst2)==Assembler::arith_op, "arith op");
duke@435 107 ip->set_long_at(NativeMovConstReg::add_offset,ip->set_data32_simm13( inst2, (intptr_t)x+o));
duke@435 108 #endif
duke@435 109 #else
duke@435 110 guarantee(Assembler::inv_op2(inst)==Assembler::sethi_op2, "must be sethi");
duke@435 111 inst &= ~Assembler::hi22( -1);
duke@435 112 inst |= Assembler::hi22((intptr_t)x);
duke@435 113 // (ignore offset; it doesn't play into the sethi)
duke@435 114 ip->set_long_at(0, inst);
duke@435 115 #endif
duke@435 116 }
duke@435 117 break;
duke@435 118
duke@435 119 default:
duke@435 120 guarantee(false, "instruction must perform arithmetic or memory access");
duke@435 121 }
duke@435 122 }
duke@435 123
duke@435 124
duke@435 125 address Relocation::pd_call_destination(address orig_addr) {
duke@435 126 intptr_t adj = 0;
duke@435 127 if (orig_addr != NULL) {
duke@435 128 // We just moved this call instruction from orig_addr to addr().
duke@435 129 // This means its target will appear to have grown by addr() - orig_addr.
duke@435 130 adj = -( addr() - orig_addr );
duke@435 131 }
duke@435 132 if (NativeCall::is_call_at(addr())) {
duke@435 133 NativeCall* call = nativeCall_at(addr());
duke@435 134 return call->destination() + adj;
duke@435 135 }
duke@435 136 if (NativeFarCall::is_call_at(addr())) {
duke@435 137 NativeFarCall* call = nativeFarCall_at(addr());
duke@435 138 return call->destination() + adj;
duke@435 139 }
duke@435 140 // Special case: Patchable branch local to the code cache.
duke@435 141 // This will break badly if the code cache grows larger than a few Mb.
duke@435 142 NativeGeneralJump* br = nativeGeneralJump_at(addr());
duke@435 143 return br->jump_destination() + adj;
duke@435 144 }
duke@435 145
duke@435 146
duke@435 147 void Relocation::pd_set_call_destination(address x) {
duke@435 148 if (NativeCall::is_call_at(addr())) {
duke@435 149 NativeCall* call = nativeCall_at(addr());
duke@435 150 call->set_destination(x);
duke@435 151 return;
duke@435 152 }
duke@435 153 if (NativeFarCall::is_call_at(addr())) {
duke@435 154 NativeFarCall* call = nativeFarCall_at(addr());
duke@435 155 call->set_destination(x);
duke@435 156 return;
duke@435 157 }
duke@435 158 // Special case: Patchable branch local to the code cache.
duke@435 159 // This will break badly if the code cache grows larger than a few Mb.
duke@435 160 NativeGeneralJump* br = nativeGeneralJump_at(addr());
duke@435 161 br->set_jump_destination(x);
duke@435 162 }
duke@435 163
duke@435 164
duke@435 165 address* Relocation::pd_address_in_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 address Relocation::pd_get_address_from_code() {
duke@435 173 // SPARC never embeds addresses in code, at present.
duke@435 174 //assert(type() == relocInfo::oop_type, "only oops are inlined at present");
duke@435 175 return *(address*)addr();
duke@435 176 }
duke@435 177
duke@435 178
duke@435 179 int Relocation::pd_breakpoint_size() {
duke@435 180 // minimum breakpoint size, in short words
duke@435 181 return NativeIllegalInstruction::instruction_size / sizeof(short);
duke@435 182 }
duke@435 183
duke@435 184 void Relocation::pd_swap_in_breakpoint(address x, short* instrs, int instrlen) {
duke@435 185 Untested("pd_swap_in_breakpoint");
duke@435 186 // %%% probably do not need a general instrlen; just use the trap size
duke@435 187 if (instrs != NULL) {
duke@435 188 assert(instrlen * sizeof(short) == NativeIllegalInstruction::instruction_size, "enough instrlen in reloc. data");
duke@435 189 for (int i = 0; i < instrlen; i++) {
duke@435 190 instrs[i] = ((short*)x)[i];
duke@435 191 }
duke@435 192 }
duke@435 193 NativeIllegalInstruction::insert(x);
duke@435 194 }
duke@435 195
duke@435 196
duke@435 197 void Relocation::pd_swap_out_breakpoint(address x, short* instrs, int instrlen) {
duke@435 198 Untested("pd_swap_out_breakpoint");
duke@435 199 assert(instrlen * sizeof(short) == sizeof(int), "enough buf");
duke@435 200 union { int l; short s[1]; } u;
duke@435 201 for (int i = 0; i < instrlen; i++) {
duke@435 202 u.s[i] = instrs[i];
duke@435 203 }
duke@435 204 NativeInstruction* ni = nativeInstruction_at(x);
duke@435 205 ni->set_long_at(0, u.l);
duke@435 206 }
never@739 207
never@739 208 void poll_Relocation::fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) {
never@739 209 }
never@739 210
never@739 211 void poll_return_Relocation::fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) {
never@739 212 }

mercurial