annotate src/cpu/sparc/vm/relocInfo_sparc.cpp @ 113:ba764ed4b6f2

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