annotate src/cpu/sparc/vm/relocInfo_sparc.cpp @ 12355:cefad50507d8

Merge with hs25-b53
author Gilles Duboscq <duboscq@ssw.jku.at>
date Fri, 11 Oct 2013 10:38:03 +0200
parents 740e263c80c6
children 8085ce95b6f5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11041
diff changeset
2 * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
0
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 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 727
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 727
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 727
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #include "precompiled.hpp"
7204
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents: 6848
diff changeset
26 #include "asm/assembler.hpp"
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27 #include "code/relocInfo.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "nativeInst_sparc.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "oops/oop.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "runtime/safepoint.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
31
2375
d673ef06fe96 7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents: 1972
diff changeset
32 void Relocation::pd_set_data_value(address x, intptr_t o, bool verify_only) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
33 NativeInstruction* ip = nativeInstruction_at(addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
34 jint inst = ip->long_at(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
35 assert(inst != NativeInstruction::illegal_instruction(), "no breakpoint");
a61af66fc99e Initial load
duke
parents:
diff changeset
36 switch (Assembler::inv_op(inst)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
37
a61af66fc99e Initial load
duke
parents:
diff changeset
38 case Assembler::ldst_op:
a61af66fc99e Initial load
duke
parents:
diff changeset
39 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
40 switch (Assembler::inv_op3(inst)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
41 case Assembler::lduw_op3:
a61af66fc99e Initial load
duke
parents:
diff changeset
42 case Assembler::ldub_op3:
a61af66fc99e Initial load
duke
parents:
diff changeset
43 case Assembler::lduh_op3:
a61af66fc99e Initial load
duke
parents:
diff changeset
44 case Assembler::ldd_op3:
a61af66fc99e Initial load
duke
parents:
diff changeset
45 case Assembler::ldsw_op3:
a61af66fc99e Initial load
duke
parents:
diff changeset
46 case Assembler::ldsb_op3:
a61af66fc99e Initial load
duke
parents:
diff changeset
47 case Assembler::ldsh_op3:
a61af66fc99e Initial load
duke
parents:
diff changeset
48 case Assembler::ldx_op3:
a61af66fc99e Initial load
duke
parents:
diff changeset
49 case Assembler::ldf_op3:
a61af66fc99e Initial load
duke
parents:
diff changeset
50 case Assembler::lddf_op3:
a61af66fc99e Initial load
duke
parents:
diff changeset
51 case Assembler::stw_op3:
a61af66fc99e Initial load
duke
parents:
diff changeset
52 case Assembler::stb_op3:
a61af66fc99e Initial load
duke
parents:
diff changeset
53 case Assembler::sth_op3:
a61af66fc99e Initial load
duke
parents:
diff changeset
54 case Assembler::std_op3:
a61af66fc99e Initial load
duke
parents:
diff changeset
55 case Assembler::stx_op3:
a61af66fc99e Initial load
duke
parents:
diff changeset
56 case Assembler::stf_op3:
a61af66fc99e Initial load
duke
parents:
diff changeset
57 case Assembler::stdf_op3:
a61af66fc99e Initial load
duke
parents:
diff changeset
58 case Assembler::casa_op3:
a61af66fc99e Initial load
duke
parents:
diff changeset
59 case Assembler::casxa_op3:
a61af66fc99e Initial load
duke
parents:
diff changeset
60 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
61 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
62 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
63 }
a61af66fc99e Initial load
duke
parents:
diff changeset
64 goto do_non_sethi;
a61af66fc99e Initial load
duke
parents:
diff changeset
65 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
66
a61af66fc99e Initial load
duke
parents:
diff changeset
67 case Assembler::arith_op:
a61af66fc99e Initial load
duke
parents:
diff changeset
68 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
69 switch (Assembler::inv_op3(inst)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
70 case Assembler::or_op3:
a61af66fc99e Initial load
duke
parents:
diff changeset
71 case Assembler::add_op3:
a61af66fc99e Initial load
duke
parents:
diff changeset
72 case Assembler::jmpl_op3:
a61af66fc99e Initial load
duke
parents:
diff changeset
73 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
74 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
75 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
76 }
a61af66fc99e Initial load
duke
parents:
diff changeset
77 do_non_sethi:;
a61af66fc99e Initial load
duke
parents:
diff changeset
78 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
79 {
a61af66fc99e Initial load
duke
parents:
diff changeset
80 guarantee(Assembler::inv_immed(inst), "must have a simm13 field");
a61af66fc99e Initial load
duke
parents:
diff changeset
81 int simm13 = Assembler::low10((intptr_t)x) + o;
a61af66fc99e Initial load
duke
parents:
diff changeset
82 guarantee(Assembler::is_simm13(simm13), "offset can't overflow simm13");
a61af66fc99e Initial load
duke
parents:
diff changeset
83 inst &= ~Assembler::simm( -1, 13);
a61af66fc99e Initial load
duke
parents:
diff changeset
84 inst |= Assembler::simm(simm13, 13);
2375
d673ef06fe96 7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents: 1972
diff changeset
85 if (verify_only) {
d673ef06fe96 7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents: 1972
diff changeset
86 assert(ip->long_at(0) == inst, "instructions must match");
d673ef06fe96 7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents: 1972
diff changeset
87 } else {
d673ef06fe96 7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents: 1972
diff changeset
88 ip->set_long_at(0, inst);
d673ef06fe96 7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents: 1972
diff changeset
89 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
90 }
a61af66fc99e Initial load
duke
parents:
diff changeset
91 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
92
a61af66fc99e Initial load
duke
parents:
diff changeset
93 case Assembler::branch_op:
a61af66fc99e Initial load
duke
parents:
diff changeset
94 {
a61af66fc99e Initial load
duke
parents:
diff changeset
95 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
96 jint inst2;
a61af66fc99e Initial load
duke
parents:
diff changeset
97 guarantee(Assembler::inv_op2(inst)==Assembler::sethi_op2, "must be sethi");
164
c436414a719e 6703890: Compressed Oops: add LoadNKlass node to generate narrow oops (32-bits) compare instructions
kvn
parents: 0
diff changeset
98 if (format() != 0) {
6848
8e47bac5643a 7054512: Compress class pointers after perm gen removal
roland
parents: 6725
diff changeset
99 assert(type() == relocInfo::oop_type || type() == relocInfo::metadata_type, "only narrow oops or klasses case");
12056
740e263c80c6 8003424: Enable Class Data Sharing for CompressedOops
hseigel
parents: 11041
diff changeset
100 jint np = type() == relocInfo::oop_type ? oopDesc::encode_heap_oop((oop)x) : Klass::encode_klass((Klass*)x);
164
c436414a719e 6703890: Compressed Oops: add LoadNKlass node to generate narrow oops (32-bits) compare instructions
kvn
parents: 0
diff changeset
101 inst &= ~Assembler::hi22(-1);
c436414a719e 6703890: Compressed Oops: add LoadNKlass node to generate narrow oops (32-bits) compare instructions
kvn
parents: 0
diff changeset
102 inst |= Assembler::hi22((intptr_t)np);
2375
d673ef06fe96 7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents: 1972
diff changeset
103 if (verify_only) {
d673ef06fe96 7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents: 1972
diff changeset
104 assert(ip->long_at(0) == inst, "instructions must match");
d673ef06fe96 7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents: 1972
diff changeset
105 } else {
d673ef06fe96 7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents: 1972
diff changeset
106 ip->set_long_at(0, inst);
d673ef06fe96 7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents: 1972
diff changeset
107 }
164
c436414a719e 6703890: Compressed Oops: add LoadNKlass node to generate narrow oops (32-bits) compare instructions
kvn
parents: 0
diff changeset
108 inst2 = ip->long_at( NativeInstruction::nop_instruction_size );
c436414a719e 6703890: Compressed Oops: add LoadNKlass node to generate narrow oops (32-bits) compare instructions
kvn
parents: 0
diff changeset
109 guarantee(Assembler::inv_op(inst2)==Assembler::arith_op, "arith op");
2375
d673ef06fe96 7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents: 1972
diff changeset
110 if (verify_only) {
d673ef06fe96 7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents: 1972
diff changeset
111 assert(ip->long_at(NativeInstruction::nop_instruction_size) == NativeInstruction::set_data32_simm13( inst2, (intptr_t)np),
d673ef06fe96 7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents: 1972
diff changeset
112 "instructions must match");
d673ef06fe96 7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents: 1972
diff changeset
113 } else {
d673ef06fe96 7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents: 1972
diff changeset
114 ip->set_long_at(NativeInstruction::nop_instruction_size, NativeInstruction::set_data32_simm13( inst2, (intptr_t)np));
d673ef06fe96 7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents: 1972
diff changeset
115 }
164
c436414a719e 6703890: Compressed Oops: add LoadNKlass node to generate narrow oops (32-bits) compare instructions
kvn
parents: 0
diff changeset
116 break;
c436414a719e 6703890: Compressed Oops: add LoadNKlass node to generate narrow oops (32-bits) compare instructions
kvn
parents: 0
diff changeset
117 }
2375
d673ef06fe96 7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents: 1972
diff changeset
118 if (verify_only) {
d673ef06fe96 7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents: 1972
diff changeset
119 ip->verify_data64_sethi( ip->addr_at(0), (intptr_t)x );
d673ef06fe96 7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents: 1972
diff changeset
120 } else {
d673ef06fe96 7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents: 1972
diff changeset
121 ip->set_data64_sethi( ip->addr_at(0), (intptr_t)x );
d673ef06fe96 7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents: 1972
diff changeset
122 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
123 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
124 guarantee(Assembler::inv_op2(inst)==Assembler::sethi_op2, "must be sethi");
a61af66fc99e Initial load
duke
parents:
diff changeset
125 inst &= ~Assembler::hi22( -1);
a61af66fc99e Initial load
duke
parents:
diff changeset
126 inst |= Assembler::hi22((intptr_t)x);
a61af66fc99e Initial load
duke
parents:
diff changeset
127 // (ignore offset; it doesn't play into the sethi)
2375
d673ef06fe96 7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents: 1972
diff changeset
128 if (verify_only) {
d673ef06fe96 7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents: 1972
diff changeset
129 assert(ip->long_at(0) == inst, "instructions must match");
d673ef06fe96 7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents: 1972
diff changeset
130 } else {
d673ef06fe96 7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents: 1972
diff changeset
131 ip->set_long_at(0, inst);
d673ef06fe96 7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents: 1972
diff changeset
132 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
133 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
134 }
a61af66fc99e Initial load
duke
parents:
diff changeset
135 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
136
a61af66fc99e Initial load
duke
parents:
diff changeset
137 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
138 guarantee(false, "instruction must perform arithmetic or memory access");
a61af66fc99e Initial load
duke
parents:
diff changeset
139 }
a61af66fc99e Initial load
duke
parents:
diff changeset
140 }
a61af66fc99e Initial load
duke
parents:
diff changeset
141
a61af66fc99e Initial load
duke
parents:
diff changeset
142
a61af66fc99e Initial load
duke
parents:
diff changeset
143 address Relocation::pd_call_destination(address orig_addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
144 intptr_t adj = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
145 if (orig_addr != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
146 // We just moved this call instruction from orig_addr to addr().
a61af66fc99e Initial load
duke
parents:
diff changeset
147 // This means its target will appear to have grown by addr() - orig_addr.
a61af66fc99e Initial load
duke
parents:
diff changeset
148 adj = -( addr() - orig_addr );
a61af66fc99e Initial load
duke
parents:
diff changeset
149 }
a61af66fc99e Initial load
duke
parents:
diff changeset
150 if (NativeCall::is_call_at(addr())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
151 NativeCall* call = nativeCall_at(addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
152 return call->destination() + adj;
a61af66fc99e Initial load
duke
parents:
diff changeset
153 }
a61af66fc99e Initial load
duke
parents:
diff changeset
154 if (NativeFarCall::is_call_at(addr())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
155 NativeFarCall* call = nativeFarCall_at(addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
156 return call->destination() + adj;
a61af66fc99e Initial load
duke
parents:
diff changeset
157 }
a61af66fc99e Initial load
duke
parents:
diff changeset
158 // Special case: Patchable branch local to the code cache.
a61af66fc99e Initial load
duke
parents:
diff changeset
159 // This will break badly if the code cache grows larger than a few Mb.
a61af66fc99e Initial load
duke
parents:
diff changeset
160 NativeGeneralJump* br = nativeGeneralJump_at(addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
161 return br->jump_destination() + adj;
a61af66fc99e Initial load
duke
parents:
diff changeset
162 }
a61af66fc99e Initial load
duke
parents:
diff changeset
163
a61af66fc99e Initial load
duke
parents:
diff changeset
164
a61af66fc99e Initial load
duke
parents:
diff changeset
165 void Relocation::pd_set_call_destination(address x) {
a61af66fc99e Initial load
duke
parents:
diff changeset
166 if (NativeCall::is_call_at(addr())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
167 NativeCall* call = nativeCall_at(addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
168 call->set_destination(x);
a61af66fc99e Initial load
duke
parents:
diff changeset
169 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
170 }
a61af66fc99e Initial load
duke
parents:
diff changeset
171 if (NativeFarCall::is_call_at(addr())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
172 NativeFarCall* call = nativeFarCall_at(addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
173 call->set_destination(x);
a61af66fc99e Initial load
duke
parents:
diff changeset
174 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
175 }
a61af66fc99e Initial load
duke
parents:
diff changeset
176 // Special case: Patchable branch local to the code cache.
a61af66fc99e Initial load
duke
parents:
diff changeset
177 // This will break badly if the code cache grows larger than a few Mb.
a61af66fc99e Initial load
duke
parents:
diff changeset
178 NativeGeneralJump* br = nativeGeneralJump_at(addr());
a61af66fc99e Initial load
duke
parents:
diff changeset
179 br->set_jump_destination(x);
a61af66fc99e Initial load
duke
parents:
diff changeset
180 }
a61af66fc99e Initial load
duke
parents:
diff changeset
181
a61af66fc99e Initial load
duke
parents:
diff changeset
182
a61af66fc99e Initial load
duke
parents:
diff changeset
183 address* Relocation::pd_address_in_code() {
a61af66fc99e Initial load
duke
parents:
diff changeset
184 // SPARC never embeds addresses in code, at present.
a61af66fc99e Initial load
duke
parents:
diff changeset
185 //assert(type() == relocInfo::oop_type, "only oops are inlined at present");
a61af66fc99e Initial load
duke
parents:
diff changeset
186 return (address*)addr();
a61af66fc99e Initial load
duke
parents:
diff changeset
187 }
a61af66fc99e Initial load
duke
parents:
diff changeset
188
a61af66fc99e Initial load
duke
parents:
diff changeset
189
a61af66fc99e Initial load
duke
parents:
diff changeset
190 address Relocation::pd_get_address_from_code() {
a61af66fc99e Initial load
duke
parents:
diff changeset
191 // SPARC never embeds addresses in code, at present.
a61af66fc99e Initial load
duke
parents:
diff changeset
192 //assert(type() == relocInfo::oop_type, "only oops are inlined at present");
a61af66fc99e Initial load
duke
parents:
diff changeset
193 return *(address*)addr();
a61af66fc99e Initial load
duke
parents:
diff changeset
194 }
a61af66fc99e Initial load
duke
parents:
diff changeset
195
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
196 void poll_Relocation::fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
197 }
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
198
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
199 void poll_return_Relocation::fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) {
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 196
diff changeset
200 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 2426
diff changeset
201
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 2426
diff changeset
202 void metadata_Relocation::pd_fix_value(address x) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 2426
diff changeset
203 }