author | naoto |
Tue, 09 Jul 2019 08:05:38 -0700 | |
changeset 55627 | 9c1885fb2a42 |
parent 54786 | ebf733a324d4 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
53686 | 2 |
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. |
1 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
14626
0cf4eccf130f
8003240: x86: move MacroAssembler into separate file
twisti
parents:
13728
diff
changeset
|
26 |
#include "code/codeCache.hpp" |
7397 | 27 |
#include "code/compiledIC.hpp" |
28 |
#include "code/nmethod.hpp" |
|
29 |
#include "code/relocInfo.hpp" |
|
30 |
#include "memory/resourceArea.hpp" |
|
54786 | 31 |
#include "memory/universe.hpp" |
49592
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
47765
diff
changeset
|
32 |
#include "oops/compressedOops.inline.hpp" |
49902
3661f31c6df4
8202150: [REDO] Split globals.hpp to factor out the Flag class
gziemski
parents:
49860
diff
changeset
|
33 |
#include "runtime/flags/flagSetting.hpp" |
7397 | 34 |
#include "runtime/stubCodeGenerator.hpp" |
35 |
#include "utilities/copy.hpp" |
|
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
24952
diff
changeset
|
36 |
#include "oops/oop.inline.hpp" |
1 | 37 |
|
38 |
const RelocationHolder RelocationHolder::none; // its type is relocInfo::none |
|
39 |
||
40 |
||
41 |
// Implementation of relocInfo |
|
42 |
||
43 |
#ifdef ASSERT |
|
44 |
relocInfo::relocInfo(relocType t, int off, int f) { |
|
45 |
assert(t != data_prefix_tag, "cannot build a prefix this way"); |
|
46 |
assert((t & type_mask) == t, "wrong type"); |
|
47 |
assert((f & format_mask) == f, "wrong format"); |
|
48 |
assert(off >= 0 && off < offset_limit(), "offset out off bounds"); |
|
49 |
assert((off & (offset_unit-1)) == 0, "misaligned offset"); |
|
50 |
(*this) = relocInfo(t, RAW_BITS, off, f); |
|
51 |
} |
|
52 |
#endif |
|
53 |
||
54 |
void relocInfo::initialize(CodeSection* dest, Relocation* reloc) { |
|
55 |
relocInfo* data = this+1; // here's where the data might go |
|
56 |
dest->set_locs_end(data); // sync end: the next call may read dest.locs_end |
|
57 |
reloc->pack_data_to(dest); // maybe write data into locs, advancing locs_end |
|
58 |
relocInfo* data_limit = dest->locs_end(); |
|
59 |
if (data_limit > data) { |
|
60 |
relocInfo suffix = (*this); |
|
61 |
data_limit = this->finish_prefix((short*) data_limit); |
|
62 |
// Finish up with the suffix. (Hack note: pack_data_to might edit this.) |
|
63 |
*data_limit = suffix; |
|
64 |
dest->set_locs_end(data_limit+1); |
|
65 |
} |
|
66 |
} |
|
67 |
||
68 |
relocInfo* relocInfo::finish_prefix(short* prefix_limit) { |
|
69 |
assert(sizeof(relocInfo) == sizeof(short), "change this code"); |
|
70 |
short* p = (short*)(this+1); |
|
71 |
assert(prefix_limit >= p, "must be a valid span of data"); |
|
72 |
int plen = prefix_limit - p; |
|
73 |
if (plen == 0) { |
|
74 |
debug_only(_value = 0xFFFF); |
|
75 |
return this; // no data: remove self completely |
|
76 |
} |
|
77 |
if (plen == 1 && fits_into_immediate(p[0])) { |
|
78 |
(*this) = immediate_relocInfo(p[0]); // move data inside self |
|
79 |
return this+1; |
|
80 |
} |
|
81 |
// cannot compact, so just update the count and return the limit pointer |
|
82 |
(*this) = prefix_relocInfo(plen); // write new datalen |
|
83 |
assert(data() + datalen() == prefix_limit, "pointers must line up"); |
|
84 |
return (relocInfo*)prefix_limit; |
|
85 |
} |
|
86 |
||
87 |
void relocInfo::set_type(relocType t) { |
|
88 |
int old_offset = addr_offset(); |
|
89 |
int old_format = format(); |
|
90 |
(*this) = relocInfo(t, old_offset, old_format); |
|
91 |
assert(type()==(int)t, "sanity check"); |
|
92 |
assert(addr_offset()==old_offset, "sanity check"); |
|
93 |
assert(format()==old_format, "sanity check"); |
|
94 |
} |
|
95 |
||
96 |
void relocInfo::change_reloc_info_for_address(RelocIterator *itr, address pc, relocType old_type, relocType new_type) { |
|
97 |
bool found = false; |
|
98 |
while (itr->next() && !found) { |
|
99 |
if (itr->addr() == pc) { |
|
100 |
assert(itr->type()==old_type, "wrong relocInfo type found"); |
|
101 |
itr->current()->set_type(new_type); |
|
102 |
found=true; |
|
103 |
} |
|
104 |
} |
|
105 |
assert(found, "no relocInfo found for pc"); |
|
106 |
} |
|
107 |
||
108 |
||
109 |
// ---------------------------------------------------------------------------------------------------- |
|
110 |
// Implementation of RelocIterator |
|
111 |
||
38133
78b95467b9f1
8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
36301
diff
changeset
|
112 |
void RelocIterator::initialize(CompiledMethod* nm, address begin, address limit) { |
1 | 113 |
initialize_misc(); |
114 |
||
5686
5435e77aa3df
6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents:
1
diff
changeset
|
115 |
if (nm == NULL && begin != NULL) { |
5435e77aa3df
6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents:
1
diff
changeset
|
116 |
// allow nmethod to be deduced from beginning address |
5435e77aa3df
6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents:
1
diff
changeset
|
117 |
CodeBlob* cb = CodeCache::find_blob(begin); |
45325
2cded43c8842
8180813: Null pointer dereference of CodeCache::find_blob() result
thartmann
parents:
42650
diff
changeset
|
118 |
nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL; |
1 | 119 |
} |
45325
2cded43c8842
8180813: Null pointer dereference of CodeCache::find_blob() result
thartmann
parents:
42650
diff
changeset
|
120 |
guarantee(nm != NULL, "must be able to deduce nmethod from other arguments"); |
1 | 121 |
|
5686
5435e77aa3df
6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents:
1
diff
changeset
|
122 |
_code = nm; |
5435e77aa3df
6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents:
1
diff
changeset
|
123 |
_current = nm->relocation_begin() - 1; |
5435e77aa3df
6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents:
1
diff
changeset
|
124 |
_end = nm->relocation_end(); |
6432
d36e09b60939
6961697: move nmethod constants section before instruction section
twisti
parents:
6418
diff
changeset
|
125 |
_addr = nm->content_begin(); |
d36e09b60939
6961697: move nmethod constants section before instruction section
twisti
parents:
6418
diff
changeset
|
126 |
|
d36e09b60939
6961697: move nmethod constants section before instruction section
twisti
parents:
6418
diff
changeset
|
127 |
// Initialize code sections. |
d36e09b60939
6961697: move nmethod constants section before instruction section
twisti
parents:
6418
diff
changeset
|
128 |
_section_start[CodeBuffer::SECT_CONSTS] = nm->consts_begin(); |
d36e09b60939
6961697: move nmethod constants section before instruction section
twisti
parents:
6418
diff
changeset
|
129 |
_section_start[CodeBuffer::SECT_INSTS ] = nm->insts_begin() ; |
d36e09b60939
6961697: move nmethod constants section before instruction section
twisti
parents:
6418
diff
changeset
|
130 |
_section_start[CodeBuffer::SECT_STUBS ] = nm->stub_begin() ; |
d36e09b60939
6961697: move nmethod constants section before instruction section
twisti
parents:
6418
diff
changeset
|
131 |
|
d36e09b60939
6961697: move nmethod constants section before instruction section
twisti
parents:
6418
diff
changeset
|
132 |
_section_end [CodeBuffer::SECT_CONSTS] = nm->consts_end() ; |
d36e09b60939
6961697: move nmethod constants section before instruction section
twisti
parents:
6418
diff
changeset
|
133 |
_section_end [CodeBuffer::SECT_INSTS ] = nm->insts_end() ; |
d36e09b60939
6961697: move nmethod constants section before instruction section
twisti
parents:
6418
diff
changeset
|
134 |
_section_end [CodeBuffer::SECT_STUBS ] = nm->stub_end() ; |
1 | 135 |
|
136 |
assert(!has_current(), "just checking"); |
|
6418 | 137 |
assert(begin == NULL || begin >= nm->code_begin(), "in bounds"); |
138 |
assert(limit == NULL || limit <= nm->code_end(), "in bounds"); |
|
1 | 139 |
set_limits(begin, limit); |
140 |
} |
|
141 |
||
142 |
||
143 |
RelocIterator::RelocIterator(CodeSection* cs, address begin, address limit) { |
|
144 |
initialize_misc(); |
|
145 |
||
146 |
_current = cs->locs_start()-1; |
|
147 |
_end = cs->locs_end(); |
|
148 |
_addr = cs->start(); |
|
149 |
_code = NULL; // Not cb->blob(); |
|
150 |
||
151 |
CodeBuffer* cb = cs->outer(); |
|
6432
d36e09b60939
6961697: move nmethod constants section before instruction section
twisti
parents:
6418
diff
changeset
|
152 |
assert((int) SECT_LIMIT == CodeBuffer::SECT_LIMIT, "my copy must be equal"); |
d36e09b60939
6961697: move nmethod constants section before instruction section
twisti
parents:
6418
diff
changeset
|
153 |
for (int n = (int) CodeBuffer::SECT_FIRST; n < (int) CodeBuffer::SECT_LIMIT; n++) { |
d36e09b60939
6961697: move nmethod constants section before instruction section
twisti
parents:
6418
diff
changeset
|
154 |
CodeSection* cs = cb->code_section(n); |
d36e09b60939
6961697: move nmethod constants section before instruction section
twisti
parents:
6418
diff
changeset
|
155 |
_section_start[n] = cs->start(); |
d36e09b60939
6961697: move nmethod constants section before instruction section
twisti
parents:
6418
diff
changeset
|
156 |
_section_end [n] = cs->end(); |
1 | 157 |
} |
158 |
||
159 |
assert(!has_current(), "just checking"); |
|
160 |
||
161 |
assert(begin == NULL || begin >= cs->start(), "in bounds"); |
|
162 |
assert(limit == NULL || limit <= cs->end(), "in bounds"); |
|
163 |
set_limits(begin, limit); |
|
164 |
} |
|
165 |
||
6432
d36e09b60939
6961697: move nmethod constants section before instruction section
twisti
parents:
6418
diff
changeset
|
166 |
bool RelocIterator::addr_in_const() const { |
d36e09b60939
6961697: move nmethod constants section before instruction section
twisti
parents:
6418
diff
changeset
|
167 |
const int n = CodeBuffer::SECT_CONSTS; |
d36e09b60939
6961697: move nmethod constants section before instruction section
twisti
parents:
6418
diff
changeset
|
168 |
return section_start(n) <= addr() && addr() < section_end(n); |
d36e09b60939
6961697: move nmethod constants section before instruction section
twisti
parents:
6418
diff
changeset
|
169 |
} |
d36e09b60939
6961697: move nmethod constants section before instruction section
twisti
parents:
6418
diff
changeset
|
170 |
|
d36e09b60939
6961697: move nmethod constants section before instruction section
twisti
parents:
6418
diff
changeset
|
171 |
|
1 | 172 |
void RelocIterator::set_limits(address begin, address limit) { |
173 |
_limit = limit; |
|
174 |
||
175 |
// the limit affects this next stuff: |
|
176 |
if (begin != NULL) { |
|
177 |
relocInfo* backup; |
|
178 |
address backup_addr; |
|
179 |
while (true) { |
|
180 |
backup = _current; |
|
181 |
backup_addr = _addr; |
|
182 |
if (!next() || addr() >= begin) break; |
|
183 |
} |
|
184 |
// At this point, either we are at the first matching record, |
|
185 |
// or else there is no such record, and !has_current(). |
|
186 |
// In either case, revert to the immediatly preceding state. |
|
187 |
_current = backup; |
|
188 |
_addr = backup_addr; |
|
189 |
set_has_current(false); |
|
190 |
} |
|
191 |
} |
|
192 |
||
193 |
||
194 |
// All the strange bit-encodings are in here. |
|
195 |
// The idea is to encode relocation data which are small integers |
|
196 |
// very efficiently (a single extra halfword). Larger chunks of |
|
197 |
// relocation data need a halfword header to hold their size. |
|
198 |
void RelocIterator::advance_over_prefix() { |
|
199 |
if (_current->is_datalen()) { |
|
200 |
_data = (short*) _current->data(); |
|
201 |
_datalen = _current->datalen(); |
|
202 |
_current += _datalen + 1; // skip the embedded data & header |
|
203 |
} else { |
|
204 |
_databuf = _current->immediate(); |
|
205 |
_data = &_databuf; |
|
206 |
_datalen = 1; |
|
207 |
_current++; // skip the header |
|
208 |
} |
|
209 |
// The client will see the following relocInfo, whatever that is. |
|
210 |
// It is the reloc to which the preceding data applies. |
|
211 |
} |
|
212 |
||
213 |
||
6432
d36e09b60939
6961697: move nmethod constants section before instruction section
twisti
parents:
6418
diff
changeset
|
214 |
void RelocIterator::initialize_misc() { |
d36e09b60939
6961697: move nmethod constants section before instruction section
twisti
parents:
6418
diff
changeset
|
215 |
set_has_current(false); |
d36e09b60939
6961697: move nmethod constants section before instruction section
twisti
parents:
6418
diff
changeset
|
216 |
for (int i = (int) CodeBuffer::SECT_FIRST; i < (int) CodeBuffer::SECT_LIMIT; i++) { |
d36e09b60939
6961697: move nmethod constants section before instruction section
twisti
parents:
6418
diff
changeset
|
217 |
_section_start[i] = NULL; // these will be lazily computed, if needed |
d36e09b60939
6961697: move nmethod constants section before instruction section
twisti
parents:
6418
diff
changeset
|
218 |
_section_end [i] = NULL; |
1 | 219 |
} |
220 |
} |
|
221 |
||
222 |
||
223 |
Relocation* RelocIterator::reloc() { |
|
224 |
// (take the "switch" out-of-line) |
|
225 |
relocInfo::relocType t = type(); |
|
226 |
if (false) {} |
|
227 |
#define EACH_TYPE(name) \ |
|
228 |
else if (t == relocInfo::name##_type) { \ |
|
229 |
return name##_reloc(); \ |
|
230 |
} |
|
231 |
APPLY_TO_RELOCATIONS(EACH_TYPE); |
|
232 |
#undef EACH_TYPE |
|
233 |
assert(t == relocInfo::none, "must be padding"); |
|
234 |
return new(_rh) Relocation(); |
|
235 |
} |
|
236 |
||
237 |
||
238 |
//////// Methods for flyweight Relocation types |
|
239 |
||
240 |
||
241 |
RelocationHolder RelocationHolder::plus(int offset) const { |
|
242 |
if (offset != 0) { |
|
243 |
switch (type()) { |
|
244 |
case relocInfo::none: |
|
245 |
break; |
|
246 |
case relocInfo::oop_type: |
|
247 |
{ |
|
248 |
oop_Relocation* r = (oop_Relocation*)reloc(); |
|
249 |
return oop_Relocation::spec(r->oop_index(), r->offset() + offset); |
|
250 |
} |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
251 |
case relocInfo::metadata_type: |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
252 |
{ |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
253 |
metadata_Relocation* r = (metadata_Relocation*)reloc(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
254 |
return metadata_Relocation::spec(r->metadata_index(), r->offset() + offset); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
255 |
} |
1 | 256 |
default: |
257 |
ShouldNotReachHere(); |
|
258 |
} |
|
259 |
} |
|
260 |
return (*this); |
|
261 |
} |
|
262 |
||
263 |
||
264 |
void Relocation::guarantee_size() { |
|
265 |
guarantee(false, "Make _relocbuf bigger!"); |
|
266 |
} |
|
267 |
||
268 |
// some relocations can compute their own values |
|
269 |
address Relocation::value() { |
|
270 |
ShouldNotReachHere(); |
|
271 |
return NULL; |
|
272 |
} |
|
273 |
||
274 |
||
275 |
void Relocation::set_value(address x) { |
|
276 |
ShouldNotReachHere(); |
|
277 |
} |
|
278 |
||
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
24952
diff
changeset
|
279 |
void Relocation::const_set_data_value(address x) { |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
24952
diff
changeset
|
280 |
#ifdef _LP64 |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
24952
diff
changeset
|
281 |
if (format() == relocInfo::narrow_oop_in_const) { |
49592
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
47765
diff
changeset
|
282 |
*(narrowOop*)addr() = CompressedOops::encode((oop) x); |
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
24952
diff
changeset
|
283 |
} else { |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
24952
diff
changeset
|
284 |
#endif |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
24952
diff
changeset
|
285 |
*(address*)addr() = x; |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
24952
diff
changeset
|
286 |
#ifdef _LP64 |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
24952
diff
changeset
|
287 |
} |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
24952
diff
changeset
|
288 |
#endif |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
24952
diff
changeset
|
289 |
} |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
24952
diff
changeset
|
290 |
|
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
24952
diff
changeset
|
291 |
void Relocation::const_verify_data_value(address x) { |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
24952
diff
changeset
|
292 |
#ifdef _LP64 |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
24952
diff
changeset
|
293 |
if (format() == relocInfo::narrow_oop_in_const) { |
49592
77fb0be7d19f
8199946: Move load/store and encode/decode out of oopDesc
stefank
parents:
47765
diff
changeset
|
294 |
guarantee(*(narrowOop*)addr() == CompressedOops::encode((oop) x), "must agree"); |
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
24952
diff
changeset
|
295 |
} else { |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
24952
diff
changeset
|
296 |
#endif |
33807
9f8b0f8a3f29
8140584: nmethod::oops_do_marking_epilogue always runs verification code
stefank
parents:
33198
diff
changeset
|
297 |
guarantee(*(address*)addr() == x, "must agree"); |
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
24952
diff
changeset
|
298 |
#ifdef _LP64 |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
24952
diff
changeset
|
299 |
} |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
24952
diff
changeset
|
300 |
#endif |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
24952
diff
changeset
|
301 |
} |
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
24952
diff
changeset
|
302 |
|
1 | 303 |
|
304 |
RelocationHolder Relocation::spec_simple(relocInfo::relocType rtype) { |
|
305 |
if (rtype == relocInfo::none) return RelocationHolder::none; |
|
306 |
relocInfo ri = relocInfo(rtype, 0); |
|
307 |
RelocIterator itr; |
|
308 |
itr.set_current(ri); |
|
309 |
itr.reloc(); |
|
310 |
return itr._rh; |
|
311 |
} |
|
312 |
||
313 |
address Relocation::old_addr_for(address newa, |
|
314 |
const CodeBuffer* src, CodeBuffer* dest) { |
|
315 |
int sect = dest->section_index_of(newa); |
|
316 |
guarantee(sect != CodeBuffer::SECT_NONE, "lost track of this address"); |
|
317 |
address ostart = src->code_section(sect)->start(); |
|
318 |
address nstart = dest->code_section(sect)->start(); |
|
319 |
return ostart + (newa - nstart); |
|
320 |
} |
|
321 |
||
322 |
address Relocation::new_addr_for(address olda, |
|
323 |
const CodeBuffer* src, CodeBuffer* dest) { |
|
324 |
debug_only(const CodeBuffer* src0 = src); |
|
325 |
int sect = CodeBuffer::SECT_NONE; |
|
326 |
// Look for olda in the source buffer, and all previous incarnations |
|
327 |
// if the source buffer has been expanded. |
|
328 |
for (; src != NULL; src = src->before_expand()) { |
|
329 |
sect = src->section_index_of(olda); |
|
330 |
if (sect != CodeBuffer::SECT_NONE) break; |
|
331 |
} |
|
332 |
guarantee(sect != CodeBuffer::SECT_NONE, "lost track of this address"); |
|
333 |
address ostart = src->code_section(sect)->start(); |
|
334 |
address nstart = dest->code_section(sect)->start(); |
|
335 |
return nstart + (olda - ostart); |
|
336 |
} |
|
337 |
||
338 |
void Relocation::normalize_address(address& addr, const CodeSection* dest, bool allow_other_sections) { |
|
339 |
address addr0 = addr; |
|
340 |
if (addr0 == NULL || dest->allocates2(addr0)) return; |
|
341 |
CodeBuffer* cb = dest->outer(); |
|
342 |
addr = new_addr_for(addr0, cb, cb); |
|
343 |
assert(allow_other_sections || dest->contains2(addr), |
|
344 |
"addr must be in required section"); |
|
345 |
} |
|
346 |
||
347 |
||
348 |
void CallRelocation::set_destination(address x) { |
|
349 |
pd_set_call_destination(x); |
|
350 |
} |
|
351 |
||
352 |
void CallRelocation::fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) { |
|
353 |
// Usually a self-relative reference to an external routine. |
|
354 |
// On some platforms, the reference is absolute (not self-relative). |
|
355 |
// The enhanced use of pd_call_destination sorts this all out. |
|
356 |
address orig_addr = old_addr_for(addr(), src, dest); |
|
357 |
address callee = pd_call_destination(orig_addr); |
|
358 |
// Reassert the callee address, this time in the new copy of the code. |
|
359 |
pd_set_call_destination(callee); |
|
360 |
} |
|
361 |
||
362 |
||
363 |
//// pack/unpack methods |
|
364 |
||
365 |
void oop_Relocation::pack_data_to(CodeSection* dest) { |
|
366 |
short* p = (short*) dest->locs_end(); |
|
367 |
p = pack_2_ints_to(p, _oop_index, _offset); |
|
368 |
dest->set_locs_end((relocInfo*) p); |
|
369 |
} |
|
370 |
||
371 |
||
372 |
void oop_Relocation::unpack_data() { |
|
373 |
unpack_2_ints(_oop_index, _offset); |
|
374 |
} |
|
375 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
376 |
void metadata_Relocation::pack_data_to(CodeSection* dest) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
377 |
short* p = (short*) dest->locs_end(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
378 |
p = pack_2_ints_to(p, _metadata_index, _offset); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
379 |
dest->set_locs_end((relocInfo*) p); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
380 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
381 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
382 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
383 |
void metadata_Relocation::unpack_data() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
384 |
unpack_2_ints(_metadata_index, _offset); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
385 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
386 |
|
1 | 387 |
|
388 |
void virtual_call_Relocation::pack_data_to(CodeSection* dest) { |
|
389 |
short* p = (short*) dest->locs_end(); |
|
390 |
address point = dest->locs_point(); |
|
391 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
392 |
normalize_address(_cached_value, dest); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
393 |
jint x0 = scaled_offset_null_special(_cached_value, point); |
35086
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
394 |
p = pack_2_ints_to(p, x0, _method_index); |
1 | 395 |
dest->set_locs_end((relocInfo*) p); |
396 |
} |
|
397 |
||
398 |
||
399 |
void virtual_call_Relocation::unpack_data() { |
|
35086
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
400 |
jint x0 = 0; |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
401 |
unpack_2_ints(x0, _method_index); |
1 | 402 |
address point = addr(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
403 |
_cached_value = x0==0? NULL: address_from_scaled_offset(x0, point); |
1 | 404 |
} |
405 |
||
42064
a530dbabe64f
8167184: [s390] Extend relocations for pc-relative instructions.
goetz
parents:
42044
diff
changeset
|
406 |
void runtime_call_w_cp_Relocation::pack_data_to(CodeSection * dest) { |
a530dbabe64f
8167184: [s390] Extend relocations for pc-relative instructions.
goetz
parents:
42044
diff
changeset
|
407 |
short* p = pack_1_int_to((short *)dest->locs_end(), (jint)(_offset >> 2)); |
a530dbabe64f
8167184: [s390] Extend relocations for pc-relative instructions.
goetz
parents:
42044
diff
changeset
|
408 |
dest->set_locs_end((relocInfo*) p); |
a530dbabe64f
8167184: [s390] Extend relocations for pc-relative instructions.
goetz
parents:
42044
diff
changeset
|
409 |
} |
a530dbabe64f
8167184: [s390] Extend relocations for pc-relative instructions.
goetz
parents:
42044
diff
changeset
|
410 |
|
a530dbabe64f
8167184: [s390] Extend relocations for pc-relative instructions.
goetz
parents:
42044
diff
changeset
|
411 |
void runtime_call_w_cp_Relocation::unpack_data() { |
a530dbabe64f
8167184: [s390] Extend relocations for pc-relative instructions.
goetz
parents:
42044
diff
changeset
|
412 |
_offset = unpack_1_int() << 2; |
a530dbabe64f
8167184: [s390] Extend relocations for pc-relative instructions.
goetz
parents:
42044
diff
changeset
|
413 |
} |
1 | 414 |
|
415 |
void static_stub_Relocation::pack_data_to(CodeSection* dest) { |
|
416 |
short* p = (short*) dest->locs_end(); |
|
417 |
CodeSection* insts = dest->outer()->insts(); |
|
418 |
normalize_address(_static_call, insts); |
|
42650 | 419 |
jint is_aot = _is_aot ? 1 : 0; |
420 |
p = pack_2_ints_to(p, scaled_offset(_static_call, insts->start()), is_aot); |
|
1 | 421 |
dest->set_locs_end((relocInfo*) p); |
422 |
} |
|
423 |
||
424 |
void static_stub_Relocation::unpack_data() { |
|
425 |
address base = binding()->section_start(CodeBuffer::SECT_INSTS); |
|
42650 | 426 |
jint offset; |
427 |
jint is_aot; |
|
428 |
unpack_2_ints(offset, is_aot); |
|
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
24952
diff
changeset
|
429 |
_static_call = address_from_scaled_offset(offset, base); |
42650 | 430 |
_is_aot = (is_aot == 1); |
1 | 431 |
} |
432 |
||
22813
422557569a6b
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
18446
diff
changeset
|
433 |
void trampoline_stub_Relocation::pack_data_to(CodeSection* dest ) { |
422557569a6b
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
18446
diff
changeset
|
434 |
short* p = (short*) dest->locs_end(); |
422557569a6b
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
18446
diff
changeset
|
435 |
CodeSection* insts = dest->outer()->insts(); |
422557569a6b
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
18446
diff
changeset
|
436 |
normalize_address(_owner, insts); |
422557569a6b
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
18446
diff
changeset
|
437 |
p = pack_1_int_to(p, scaled_offset(_owner, insts->start())); |
422557569a6b
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
18446
diff
changeset
|
438 |
dest->set_locs_end((relocInfo*) p); |
422557569a6b
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
18446
diff
changeset
|
439 |
} |
422557569a6b
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
18446
diff
changeset
|
440 |
|
422557569a6b
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
18446
diff
changeset
|
441 |
void trampoline_stub_Relocation::unpack_data() { |
422557569a6b
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
18446
diff
changeset
|
442 |
address base = binding()->section_start(CodeBuffer::SECT_INSTS); |
422557569a6b
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
18446
diff
changeset
|
443 |
_owner = address_from_scaled_offset(unpack_1_int(), base); |
422557569a6b
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
18446
diff
changeset
|
444 |
} |
1 | 445 |
|
446 |
void external_word_Relocation::pack_data_to(CodeSection* dest) { |
|
447 |
short* p = (short*) dest->locs_end(); |
|
448 |
#ifndef _LP64 |
|
36301
cb578d8c6cba
8149741: Don't refer to stub entry points by index in external_word relocations
vlivanov
parents:
35086
diff
changeset
|
449 |
p = pack_1_int_to(p, (int32_t) (intptr_t)_target); |
1 | 450 |
#else |
36301
cb578d8c6cba
8149741: Don't refer to stub entry points by index in external_word relocations
vlivanov
parents:
35086
diff
changeset
|
451 |
jlong t = (jlong) _target; |
cb578d8c6cba
8149741: Don't refer to stub entry points by index in external_word relocations
vlivanov
parents:
35086
diff
changeset
|
452 |
int32_t lo = low(t); |
cb578d8c6cba
8149741: Don't refer to stub entry points by index in external_word relocations
vlivanov
parents:
35086
diff
changeset
|
453 |
int32_t hi = high(t); |
cb578d8c6cba
8149741: Don't refer to stub entry points by index in external_word relocations
vlivanov
parents:
35086
diff
changeset
|
454 |
p = pack_2_ints_to(p, lo, hi); |
1 | 455 |
#endif /* _LP64 */ |
456 |
dest->set_locs_end((relocInfo*) p); |
|
457 |
} |
|
458 |
||
459 |
||
460 |
void external_word_Relocation::unpack_data() { |
|
461 |
#ifndef _LP64 |
|
36301
cb578d8c6cba
8149741: Don't refer to stub entry points by index in external_word relocations
vlivanov
parents:
35086
diff
changeset
|
462 |
_target = (address) (intptr_t)unpack_1_int(); |
1 | 463 |
#else |
47765
b7c7428eaab9
8189610: Reconcile jvm.h and all jvm_md.h between java.base and hotspot
coleenp
parents:
47216
diff
changeset
|
464 |
jint lo, hi; |
1 | 465 |
unpack_2_ints(lo, hi); |
466 |
jlong t = jlong_from(hi, lo);; |
|
36301
cb578d8c6cba
8149741: Don't refer to stub entry points by index in external_word relocations
vlivanov
parents:
35086
diff
changeset
|
467 |
_target = (address) t; |
1 | 468 |
#endif /* _LP64 */ |
469 |
} |
|
470 |
||
471 |
||
472 |
void internal_word_Relocation::pack_data_to(CodeSection* dest) { |
|
473 |
short* p = (short*) dest->locs_end(); |
|
474 |
normalize_address(_target, dest, true); |
|
475 |
||
476 |
// Check whether my target address is valid within this section. |
|
477 |
// If not, strengthen the relocation type to point to another section. |
|
478 |
int sindex = _section; |
|
479 |
if (sindex == CodeBuffer::SECT_NONE && _target != NULL |
|
480 |
&& (!dest->allocates(_target) || _target == dest->locs_point())) { |
|
481 |
sindex = dest->outer()->section_index_of(_target); |
|
482 |
guarantee(sindex != CodeBuffer::SECT_NONE, "must belong somewhere"); |
|
483 |
relocInfo* base = dest->locs_end() - 1; |
|
484 |
assert(base->type() == this->type(), "sanity"); |
|
485 |
// Change the written type, to be section_word_type instead. |
|
486 |
base->set_type(relocInfo::section_word_type); |
|
487 |
} |
|
488 |
||
489 |
// Note: An internal_word relocation cannot refer to its own instruction, |
|
490 |
// because we reserve "0" to mean that the pointer itself is embedded |
|
491 |
// in the code stream. We use a section_word relocation for such cases. |
|
492 |
||
493 |
if (sindex == CodeBuffer::SECT_NONE) { |
|
494 |
assert(type() == relocInfo::internal_word_type, "must be base class"); |
|
495 |
guarantee(_target == NULL || dest->allocates2(_target), "must be within the given code section"); |
|
496 |
jint x0 = scaled_offset_null_special(_target, dest->locs_point()); |
|
497 |
assert(!(x0 == 0 && _target != NULL), "correct encoding of null target"); |
|
498 |
p = pack_1_int_to(p, x0); |
|
499 |
} else { |
|
500 |
assert(_target != NULL, "sanity"); |
|
501 |
CodeSection* sect = dest->outer()->code_section(sindex); |
|
502 |
guarantee(sect->allocates2(_target), "must be in correct section"); |
|
503 |
address base = sect->start(); |
|
504 |
jint offset = scaled_offset(_target, base); |
|
505 |
assert((uint)sindex < (uint)CodeBuffer::SECT_LIMIT, "sanity"); |
|
506 |
assert(CodeBuffer::SECT_LIMIT <= (1 << section_width), "section_width++"); |
|
507 |
p = pack_1_int_to(p, (offset << section_width) | sindex); |
|
508 |
} |
|
509 |
||
510 |
dest->set_locs_end((relocInfo*) p); |
|
511 |
} |
|
512 |
||
513 |
||
514 |
void internal_word_Relocation::unpack_data() { |
|
515 |
jint x0 = unpack_1_int(); |
|
516 |
_target = x0==0? NULL: address_from_scaled_offset(x0, addr()); |
|
517 |
_section = CodeBuffer::SECT_NONE; |
|
518 |
} |
|
519 |
||
520 |
||
521 |
void section_word_Relocation::unpack_data() { |
|
522 |
jint x = unpack_1_int(); |
|
523 |
jint offset = (x >> section_width); |
|
524 |
int sindex = (x & ((1<<section_width)-1)); |
|
525 |
address base = binding()->section_start(sindex); |
|
526 |
||
527 |
_section = sindex; |
|
528 |
_target = address_from_scaled_offset(offset, base); |
|
529 |
} |
|
530 |
||
531 |
//// miscellaneous methods |
|
532 |
oop* oop_Relocation::oop_addr() { |
|
533 |
int n = _oop_index; |
|
534 |
if (n == 0) { |
|
535 |
// oop is stored in the code stream |
|
536 |
return (oop*) pd_address_in_code(); |
|
537 |
} else { |
|
5686
5435e77aa3df
6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents:
1
diff
changeset
|
538 |
// oop is stored in table at nmethod::oops_begin |
1 | 539 |
return code()->oop_addr_at(n); |
540 |
} |
|
541 |
} |
|
542 |
||
543 |
||
544 |
oop oop_Relocation::oop_value() { |
|
545 |
oop v = *oop_addr(); |
|
546 |
// clean inline caches store a special pseudo-null |
|
52070 | 547 |
if (v == Universe::non_oop_word()) v = NULL; |
1 | 548 |
return v; |
549 |
} |
|
550 |
||
551 |
||
552 |
void oop_Relocation::fix_oop_relocation() { |
|
553 |
if (!oop_is_immediate()) { |
|
554 |
// get the oop from the pool, and re-insert it into the instruction: |
|
555 |
set_value(value()); |
|
556 |
} |
|
557 |
} |
|
558 |
||
559 |
||
8724
693c6b883b54
7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents:
8107
diff
changeset
|
560 |
void oop_Relocation::verify_oop_relocation() { |
693c6b883b54
7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents:
8107
diff
changeset
|
561 |
if (!oop_is_immediate()) { |
693c6b883b54
7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents:
8107
diff
changeset
|
562 |
// get the oop from the pool, and re-insert it into the instruction: |
693c6b883b54
7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents:
8107
diff
changeset
|
563 |
verify_value(value()); |
693c6b883b54
7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents:
8107
diff
changeset
|
564 |
} |
693c6b883b54
7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents:
8107
diff
changeset
|
565 |
} |
693c6b883b54
7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents:
8107
diff
changeset
|
566 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
567 |
// meta data versions |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
568 |
Metadata** metadata_Relocation::metadata_addr() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
569 |
int n = _metadata_index; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
570 |
if (n == 0) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
571 |
// metadata is stored in the code stream |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
572 |
return (Metadata**) pd_address_in_code(); |
1 | 573 |
} else { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
574 |
// metadata is stored in table at nmethod::metadatas_begin |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
575 |
return code()->metadata_addr_at(n); |
1 | 576 |
} |
577 |
} |
|
578 |
||
579 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
580 |
Metadata* metadata_Relocation::metadata_value() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
581 |
Metadata* v = *metadata_addr(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
582 |
// clean inline caches store a special pseudo-null |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
583 |
if (v == (Metadata*)Universe::non_oop_word()) v = NULL; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
584 |
return v; |
1 | 585 |
} |
586 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
587 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
588 |
void metadata_Relocation::fix_metadata_relocation() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
589 |
if (!metadata_is_immediate()) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
590 |
// get the metadata from the pool, and re-insert it into the instruction: |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
591 |
pd_fix_value(value()); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
592 |
} |
1 | 593 |
} |
594 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
595 |
address virtual_call_Relocation::cached_value() { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
596 |
assert(_cached_value != NULL && _cached_value < addr(), "must precede ic_call"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
597 |
return _cached_value; |
1 | 598 |
} |
599 |
||
35086
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
600 |
Method* virtual_call_Relocation::method_value() { |
42044 | 601 |
CompiledMethod* cm = code(); |
602 |
if (cm == NULL) return (Method*)NULL; |
|
603 |
Metadata* m = cm->metadata_at(_method_index); |
|
35086
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
604 |
assert(m != NULL || _method_index == 0, "should be non-null for non-zero index"); |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
605 |
assert(m == NULL || m->is_method(), "not a method"); |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
606 |
return (Method*)m; |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
607 |
} |
1 | 608 |
|
52857
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52070
diff
changeset
|
609 |
bool virtual_call_Relocation::clear_inline_cache() { |
1 | 610 |
// No stubs for ICs |
611 |
// Clean IC |
|
612 |
ResourceMark rm; |
|
613 |
CompiledIC* icache = CompiledIC_at(this); |
|
52857
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52070
diff
changeset
|
614 |
return icache->set_to_clean(); |
1 | 615 |
} |
616 |
||
617 |
||
35086
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
618 |
void opt_virtual_call_Relocation::pack_data_to(CodeSection* dest) { |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
619 |
short* p = (short*) dest->locs_end(); |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
620 |
p = pack_1_int_to(p, _method_index); |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
621 |
dest->set_locs_end((relocInfo*) p); |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
622 |
} |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
623 |
|
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
624 |
void opt_virtual_call_Relocation::unpack_data() { |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
625 |
_method_index = unpack_1_int(); |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
626 |
} |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
627 |
|
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
628 |
Method* opt_virtual_call_Relocation::method_value() { |
42044 | 629 |
CompiledMethod* cm = code(); |
630 |
if (cm == NULL) return (Method*)NULL; |
|
631 |
Metadata* m = cm->metadata_at(_method_index); |
|
35086
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
632 |
assert(m != NULL || _method_index == 0, "should be non-null for non-zero index"); |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
633 |
assert(m == NULL || m->is_method(), "not a method"); |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
634 |
return (Method*)m; |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
635 |
} |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
636 |
|
52857
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52070
diff
changeset
|
637 |
template<typename CompiledICorStaticCall> |
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52070
diff
changeset
|
638 |
static bool set_to_clean_no_ic_refill(CompiledICorStaticCall* ic) { |
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52070
diff
changeset
|
639 |
guarantee(ic->set_to_clean(), "Should not need transition stubs"); |
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52070
diff
changeset
|
640 |
return true; |
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52070
diff
changeset
|
641 |
} |
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52070
diff
changeset
|
642 |
|
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52070
diff
changeset
|
643 |
bool opt_virtual_call_Relocation::clear_inline_cache() { |
1 | 644 |
// No stubs for ICs |
645 |
// Clean IC |
|
646 |
ResourceMark rm; |
|
647 |
CompiledIC* icache = CompiledIC_at(this); |
|
52857
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52070
diff
changeset
|
648 |
return set_to_clean_no_ic_refill(icache); |
1 | 649 |
} |
650 |
||
42650 | 651 |
address opt_virtual_call_Relocation::static_stub(bool is_aot) { |
1 | 652 |
// search for the static stub who points back to this static call |
653 |
address static_call_addr = addr(); |
|
654 |
RelocIterator iter(code()); |
|
655 |
while (iter.next()) { |
|
656 |
if (iter.type() == relocInfo::static_stub_type) { |
|
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
24952
diff
changeset
|
657 |
static_stub_Relocation* stub_reloc = iter.static_stub_reloc(); |
42650 | 658 |
if (stub_reloc->static_call() == static_call_addr && stub_reloc->is_aot() == is_aot) { |
1 | 659 |
return iter.addr(); |
660 |
} |
|
661 |
} |
|
662 |
} |
|
663 |
return NULL; |
|
664 |
} |
|
665 |
||
35086
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
666 |
Method* static_call_Relocation::method_value() { |
42044 | 667 |
CompiledMethod* cm = code(); |
668 |
if (cm == NULL) return (Method*)NULL; |
|
669 |
Metadata* m = cm->metadata_at(_method_index); |
|
35086
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
670 |
assert(m != NULL || _method_index == 0, "should be non-null for non-zero index"); |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
671 |
assert(m == NULL || m->is_method(), "not a method"); |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
672 |
return (Method*)m; |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
673 |
} |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
674 |
|
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
675 |
void static_call_Relocation::pack_data_to(CodeSection* dest) { |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
676 |
short* p = (short*) dest->locs_end(); |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
677 |
p = pack_1_int_to(p, _method_index); |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
678 |
dest->set_locs_end((relocInfo*) p); |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
679 |
} |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
680 |
|
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
681 |
void static_call_Relocation::unpack_data() { |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
682 |
_method_index = unpack_1_int(); |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
683 |
} |
1 | 684 |
|
52857
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52070
diff
changeset
|
685 |
bool static_call_Relocation::clear_inline_cache() { |
1 | 686 |
// Safe call site info |
42650 | 687 |
CompiledStaticCall* handler = this->code()->compiledStaticCall_at(this); |
52857
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52070
diff
changeset
|
688 |
return set_to_clean_no_ic_refill(handler); |
1 | 689 |
} |
690 |
||
691 |
||
42650 | 692 |
address static_call_Relocation::static_stub(bool is_aot) { |
1 | 693 |
// search for the static stub who points back to this static call |
694 |
address static_call_addr = addr(); |
|
695 |
RelocIterator iter(code()); |
|
696 |
while (iter.next()) { |
|
697 |
if (iter.type() == relocInfo::static_stub_type) { |
|
33160
c59f1676d27e
8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents:
24952
diff
changeset
|
698 |
static_stub_Relocation* stub_reloc = iter.static_stub_reloc(); |
42650 | 699 |
if (stub_reloc->static_call() == static_call_addr && stub_reloc->is_aot() == is_aot) { |
1 | 700 |
return iter.addr(); |
701 |
} |
|
702 |
} |
|
703 |
} |
|
704 |
return NULL; |
|
705 |
} |
|
706 |
||
22813
422557569a6b
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
18446
diff
changeset
|
707 |
// Finds the trampoline address for a call. If no trampoline stub is |
422557569a6b
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
18446
diff
changeset
|
708 |
// found NULL is returned which can be handled by the caller. |
422557569a6b
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
18446
diff
changeset
|
709 |
address trampoline_stub_Relocation::get_trampoline_for(address call, nmethod* code) { |
422557569a6b
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
18446
diff
changeset
|
710 |
// There are no relocations available when the code gets relocated |
422557569a6b
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
18446
diff
changeset
|
711 |
// because of CodeBuffer expansion. |
422557569a6b
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
18446
diff
changeset
|
712 |
if (code->relocation_size() == 0) |
422557569a6b
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
18446
diff
changeset
|
713 |
return NULL; |
422557569a6b
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
18446
diff
changeset
|
714 |
|
422557569a6b
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
18446
diff
changeset
|
715 |
RelocIterator iter(code, call); |
422557569a6b
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
18446
diff
changeset
|
716 |
while (iter.next()) { |
422557569a6b
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
18446
diff
changeset
|
717 |
if (iter.type() == relocInfo::trampoline_stub_type) { |
422557569a6b
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
18446
diff
changeset
|
718 |
if (iter.trampoline_stub_reloc()->owner() == call) { |
422557569a6b
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
18446
diff
changeset
|
719 |
return iter.addr(); |
422557569a6b
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
18446
diff
changeset
|
720 |
} |
422557569a6b
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
18446
diff
changeset
|
721 |
} |
422557569a6b
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
18446
diff
changeset
|
722 |
} |
422557569a6b
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
18446
diff
changeset
|
723 |
|
422557569a6b
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
18446
diff
changeset
|
724 |
return NULL; |
422557569a6b
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
18446
diff
changeset
|
725 |
} |
1 | 726 |
|
52857
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52070
diff
changeset
|
727 |
bool static_stub_Relocation::clear_inline_cache() { |
1 | 728 |
// Call stub is only used when calling the interpreted code. |
729 |
// It does not really need to be cleared, except that we want to clean out the methodoop. |
|
42650 | 730 |
CompiledDirectStaticCall::set_stub_to_clean(this); |
52857
7e268f863ff0
8214338: Move IC stub refilling out of IC cache transitions
eosterlund
parents:
52070
diff
changeset
|
731 |
return true; |
1 | 732 |
} |
733 |
||
734 |
||
735 |
void external_word_Relocation::fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) { |
|
736 |
address target = _target; |
|
737 |
if (target == NULL) { |
|
738 |
// An absolute embedded reference to an external location, |
|
739 |
// which means there is nothing to fix here. |
|
740 |
return; |
|
741 |
} |
|
742 |
// Probably this reference is absolute, not relative, so the |
|
743 |
// following is probably a no-op. |
|
744 |
assert(src->section_index_of(target) == CodeBuffer::SECT_NONE, "sanity"); |
|
745 |
set_value(target); |
|
746 |
} |
|
747 |
||
748 |
||
749 |
address external_word_Relocation::target() { |
|
750 |
address target = _target; |
|
751 |
if (target == NULL) { |
|
752 |
target = pd_get_address_from_code(); |
|
753 |
} |
|
754 |
return target; |
|
755 |
} |
|
756 |
||
757 |
||
758 |
void internal_word_Relocation::fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) { |
|
759 |
address target = _target; |
|
760 |
if (target == NULL) { |
|
24952
953481cd953d
8044538: assert(which != imm_operand) failed: instruction is not a movq reg, imm64
thartmann
parents:
24424
diff
changeset
|
761 |
target = new_addr_for(this->target(), src, dest); |
1 | 762 |
} |
763 |
set_value(target); |
|
764 |
} |
|
765 |
||
766 |
||
767 |
address internal_word_Relocation::target() { |
|
768 |
address target = _target; |
|
769 |
if (target == NULL) { |
|
24952
953481cd953d
8044538: assert(which != imm_operand) failed: instruction is not a movq reg, imm64
thartmann
parents:
24424
diff
changeset
|
770 |
if (addr_in_const()) { |
953481cd953d
8044538: assert(which != imm_operand) failed: instruction is not a movq reg, imm64
thartmann
parents:
24424
diff
changeset
|
771 |
target = *(address*)addr(); |
953481cd953d
8044538: assert(which != imm_operand) failed: instruction is not a movq reg, imm64
thartmann
parents:
24424
diff
changeset
|
772 |
} else { |
953481cd953d
8044538: assert(which != imm_operand) failed: instruction is not a movq reg, imm64
thartmann
parents:
24424
diff
changeset
|
773 |
target = pd_get_address_from_code(); |
953481cd953d
8044538: assert(which != imm_operand) failed: instruction is not a movq reg, imm64
thartmann
parents:
24424
diff
changeset
|
774 |
} |
1 | 775 |
} |
776 |
return target; |
|
777 |
} |
|
778 |
||
779 |
//--------------------------------------------------------------------------------- |
|
780 |
// Non-product code |
|
781 |
||
782 |
#ifndef PRODUCT |
|
783 |
||
784 |
static const char* reloc_type_string(relocInfo::relocType t) { |
|
785 |
switch (t) { |
|
786 |
#define EACH_CASE(name) \ |
|
787 |
case relocInfo::name##_type: \ |
|
788 |
return #name; |
|
789 |
||
790 |
APPLY_TO_RELOCATIONS(EACH_CASE); |
|
791 |
#undef EACH_CASE |
|
792 |
||
793 |
case relocInfo::none: |
|
794 |
return "none"; |
|
795 |
case relocInfo::data_prefix_tag: |
|
796 |
return "prefix"; |
|
797 |
default: |
|
798 |
return "UNKNOWN RELOC TYPE"; |
|
799 |
} |
|
800 |
} |
|
801 |
||
802 |
||
803 |
void RelocIterator::print_current() { |
|
804 |
if (!has_current()) { |
|
805 |
tty->print_cr("(no relocs)"); |
|
806 |
return; |
|
807 |
} |
|
7427 | 808 |
tty->print("relocInfo@" INTPTR_FORMAT " [type=%d(%s) addr=" INTPTR_FORMAT " offset=%d", |
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
24952
diff
changeset
|
809 |
p2i(_current), type(), reloc_type_string((relocInfo::relocType) type()), p2i(_addr), _current->addr_offset()); |
1 | 810 |
if (current()->format() != 0) |
811 |
tty->print(" format=%d", current()->format()); |
|
812 |
if (datalen() == 1) { |
|
813 |
tty->print(" data=%d", data()[0]); |
|
814 |
} else if (datalen() > 0) { |
|
815 |
tty->print(" data={"); |
|
816 |
for (int i = 0; i < datalen(); i++) { |
|
817 |
tty->print("%04x", data()[i] & 0xFFFF); |
|
818 |
} |
|
819 |
tty->print("}"); |
|
820 |
} |
|
821 |
tty->print("]"); |
|
822 |
switch (type()) { |
|
823 |
case relocInfo::oop_type: |
|
824 |
{ |
|
825 |
oop_Relocation* r = oop_reloc(); |
|
826 |
oop* oop_addr = NULL; |
|
827 |
oop raw_oop = NULL; |
|
828 |
oop oop_value = NULL; |
|
829 |
if (code() != NULL || r->oop_is_immediate()) { |
|
830 |
oop_addr = r->oop_addr(); |
|
831 |
raw_oop = *oop_addr; |
|
832 |
oop_value = r->oop_value(); |
|
833 |
} |
|
834 |
tty->print(" | [oop_addr=" INTPTR_FORMAT " *=" INTPTR_FORMAT " offset=%d]", |
|
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
24952
diff
changeset
|
835 |
p2i(oop_addr), p2i(raw_oop), r->offset()); |
1 | 836 |
// Do not print the oop by default--we want this routine to |
837 |
// work even during GC or other inconvenient times. |
|
838 |
if (WizardMode && oop_value != NULL) { |
|
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
24952
diff
changeset
|
839 |
tty->print("oop_value=" INTPTR_FORMAT ": ", p2i(oop_value)); |
46968
9119841280f4
8160399: is_oop_or_null involves undefined behavior
coleenp
parents:
46630
diff
changeset
|
840 |
if (oopDesc::is_oop(oop_value)) { |
42044 | 841 |
oop_value->print_value_on(tty); |
842 |
} |
|
1 | 843 |
} |
844 |
break; |
|
845 |
} |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
846 |
case relocInfo::metadata_type: |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
847 |
{ |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
848 |
metadata_Relocation* r = metadata_reloc(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
849 |
Metadata** metadata_addr = NULL; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
850 |
Metadata* raw_metadata = NULL; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
851 |
Metadata* metadata_value = NULL; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
852 |
if (code() != NULL || r->metadata_is_immediate()) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
853 |
metadata_addr = r->metadata_addr(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
854 |
raw_metadata = *metadata_addr; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
855 |
metadata_value = r->metadata_value(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
856 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
857 |
tty->print(" | [metadata_addr=" INTPTR_FORMAT " *=" INTPTR_FORMAT " offset=%d]", |
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
24952
diff
changeset
|
858 |
p2i(metadata_addr), p2i(raw_metadata), r->offset()); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
859 |
if (metadata_value != NULL) { |
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
24952
diff
changeset
|
860 |
tty->print("metadata_value=" INTPTR_FORMAT ": ", p2i(metadata_value)); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
861 |
metadata_value->print_value_on(tty); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
862 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
863 |
break; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
9124
diff
changeset
|
864 |
} |
1 | 865 |
case relocInfo::external_word_type: |
866 |
case relocInfo::internal_word_type: |
|
867 |
case relocInfo::section_word_type: |
|
868 |
{ |
|
869 |
DataRelocation* r = (DataRelocation*) reloc(); |
|
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
24952
diff
changeset
|
870 |
tty->print(" | [target=" INTPTR_FORMAT "]", p2i(r->value())); //value==target |
1 | 871 |
break; |
872 |
} |
|
873 |
case relocInfo::static_call_type: |
|
35086
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
874 |
{ |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
875 |
static_call_Relocation* r = (static_call_Relocation*) reloc(); |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
876 |
tty->print(" | [destination=" INTPTR_FORMAT " metadata=" INTPTR_FORMAT "]", |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
877 |
p2i(r->destination()), p2i(r->method_value())); |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
878 |
break; |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
879 |
} |
1 | 880 |
case relocInfo::runtime_call_type: |
42064
a530dbabe64f
8167184: [s390] Extend relocations for pc-relative instructions.
goetz
parents:
42044
diff
changeset
|
881 |
case relocInfo::runtime_call_w_cp_type: |
1 | 882 |
{ |
883 |
CallRelocation* r = (CallRelocation*) reloc(); |
|
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
24952
diff
changeset
|
884 |
tty->print(" | [destination=" INTPTR_FORMAT "]", p2i(r->destination())); |
1 | 885 |
break; |
886 |
} |
|
887 |
case relocInfo::virtual_call_type: |
|
888 |
{ |
|
889 |
virtual_call_Relocation* r = (virtual_call_Relocation*) reloc(); |
|
35086
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
890 |
tty->print(" | [destination=" INTPTR_FORMAT " cached_value=" INTPTR_FORMAT " metadata=" INTPTR_FORMAT "]", |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
891 |
p2i(r->destination()), p2i(r->cached_value()), p2i(r->method_value())); |
1 | 892 |
break; |
893 |
} |
|
894 |
case relocInfo::static_stub_type: |
|
895 |
{ |
|
896 |
static_stub_Relocation* r = (static_stub_Relocation*) reloc(); |
|
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
24952
diff
changeset
|
897 |
tty->print(" | [static_call=" INTPTR_FORMAT "]", p2i(r->static_call())); |
1 | 898 |
break; |
899 |
} |
|
22813
422557569a6b
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
18446
diff
changeset
|
900 |
case relocInfo::trampoline_stub_type: |
422557569a6b
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
18446
diff
changeset
|
901 |
{ |
422557569a6b
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
18446
diff
changeset
|
902 |
trampoline_stub_Relocation* r = (trampoline_stub_Relocation*) reloc(); |
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
24952
diff
changeset
|
903 |
tty->print(" | [trampoline owner=" INTPTR_FORMAT "]", p2i(r->owner())); |
22813
422557569a6b
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
18446
diff
changeset
|
904 |
break; |
422557569a6b
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
18446
diff
changeset
|
905 |
} |
35086
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
906 |
case relocInfo::opt_virtual_call_type: |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
907 |
{ |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
908 |
opt_virtual_call_Relocation* r = (opt_virtual_call_Relocation*) reloc(); |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
909 |
tty->print(" | [destination=" INTPTR_FORMAT " metadata=" INTPTR_FORMAT "]", |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
910 |
p2i(r->destination()), p2i(r->method_value())); |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
911 |
break; |
bbf32241d851
8072008: Emit direct call instead of linkTo* for recursive indy/MH.invoke* calls
vlivanov
parents:
33807
diff
changeset
|
912 |
} |
46630
75aa3e39d02c
8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents:
46530
diff
changeset
|
913 |
default: |
75aa3e39d02c
8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents:
46530
diff
changeset
|
914 |
break; |
1 | 915 |
} |
916 |
tty->cr(); |
|
917 |
} |
|
918 |
||
919 |
||
920 |
void RelocIterator::print() { |
|
921 |
RelocIterator save_this = (*this); |
|
922 |
relocInfo* scan = _current; |
|
923 |
if (!has_current()) scan += 1; // nothing to scan here! |
|
924 |
||
925 |
bool skip_next = has_current(); |
|
926 |
bool got_next; |
|
927 |
while (true) { |
|
928 |
got_next = (skip_next || next()); |
|
929 |
skip_next = false; |
|
930 |
||
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
24952
diff
changeset
|
931 |
tty->print(" @" INTPTR_FORMAT ": ", p2i(scan)); |
1 | 932 |
relocInfo* newscan = _current+1; |
933 |
if (!has_current()) newscan -= 1; // nothing to scan here! |
|
934 |
while (scan < newscan) { |
|
935 |
tty->print("%04x", *(short*)scan & 0xFFFF); |
|
936 |
scan++; |
|
937 |
} |
|
938 |
tty->cr(); |
|
939 |
||
940 |
if (!got_next) break; |
|
941 |
print_current(); |
|
942 |
} |
|
943 |
||
944 |
(*this) = save_this; |
|
945 |
} |
|
946 |
||
947 |
// For the debugger: |
|
948 |
extern "C" |
|
5686
5435e77aa3df
6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents:
1
diff
changeset
|
949 |
void print_blob_locs(nmethod* nm) { |
5435e77aa3df
6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents:
1
diff
changeset
|
950 |
nm->print(); |
5435e77aa3df
6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents:
1
diff
changeset
|
951 |
RelocIterator iter(nm); |
1 | 952 |
iter.print(); |
953 |
} |
|
954 |
extern "C" |
|
955 |
void print_buf_locs(CodeBuffer* cb) { |
|
956 |
FlagSetting fs(PrintRelocations, true); |
|
957 |
cb->print(); |
|
958 |
} |
|
959 |
#endif // !PRODUCT |