src/cpu/sparc/vm/relocInfo_sparc.cpp

Tue, 30 Nov 2010 23:23:40 -0800

author
iveresov
date
Tue, 30 Nov 2010 23:23:40 -0800
changeset 2344
ac637b7220d1
parent 2314
f95d63e2154a
child 2657
d673ef06fe96
permissions
-rw-r--r--

6985015: C1 needs to support compressed oops
Summary: This change implements compressed oops for C1 for x64 and sparc. The changes are mostly on the codegen level, with a few exceptions when we do access things outside of the heap that are uncompressed from the IR. Compressed oops are now also enabled with tiered.
Reviewed-by: twisti, kvn, never, phh

duke@435 1 /*
stefank@2314 2 * Copyright (c) 1998, 2010, 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
stefank@2314 25 #include "precompiled.hpp"
stefank@2314 26 #include "asm/assembler.inline.hpp"
stefank@2314 27 #include "assembler_sparc.inline.hpp"
stefank@2314 28 #include "code/relocInfo.hpp"
stefank@2314 29 #include "nativeInst_sparc.hpp"
stefank@2314 30 #include "oops/oop.inline.hpp"
stefank@2314 31 #include "runtime/safepoint.hpp"
duke@435 32
duke@435 33 void Relocation::pd_set_data_value(address x, intptr_t o) {
duke@435 34 NativeInstruction* ip = nativeInstruction_at(addr());
duke@435 35 jint inst = ip->long_at(0);
duke@435 36 assert(inst != NativeInstruction::illegal_instruction(), "no breakpoint");
duke@435 37 switch (Assembler::inv_op(inst)) {
duke@435 38
duke@435 39 case Assembler::ldst_op:
duke@435 40 #ifdef ASSERT
duke@435 41 switch (Assembler::inv_op3(inst)) {
duke@435 42 case Assembler::lduw_op3:
duke@435 43 case Assembler::ldub_op3:
duke@435 44 case Assembler::lduh_op3:
duke@435 45 case Assembler::ldd_op3:
duke@435 46 case Assembler::ldsw_op3:
duke@435 47 case Assembler::ldsb_op3:
duke@435 48 case Assembler::ldsh_op3:
duke@435 49 case Assembler::ldx_op3:
duke@435 50 case Assembler::ldf_op3:
duke@435 51 case Assembler::lddf_op3:
duke@435 52 case Assembler::stw_op3:
duke@435 53 case Assembler::stb_op3:
duke@435 54 case Assembler::sth_op3:
duke@435 55 case Assembler::std_op3:
duke@435 56 case Assembler::stx_op3:
duke@435 57 case Assembler::stf_op3:
duke@435 58 case Assembler::stdf_op3:
duke@435 59 case Assembler::casa_op3:
duke@435 60 case Assembler::casxa_op3:
duke@435 61 break;
duke@435 62 default:
duke@435 63 ShouldNotReachHere();
duke@435 64 }
duke@435 65 goto do_non_sethi;
duke@435 66 #endif
duke@435 67
duke@435 68 case Assembler::arith_op:
duke@435 69 #ifdef ASSERT
duke@435 70 switch (Assembler::inv_op3(inst)) {
duke@435 71 case Assembler::or_op3:
duke@435 72 case Assembler::add_op3:
duke@435 73 case Assembler::jmpl_op3:
duke@435 74 break;
duke@435 75 default:
duke@435 76 ShouldNotReachHere();
duke@435 77 }
duke@435 78 do_non_sethi:;
duke@435 79 #endif
duke@435 80 {
duke@435 81 guarantee(Assembler::inv_immed(inst), "must have a simm13 field");
duke@435 82 int simm13 = Assembler::low10((intptr_t)x) + o;
duke@435 83 guarantee(Assembler::is_simm13(simm13), "offset can't overflow simm13");
duke@435 84 inst &= ~Assembler::simm( -1, 13);
duke@435 85 inst |= Assembler::simm(simm13, 13);
duke@435 86 ip->set_long_at(0, inst);
duke@435 87 }
duke@435 88 break;
duke@435 89
duke@435 90 case Assembler::branch_op:
duke@435 91 {
duke@435 92 #ifdef _LP64
duke@435 93 jint inst2;
duke@435 94 guarantee(Assembler::inv_op2(inst)==Assembler::sethi_op2, "must be sethi");
kvn@599 95 if (format() != 0) {
kvn@599 96 assert(type() == relocInfo::oop_type, "only narrow oops case");
kvn@599 97 jint np = oopDesc::encode_heap_oop((oop)x);
kvn@599 98 inst &= ~Assembler::hi22(-1);
kvn@599 99 inst |= Assembler::hi22((intptr_t)np);
kvn@599 100 ip->set_long_at(0, inst);
kvn@599 101 inst2 = ip->long_at( NativeInstruction::nop_instruction_size );
kvn@599 102 guarantee(Assembler::inv_op(inst2)==Assembler::arith_op, "arith op");
kvn@599 103 ip->set_long_at(NativeInstruction::nop_instruction_size, ip->set_data32_simm13( inst2, (intptr_t)np));
kvn@599 104 break;
kvn@599 105 }
duke@435 106 ip->set_data64_sethi( ip->addr_at(0), (intptr_t)x );
duke@435 107 #else
duke@435 108 guarantee(Assembler::inv_op2(inst)==Assembler::sethi_op2, "must be sethi");
duke@435 109 inst &= ~Assembler::hi22( -1);
duke@435 110 inst |= Assembler::hi22((intptr_t)x);
duke@435 111 // (ignore offset; it doesn't play into the sethi)
duke@435 112 ip->set_long_at(0, inst);
duke@435 113 #endif
duke@435 114 }
duke@435 115 break;
duke@435 116
duke@435 117 default:
duke@435 118 guarantee(false, "instruction must perform arithmetic or memory access");
duke@435 119 }
duke@435 120 }
duke@435 121
duke@435 122
duke@435 123 address Relocation::pd_call_destination(address orig_addr) {
duke@435 124 intptr_t adj = 0;
duke@435 125 if (orig_addr != NULL) {
duke@435 126 // We just moved this call instruction from orig_addr to addr().
duke@435 127 // This means its target will appear to have grown by addr() - orig_addr.
duke@435 128 adj = -( addr() - orig_addr );
duke@435 129 }
duke@435 130 if (NativeCall::is_call_at(addr())) {
duke@435 131 NativeCall* call = nativeCall_at(addr());
duke@435 132 return call->destination() + adj;
duke@435 133 }
duke@435 134 if (NativeFarCall::is_call_at(addr())) {
duke@435 135 NativeFarCall* call = nativeFarCall_at(addr());
duke@435 136 return call->destination() + adj;
duke@435 137 }
duke@435 138 // Special case: Patchable branch local to the code cache.
duke@435 139 // This will break badly if the code cache grows larger than a few Mb.
duke@435 140 NativeGeneralJump* br = nativeGeneralJump_at(addr());
duke@435 141 return br->jump_destination() + adj;
duke@435 142 }
duke@435 143
duke@435 144
duke@435 145 void Relocation::pd_set_call_destination(address x) {
duke@435 146 if (NativeCall::is_call_at(addr())) {
duke@435 147 NativeCall* call = nativeCall_at(addr());
duke@435 148 call->set_destination(x);
duke@435 149 return;
duke@435 150 }
duke@435 151 if (NativeFarCall::is_call_at(addr())) {
duke@435 152 NativeFarCall* call = nativeFarCall_at(addr());
duke@435 153 call->set_destination(x);
duke@435 154 return;
duke@435 155 }
duke@435 156 // Special case: Patchable branch local to the code cache.
duke@435 157 // This will break badly if the code cache grows larger than a few Mb.
duke@435 158 NativeGeneralJump* br = nativeGeneralJump_at(addr());
duke@435 159 br->set_jump_destination(x);
duke@435 160 }
duke@435 161
duke@435 162
duke@435 163 address* Relocation::pd_address_in_code() {
duke@435 164 // SPARC never embeds addresses in code, at present.
duke@435 165 //assert(type() == relocInfo::oop_type, "only oops are inlined at present");
duke@435 166 return (address*)addr();
duke@435 167 }
duke@435 168
duke@435 169
duke@435 170 address Relocation::pd_get_address_from_code() {
duke@435 171 // SPARC never embeds addresses in code, at present.
duke@435 172 //assert(type() == relocInfo::oop_type, "only oops are inlined at present");
duke@435 173 return *(address*)addr();
duke@435 174 }
duke@435 175
duke@435 176
duke@435 177 int Relocation::pd_breakpoint_size() {
duke@435 178 // minimum breakpoint size, in short words
duke@435 179 return NativeIllegalInstruction::instruction_size / sizeof(short);
duke@435 180 }
duke@435 181
duke@435 182 void Relocation::pd_swap_in_breakpoint(address x, short* instrs, int instrlen) {
duke@435 183 Untested("pd_swap_in_breakpoint");
duke@435 184 // %%% probably do not need a general instrlen; just use the trap size
duke@435 185 if (instrs != NULL) {
duke@435 186 assert(instrlen * sizeof(short) == NativeIllegalInstruction::instruction_size, "enough instrlen in reloc. data");
duke@435 187 for (int i = 0; i < instrlen; i++) {
duke@435 188 instrs[i] = ((short*)x)[i];
duke@435 189 }
duke@435 190 }
duke@435 191 NativeIllegalInstruction::insert(x);
duke@435 192 }
duke@435 193
duke@435 194
duke@435 195 void Relocation::pd_swap_out_breakpoint(address x, short* instrs, int instrlen) {
duke@435 196 Untested("pd_swap_out_breakpoint");
duke@435 197 assert(instrlen * sizeof(short) == sizeof(int), "enough buf");
duke@435 198 union { int l; short s[1]; } u;
duke@435 199 for (int i = 0; i < instrlen; i++) {
duke@435 200 u.s[i] = instrs[i];
duke@435 201 }
duke@435 202 NativeInstruction* ni = nativeInstruction_at(x);
duke@435 203 ni->set_long_at(0, u.l);
duke@435 204 }
never@739 205
never@739 206 void poll_Relocation::fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) {
never@739 207 }
never@739 208
never@739 209 void poll_return_Relocation::fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) {
never@739 210 }

mercurial