Mercurial > hg > truffle
annotate src/share/vm/code/relocInfo.cpp @ 18461:3b89c08c75f7
Rename DelayedFrameMapBuilder to FrameMapBuilderImpl (again).
author | Josef Eisl <josef.eisl@jku.at> |
---|---|
date | Mon, 17 Nov 2014 20:29:38 +0100 |
parents | 89f97291c3a5 |
children | 7848fc12602b |
rev | line source |
---|---|
0 | 1 /* |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
14456
diff
changeset
|
2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
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:
0
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
7199
cd3d6a6b95d9
8003240: x86: move MacroAssembler into separate file
twisti
parents:
6725
diff
changeset
|
26 #include "code/codeCache.hpp" |
1972 | 27 #include "code/compiledIC.hpp" |
28 #include "code/nmethod.hpp" | |
29 #include "code/relocInfo.hpp" | |
30 #include "memory/resourceArea.hpp" | |
31 #include "runtime/stubCodeGenerator.hpp" | |
32 #include "utilities/copy.hpp" | |
18177
89f97291c3a5
Hotspot: Support narrow oop relocations in constants section.
Roland Schatz <roland.schatz@oracle.com>
parents:
18041
diff
changeset
|
33 #include "oops/oop.inline.hpp" |
0 | 34 |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
14456
diff
changeset
|
35 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC |
0 | 36 |
37 const RelocationHolder RelocationHolder::none; // its type is relocInfo::none | |
38 | |
39 | |
40 // Implementation of relocInfo | |
41 | |
42 #ifdef ASSERT | |
43 relocInfo::relocInfo(relocType t, int off, int f) { | |
44 assert(t != data_prefix_tag, "cannot build a prefix this way"); | |
45 assert((t & type_mask) == t, "wrong type"); | |
46 assert((f & format_mask) == f, "wrong format"); | |
47 assert(off >= 0 && off < offset_limit(), "offset out off bounds"); | |
48 assert((off & (offset_unit-1)) == 0, "misaligned offset"); | |
49 (*this) = relocInfo(t, RAW_BITS, off, f); | |
50 } | |
51 #endif | |
52 | |
53 void relocInfo::initialize(CodeSection* dest, Relocation* reloc) { | |
54 relocInfo* data = this+1; // here's where the data might go | |
55 dest->set_locs_end(data); // sync end: the next call may read dest.locs_end | |
56 reloc->pack_data_to(dest); // maybe write data into locs, advancing locs_end | |
57 relocInfo* data_limit = dest->locs_end(); | |
58 if (data_limit > data) { | |
59 relocInfo suffix = (*this); | |
60 data_limit = this->finish_prefix((short*) data_limit); | |
61 // Finish up with the suffix. (Hack note: pack_data_to might edit this.) | |
62 *data_limit = suffix; | |
63 dest->set_locs_end(data_limit+1); | |
64 } | |
65 } | |
66 | |
67 relocInfo* relocInfo::finish_prefix(short* prefix_limit) { | |
68 assert(sizeof(relocInfo) == sizeof(short), "change this code"); | |
69 short* p = (short*)(this+1); | |
70 assert(prefix_limit >= p, "must be a valid span of data"); | |
71 int plen = prefix_limit - p; | |
72 if (plen == 0) { | |
73 debug_only(_value = 0xFFFF); | |
74 return this; // no data: remove self completely | |
75 } | |
76 if (plen == 1 && fits_into_immediate(p[0])) { | |
77 (*this) = immediate_relocInfo(p[0]); // move data inside self | |
78 return this+1; | |
79 } | |
80 // cannot compact, so just update the count and return the limit pointer | |
81 (*this) = prefix_relocInfo(plen); // write new datalen | |
82 assert(data() + datalen() == prefix_limit, "pointers must line up"); | |
83 return (relocInfo*)prefix_limit; | |
84 } | |
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 | |
97 void relocInfo::set_format(int f) { | |
98 int old_offset = addr_offset(); | |
99 assert((f & format_mask) == f, "wrong format"); | |
100 _value = (_value & ~(format_mask << offset_width)) | (f << offset_width); | |
101 assert(addr_offset()==old_offset, "sanity check"); | |
102 } | |
103 | |
104 | |
105 void relocInfo::change_reloc_info_for_address(RelocIterator *itr, address pc, relocType old_type, relocType new_type) { | |
106 bool found = false; | |
107 while (itr->next() && !found) { | |
108 if (itr->addr() == pc) { | |
109 assert(itr->type()==old_type, "wrong relocInfo type found"); | |
110 itr->current()->set_type(new_type); | |
111 found=true; | |
112 } | |
113 } | |
114 assert(found, "no relocInfo found for pc"); | |
115 } | |
116 | |
117 | |
118 void relocInfo::remove_reloc_info_for_address(RelocIterator *itr, address pc, relocType old_type) { | |
119 change_reloc_info_for_address(itr, pc, old_type, none); | |
120 } | |
121 | |
122 | |
123 // ---------------------------------------------------------------------------------------------------- | |
124 // Implementation of RelocIterator | |
125 | |
1563
1a5913bf5e19
6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents:
0
diff
changeset
|
126 void RelocIterator::initialize(nmethod* nm, address begin, address limit) { |
0 | 127 initialize_misc(); |
128 | |
1563
1a5913bf5e19
6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents:
0
diff
changeset
|
129 if (nm == NULL && begin != NULL) { |
1a5913bf5e19
6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents:
0
diff
changeset
|
130 // allow nmethod to be deduced from beginning address |
1a5913bf5e19
6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents:
0
diff
changeset
|
131 CodeBlob* cb = CodeCache::find_blob(begin); |
1a5913bf5e19
6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents:
0
diff
changeset
|
132 nm = cb->as_nmethod_or_null(); |
0 | 133 } |
1563
1a5913bf5e19
6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents:
0
diff
changeset
|
134 assert(nm != NULL, "must be able to deduce nmethod from other arguments"); |
0 | 135 |
1563
1a5913bf5e19
6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents:
0
diff
changeset
|
136 _code = nm; |
1a5913bf5e19
6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents:
0
diff
changeset
|
137 _current = nm->relocation_begin() - 1; |
1a5913bf5e19
6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents:
0
diff
changeset
|
138 _end = nm->relocation_end(); |
1762
0878d7bae69f
6961697: move nmethod constants section before instruction section
twisti
parents:
1748
diff
changeset
|
139 _addr = nm->content_begin(); |
0878d7bae69f
6961697: move nmethod constants section before instruction section
twisti
parents:
1748
diff
changeset
|
140 |
0878d7bae69f
6961697: move nmethod constants section before instruction section
twisti
parents:
1748
diff
changeset
|
141 // Initialize code sections. |
0878d7bae69f
6961697: move nmethod constants section before instruction section
twisti
parents:
1748
diff
changeset
|
142 _section_start[CodeBuffer::SECT_CONSTS] = nm->consts_begin(); |
0878d7bae69f
6961697: move nmethod constants section before instruction section
twisti
parents:
1748
diff
changeset
|
143 _section_start[CodeBuffer::SECT_INSTS ] = nm->insts_begin() ; |
0878d7bae69f
6961697: move nmethod constants section before instruction section
twisti
parents:
1748
diff
changeset
|
144 _section_start[CodeBuffer::SECT_STUBS ] = nm->stub_begin() ; |
0878d7bae69f
6961697: move nmethod constants section before instruction section
twisti
parents:
1748
diff
changeset
|
145 |
0878d7bae69f
6961697: move nmethod constants section before instruction section
twisti
parents:
1748
diff
changeset
|
146 _section_end [CodeBuffer::SECT_CONSTS] = nm->consts_end() ; |
0878d7bae69f
6961697: move nmethod constants section before instruction section
twisti
parents:
1748
diff
changeset
|
147 _section_end [CodeBuffer::SECT_INSTS ] = nm->insts_end() ; |
0878d7bae69f
6961697: move nmethod constants section before instruction section
twisti
parents:
1748
diff
changeset
|
148 _section_end [CodeBuffer::SECT_STUBS ] = nm->stub_end() ; |
0 | 149 |
150 assert(!has_current(), "just checking"); | |
1748 | 151 assert(begin == NULL || begin >= nm->code_begin(), "in bounds"); |
152 assert(limit == NULL || limit <= nm->code_end(), "in bounds"); | |
0 | 153 set_limits(begin, limit); |
154 } | |
155 | |
156 | |
157 RelocIterator::RelocIterator(CodeSection* cs, address begin, address limit) { | |
158 initialize_misc(); | |
159 | |
160 _current = cs->locs_start()-1; | |
161 _end = cs->locs_end(); | |
162 _addr = cs->start(); | |
163 _code = NULL; // Not cb->blob(); | |
164 | |
165 CodeBuffer* cb = cs->outer(); | |
1762
0878d7bae69f
6961697: move nmethod constants section before instruction section
twisti
parents:
1748
diff
changeset
|
166 assert((int) SECT_LIMIT == CodeBuffer::SECT_LIMIT, "my copy must be equal"); |
0878d7bae69f
6961697: move nmethod constants section before instruction section
twisti
parents:
1748
diff
changeset
|
167 for (int n = (int) CodeBuffer::SECT_FIRST; n < (int) CodeBuffer::SECT_LIMIT; n++) { |
0878d7bae69f
6961697: move nmethod constants section before instruction section
twisti
parents:
1748
diff
changeset
|
168 CodeSection* cs = cb->code_section(n); |
0878d7bae69f
6961697: move nmethod constants section before instruction section
twisti
parents:
1748
diff
changeset
|
169 _section_start[n] = cs->start(); |
0878d7bae69f
6961697: move nmethod constants section before instruction section
twisti
parents:
1748
diff
changeset
|
170 _section_end [n] = cs->end(); |
0 | 171 } |
172 | |
173 assert(!has_current(), "just checking"); | |
174 | |
175 assert(begin == NULL || begin >= cs->start(), "in bounds"); | |
176 assert(limit == NULL || limit <= cs->end(), "in bounds"); | |
177 set_limits(begin, limit); | |
178 } | |
179 | |
180 | |
181 enum { indexCardSize = 128 }; | |
182 struct RelocIndexEntry { | |
183 jint addr_offset; // offset from header_end of an addr() | |
184 jint reloc_offset; // offset from header_end of a relocInfo (prefix) | |
185 }; | |
186 | |
187 | |
1762
0878d7bae69f
6961697: move nmethod constants section before instruction section
twisti
parents:
1748
diff
changeset
|
188 bool RelocIterator::addr_in_const() const { |
0878d7bae69f
6961697: move nmethod constants section before instruction section
twisti
parents:
1748
diff
changeset
|
189 const int n = CodeBuffer::SECT_CONSTS; |
0878d7bae69f
6961697: move nmethod constants section before instruction section
twisti
parents:
1748
diff
changeset
|
190 return section_start(n) <= addr() && addr() < section_end(n); |
0878d7bae69f
6961697: move nmethod constants section before instruction section
twisti
parents:
1748
diff
changeset
|
191 } |
0878d7bae69f
6961697: move nmethod constants section before instruction section
twisti
parents:
1748
diff
changeset
|
192 |
0878d7bae69f
6961697: move nmethod constants section before instruction section
twisti
parents:
1748
diff
changeset
|
193 |
0 | 194 static inline int num_cards(int code_size) { |
195 return (code_size-1) / indexCardSize; | |
196 } | |
197 | |
198 | |
199 int RelocIterator::locs_and_index_size(int code_size, int locs_size) { | |
200 if (!UseRelocIndex) return locs_size; // no index | |
201 code_size = round_to(code_size, oopSize); | |
202 locs_size = round_to(locs_size, oopSize); | |
203 int index_size = num_cards(code_size) * sizeof(RelocIndexEntry); | |
204 // format of indexed relocs: | |
205 // relocation_begin: relocInfo ... | |
206 // index: (addr,reloc#) ... | |
207 // indexSize :relocation_end | |
208 return locs_size + index_size + BytesPerInt; | |
209 } | |
210 | |
211 | |
212 void RelocIterator::create_index(relocInfo* dest_begin, int dest_count, relocInfo* dest_end) { | |
213 address relocation_begin = (address)dest_begin; | |
214 address relocation_end = (address)dest_end; | |
215 int total_size = relocation_end - relocation_begin; | |
216 int locs_size = dest_count * sizeof(relocInfo); | |
217 if (!UseRelocIndex) { | |
218 Copy::fill_to_bytes(relocation_begin + locs_size, total_size-locs_size, 0); | |
219 return; | |
220 } | |
221 int index_size = total_size - locs_size - BytesPerInt; // find out how much space is left | |
222 int ncards = index_size / sizeof(RelocIndexEntry); | |
223 assert(total_size == locs_size + index_size + BytesPerInt, "checkin'"); | |
224 assert(index_size >= 0 && index_size % sizeof(RelocIndexEntry) == 0, "checkin'"); | |
225 jint* index_size_addr = (jint*)relocation_end - 1; | |
226 | |
227 assert(sizeof(jint) == BytesPerInt, "change this code"); | |
228 | |
229 *index_size_addr = index_size; | |
230 if (index_size != 0) { | |
231 assert(index_size > 0, "checkin'"); | |
232 | |
233 RelocIndexEntry* index = (RelocIndexEntry *)(relocation_begin + locs_size); | |
234 assert(index == (RelocIndexEntry*)index_size_addr - ncards, "checkin'"); | |
235 | |
236 // walk over the relocations, and fill in index entries as we go | |
237 RelocIterator iter; | |
238 const address initial_addr = NULL; | |
239 relocInfo* const initial_current = dest_begin - 1; // biased by -1 like elsewhere | |
240 | |
241 iter._code = NULL; | |
242 iter._addr = initial_addr; | |
243 iter._limit = (address)(intptr_t)(ncards * indexCardSize); | |
244 iter._current = initial_current; | |
245 iter._end = dest_begin + dest_count; | |
246 | |
247 int i = 0; | |
248 address next_card_addr = (address)indexCardSize; | |
249 int addr_offset = 0; | |
250 int reloc_offset = 0; | |
251 while (true) { | |
252 // Checkpoint the iterator before advancing it. | |
253 addr_offset = iter._addr - initial_addr; | |
254 reloc_offset = iter._current - initial_current; | |
255 if (!iter.next()) break; | |
256 while (iter.addr() >= next_card_addr) { | |
257 index[i].addr_offset = addr_offset; | |
258 index[i].reloc_offset = reloc_offset; | |
259 i++; | |
260 next_card_addr += indexCardSize; | |
261 } | |
262 } | |
263 while (i < ncards) { | |
264 index[i].addr_offset = addr_offset; | |
265 index[i].reloc_offset = reloc_offset; | |
266 i++; | |
267 } | |
268 } | |
269 } | |
270 | |
271 | |
272 void RelocIterator::set_limits(address begin, address limit) { | |
273 int index_size = 0; | |
274 if (UseRelocIndex && _code != NULL) { | |
275 index_size = ((jint*)_end)[-1]; | |
276 _end = (relocInfo*)( (address)_end - index_size - BytesPerInt ); | |
277 } | |
278 | |
279 _limit = limit; | |
280 | |
281 // the limit affects this next stuff: | |
282 if (begin != NULL) { | |
283 #ifdef ASSERT | |
284 // In ASSERT mode we do not actually use the index, but simply | |
285 // check that its contents would have led us to the right answer. | |
286 address addrCheck = _addr; | |
287 relocInfo* infoCheck = _current; | |
288 #endif // ASSERT | |
289 if (index_size > 0) { | |
290 // skip ahead | |
291 RelocIndexEntry* index = (RelocIndexEntry*)_end; | |
292 RelocIndexEntry* index_limit = (RelocIndexEntry*)((address)index + index_size); | |
1748 | 293 assert(_addr == _code->code_begin(), "_addr must be unadjusted"); |
0 | 294 int card = (begin - _addr) / indexCardSize; |
295 if (card > 0) { | |
296 if (index+card-1 < index_limit) index += card-1; | |
297 else index = index_limit - 1; | |
298 #ifdef ASSERT | |
299 addrCheck = _addr + index->addr_offset; | |
300 infoCheck = _current + index->reloc_offset; | |
301 #else | |
302 // Advance the iterator immediately to the last valid state | |
303 // for the previous card. Calling "next" will then advance | |
304 // it to the first item on the required card. | |
305 _addr += index->addr_offset; | |
306 _current += index->reloc_offset; | |
307 #endif // ASSERT | |
308 } | |
309 } | |
310 | |
311 relocInfo* backup; | |
312 address backup_addr; | |
313 while (true) { | |
314 backup = _current; | |
315 backup_addr = _addr; | |
316 #ifdef ASSERT | |
317 if (backup == infoCheck) { | |
318 assert(backup_addr == addrCheck, "must match"); addrCheck = NULL; infoCheck = NULL; | |
319 } else { | |
320 assert(addrCheck == NULL || backup_addr <= addrCheck, "must not pass addrCheck"); | |
321 } | |
322 #endif // ASSERT | |
323 if (!next() || addr() >= begin) break; | |
324 } | |
325 assert(addrCheck == NULL || addrCheck == backup_addr, "must have matched addrCheck"); | |
326 assert(infoCheck == NULL || infoCheck == backup, "must have matched infoCheck"); | |
327 // At this point, either we are at the first matching record, | |
328 // or else there is no such record, and !has_current(). | |
329 // In either case, revert to the immediatly preceding state. | |
330 _current = backup; | |
331 _addr = backup_addr; | |
332 set_has_current(false); | |
333 } | |
334 } | |
335 | |
336 | |
337 void RelocIterator::set_limit(address limit) { | |
338 address code_end = (address)code() + code()->size(); | |
339 assert(limit == NULL || limit <= code_end, "in bounds"); | |
340 _limit = limit; | |
341 } | |
342 | |
343 // All the strange bit-encodings are in here. | |
344 // The idea is to encode relocation data which are small integers | |
345 // very efficiently (a single extra halfword). Larger chunks of | |
346 // relocation data need a halfword header to hold their size. | |
347 void RelocIterator::advance_over_prefix() { | |
348 if (_current->is_datalen()) { | |
349 _data = (short*) _current->data(); | |
350 _datalen = _current->datalen(); | |
351 _current += _datalen + 1; // skip the embedded data & header | |
352 } else { | |
353 _databuf = _current->immediate(); | |
354 _data = &_databuf; | |
355 _datalen = 1; | |
356 _current++; // skip the header | |
357 } | |
358 // The client will see the following relocInfo, whatever that is. | |
359 // It is the reloc to which the preceding data applies. | |
360 } | |
361 | |
362 | |
1762
0878d7bae69f
6961697: move nmethod constants section before instruction section
twisti
parents:
1748
diff
changeset
|
363 void RelocIterator::initialize_misc() { |
0878d7bae69f
6961697: move nmethod constants section before instruction section
twisti
parents:
1748
diff
changeset
|
364 set_has_current(false); |
0878d7bae69f
6961697: move nmethod constants section before instruction section
twisti
parents:
1748
diff
changeset
|
365 for (int i = (int) CodeBuffer::SECT_FIRST; i < (int) CodeBuffer::SECT_LIMIT; i++) { |
0878d7bae69f
6961697: move nmethod constants section before instruction section
twisti
parents:
1748
diff
changeset
|
366 _section_start[i] = NULL; // these will be lazily computed, if needed |
0878d7bae69f
6961697: move nmethod constants section before instruction section
twisti
parents:
1748
diff
changeset
|
367 _section_end [i] = NULL; |
0 | 368 } |
369 } | |
370 | |
371 | |
372 Relocation* RelocIterator::reloc() { | |
373 // (take the "switch" out-of-line) | |
374 relocInfo::relocType t = type(); | |
375 if (false) {} | |
376 #define EACH_TYPE(name) \ | |
377 else if (t == relocInfo::name##_type) { \ | |
378 return name##_reloc(); \ | |
379 } | |
380 APPLY_TO_RELOCATIONS(EACH_TYPE); | |
381 #undef EACH_TYPE | |
382 assert(t == relocInfo::none, "must be padding"); | |
383 return new(_rh) Relocation(); | |
384 } | |
385 | |
386 | |
387 //////// Methods for flyweight Relocation types | |
388 | |
389 | |
390 RelocationHolder RelocationHolder::plus(int offset) const { | |
391 if (offset != 0) { | |
392 switch (type()) { | |
393 case relocInfo::none: | |
394 break; | |
395 case relocInfo::oop_type: | |
396 { | |
397 oop_Relocation* r = (oop_Relocation*)reloc(); | |
398 return oop_Relocation::spec(r->oop_index(), r->offset() + offset); | |
399 } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
400 case relocInfo::metadata_type: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
401 { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
402 metadata_Relocation* r = (metadata_Relocation*)reloc(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
403 return metadata_Relocation::spec(r->metadata_index(), r->offset() + offset); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
404 } |
0 | 405 default: |
406 ShouldNotReachHere(); | |
407 } | |
408 } | |
409 return (*this); | |
410 } | |
411 | |
412 | |
413 void Relocation::guarantee_size() { | |
414 guarantee(false, "Make _relocbuf bigger!"); | |
415 } | |
416 | |
417 // some relocations can compute their own values | |
418 address Relocation::value() { | |
419 ShouldNotReachHere(); | |
420 return NULL; | |
421 } | |
422 | |
423 | |
424 void Relocation::set_value(address x) { | |
425 ShouldNotReachHere(); | |
426 } | |
427 | |
18177
89f97291c3a5
Hotspot: Support narrow oop relocations in constants section.
Roland Schatz <roland.schatz@oracle.com>
parents:
18041
diff
changeset
|
428 void Relocation::const_set_data_value(address x) { |
89f97291c3a5
Hotspot: Support narrow oop relocations in constants section.
Roland Schatz <roland.schatz@oracle.com>
parents:
18041
diff
changeset
|
429 #ifdef _LP64 |
89f97291c3a5
Hotspot: Support narrow oop relocations in constants section.
Roland Schatz <roland.schatz@oracle.com>
parents:
18041
diff
changeset
|
430 if (format() == relocInfo::narrow_oop_in_const) { |
89f97291c3a5
Hotspot: Support narrow oop relocations in constants section.
Roland Schatz <roland.schatz@oracle.com>
parents:
18041
diff
changeset
|
431 *(narrowOop*)addr() = oopDesc::encode_heap_oop((oop) x); |
89f97291c3a5
Hotspot: Support narrow oop relocations in constants section.
Roland Schatz <roland.schatz@oracle.com>
parents:
18041
diff
changeset
|
432 } else { |
89f97291c3a5
Hotspot: Support narrow oop relocations in constants section.
Roland Schatz <roland.schatz@oracle.com>
parents:
18041
diff
changeset
|
433 #endif |
89f97291c3a5
Hotspot: Support narrow oop relocations in constants section.
Roland Schatz <roland.schatz@oracle.com>
parents:
18041
diff
changeset
|
434 *(address*)addr() = x; |
89f97291c3a5
Hotspot: Support narrow oop relocations in constants section.
Roland Schatz <roland.schatz@oracle.com>
parents:
18041
diff
changeset
|
435 #ifdef _LP64 |
89f97291c3a5
Hotspot: Support narrow oop relocations in constants section.
Roland Schatz <roland.schatz@oracle.com>
parents:
18041
diff
changeset
|
436 } |
89f97291c3a5
Hotspot: Support narrow oop relocations in constants section.
Roland Schatz <roland.schatz@oracle.com>
parents:
18041
diff
changeset
|
437 #endif |
89f97291c3a5
Hotspot: Support narrow oop relocations in constants section.
Roland Schatz <roland.schatz@oracle.com>
parents:
18041
diff
changeset
|
438 } |
89f97291c3a5
Hotspot: Support narrow oop relocations in constants section.
Roland Schatz <roland.schatz@oracle.com>
parents:
18041
diff
changeset
|
439 |
89f97291c3a5
Hotspot: Support narrow oop relocations in constants section.
Roland Schatz <roland.schatz@oracle.com>
parents:
18041
diff
changeset
|
440 void Relocation::const_verify_data_value(address x) { |
89f97291c3a5
Hotspot: Support narrow oop relocations in constants section.
Roland Schatz <roland.schatz@oracle.com>
parents:
18041
diff
changeset
|
441 #ifdef _LP64 |
89f97291c3a5
Hotspot: Support narrow oop relocations in constants section.
Roland Schatz <roland.schatz@oracle.com>
parents:
18041
diff
changeset
|
442 if (format() == relocInfo::narrow_oop_in_const) { |
89f97291c3a5
Hotspot: Support narrow oop relocations in constants section.
Roland Schatz <roland.schatz@oracle.com>
parents:
18041
diff
changeset
|
443 assert(*(narrowOop*)addr() == oopDesc::encode_heap_oop((oop) x), "must agree"); |
89f97291c3a5
Hotspot: Support narrow oop relocations in constants section.
Roland Schatz <roland.schatz@oracle.com>
parents:
18041
diff
changeset
|
444 } else { |
89f97291c3a5
Hotspot: Support narrow oop relocations in constants section.
Roland Schatz <roland.schatz@oracle.com>
parents:
18041
diff
changeset
|
445 #endif |
89f97291c3a5
Hotspot: Support narrow oop relocations in constants section.
Roland Schatz <roland.schatz@oracle.com>
parents:
18041
diff
changeset
|
446 assert(*(address*)addr() == x, "must agree"); |
89f97291c3a5
Hotspot: Support narrow oop relocations in constants section.
Roland Schatz <roland.schatz@oracle.com>
parents:
18041
diff
changeset
|
447 #ifdef _LP64 |
89f97291c3a5
Hotspot: Support narrow oop relocations in constants section.
Roland Schatz <roland.schatz@oracle.com>
parents:
18041
diff
changeset
|
448 } |
89f97291c3a5
Hotspot: Support narrow oop relocations in constants section.
Roland Schatz <roland.schatz@oracle.com>
parents:
18041
diff
changeset
|
449 #endif |
89f97291c3a5
Hotspot: Support narrow oop relocations in constants section.
Roland Schatz <roland.schatz@oracle.com>
parents:
18041
diff
changeset
|
450 } |
89f97291c3a5
Hotspot: Support narrow oop relocations in constants section.
Roland Schatz <roland.schatz@oracle.com>
parents:
18041
diff
changeset
|
451 |
0 | 452 |
453 RelocationHolder Relocation::spec_simple(relocInfo::relocType rtype) { | |
454 if (rtype == relocInfo::none) return RelocationHolder::none; | |
455 relocInfo ri = relocInfo(rtype, 0); | |
456 RelocIterator itr; | |
457 itr.set_current(ri); | |
458 itr.reloc(); | |
459 return itr._rh; | |
460 } | |
461 | |
462 int32_t Relocation::runtime_address_to_index(address runtime_address) { | |
2455
479b4b4b6950
6777083: assert(target != __null,"must not be null")
never
parents:
2375
diff
changeset
|
463 assert(!is_reloc_index((intptr_t)runtime_address), "must not look like an index"); |
0 | 464 |
465 if (runtime_address == NULL) return 0; | |
466 | |
467 StubCodeDesc* p = StubCodeDesc::desc_for(runtime_address); | |
468 if (p != NULL && p->begin() == runtime_address) { | |
2455
479b4b4b6950
6777083: assert(target != __null,"must not be null")
never
parents:
2375
diff
changeset
|
469 assert(is_reloc_index(p->index()), "there must not be too many stubs"); |
0 | 470 return (int32_t)p->index(); |
471 } else { | |
472 // Known "miscellaneous" non-stub pointers: | |
473 // os::get_polling_page(), SafepointSynchronize::address_of_state() | |
474 if (PrintRelocations) { | |
475 tty->print_cr("random unregistered address in relocInfo: " INTPTR_FORMAT, runtime_address); | |
476 } | |
477 #ifndef _LP64 | |
478 return (int32_t) (intptr_t)runtime_address; | |
479 #else | |
480 // didn't fit return non-index | |
481 return -1; | |
482 #endif /* _LP64 */ | |
483 } | |
484 } | |
485 | |
486 | |
487 address Relocation::index_to_runtime_address(int32_t index) { | |
488 if (index == 0) return NULL; | |
489 | |
2455
479b4b4b6950
6777083: assert(target != __null,"must not be null")
never
parents:
2375
diff
changeset
|
490 if (is_reloc_index(index)) { |
0 | 491 StubCodeDesc* p = StubCodeDesc::desc_for_index(index); |
492 assert(p != NULL, "there must be a stub for this index"); | |
493 return p->begin(); | |
494 } else { | |
495 #ifndef _LP64 | |
496 // this only works on 32bit machines | |
497 return (address) ((intptr_t) index); | |
498 #else | |
499 fatal("Relocation::index_to_runtime_address, int32_t not pointer sized"); | |
500 return NULL; | |
501 #endif /* _LP64 */ | |
502 } | |
503 } | |
504 | |
505 address Relocation::old_addr_for(address newa, | |
506 const CodeBuffer* src, CodeBuffer* dest) { | |
507 int sect = dest->section_index_of(newa); | |
508 guarantee(sect != CodeBuffer::SECT_NONE, "lost track of this address"); | |
509 address ostart = src->code_section(sect)->start(); | |
510 address nstart = dest->code_section(sect)->start(); | |
511 return ostart + (newa - nstart); | |
512 } | |
513 | |
514 address Relocation::new_addr_for(address olda, | |
515 const CodeBuffer* src, CodeBuffer* dest) { | |
516 debug_only(const CodeBuffer* src0 = src); | |
517 int sect = CodeBuffer::SECT_NONE; | |
518 // Look for olda in the source buffer, and all previous incarnations | |
519 // if the source buffer has been expanded. | |
520 for (; src != NULL; src = src->before_expand()) { | |
521 sect = src->section_index_of(olda); | |
522 if (sect != CodeBuffer::SECT_NONE) break; | |
523 } | |
524 guarantee(sect != CodeBuffer::SECT_NONE, "lost track of this address"); | |
525 address ostart = src->code_section(sect)->start(); | |
526 address nstart = dest->code_section(sect)->start(); | |
527 return nstart + (olda - ostart); | |
528 } | |
529 | |
530 void Relocation::normalize_address(address& addr, const CodeSection* dest, bool allow_other_sections) { | |
531 address addr0 = addr; | |
532 if (addr0 == NULL || dest->allocates2(addr0)) return; | |
533 CodeBuffer* cb = dest->outer(); | |
534 addr = new_addr_for(addr0, cb, cb); | |
535 assert(allow_other_sections || dest->contains2(addr), | |
536 "addr must be in required section"); | |
537 } | |
538 | |
539 | |
540 void CallRelocation::set_destination(address x) { | |
541 pd_set_call_destination(x); | |
542 } | |
543 | |
544 void CallRelocation::fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) { | |
545 // Usually a self-relative reference to an external routine. | |
546 // On some platforms, the reference is absolute (not self-relative). | |
547 // The enhanced use of pd_call_destination sorts this all out. | |
548 address orig_addr = old_addr_for(addr(), src, dest); | |
549 address callee = pd_call_destination(orig_addr); | |
550 // Reassert the callee address, this time in the new copy of the code. | |
551 pd_set_call_destination(callee); | |
552 } | |
553 | |
554 | |
555 //// pack/unpack methods | |
556 | |
557 void oop_Relocation::pack_data_to(CodeSection* dest) { | |
558 short* p = (short*) dest->locs_end(); | |
559 p = pack_2_ints_to(p, _oop_index, _offset); | |
560 dest->set_locs_end((relocInfo*) p); | |
561 } | |
562 | |
563 | |
564 void oop_Relocation::unpack_data() { | |
565 unpack_2_ints(_oop_index, _offset); | |
566 } | |
567 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
568 void metadata_Relocation::pack_data_to(CodeSection* dest) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
569 short* p = (short*) dest->locs_end(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
570 p = pack_2_ints_to(p, _metadata_index, _offset); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
571 dest->set_locs_end((relocInfo*) p); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
572 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
573 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
574 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
575 void metadata_Relocation::unpack_data() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
576 unpack_2_ints(_metadata_index, _offset); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
577 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
578 |
0 | 579 |
580 void virtual_call_Relocation::pack_data_to(CodeSection* dest) { | |
581 short* p = (short*) dest->locs_end(); | |
582 address point = dest->locs_point(); | |
583 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
584 normalize_address(_cached_value, dest); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
585 jint x0 = scaled_offset_null_special(_cached_value, point); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
586 p = pack_1_int_to(p, x0); |
0 | 587 dest->set_locs_end((relocInfo*) p); |
588 } | |
589 | |
590 | |
591 void virtual_call_Relocation::unpack_data() { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
592 jint x0 = unpack_1_int(); |
0 | 593 address point = addr(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
594 _cached_value = x0==0? NULL: address_from_scaled_offset(x0, point); |
0 | 595 } |
596 | |
597 | |
598 void static_stub_Relocation::pack_data_to(CodeSection* dest) { | |
599 short* p = (short*) dest->locs_end(); | |
600 CodeSection* insts = dest->outer()->insts(); | |
601 normalize_address(_static_call, insts); | |
602 p = pack_1_int_to(p, scaled_offset(_static_call, insts->start())); | |
603 dest->set_locs_end((relocInfo*) p); | |
604 } | |
605 | |
606 void static_stub_Relocation::unpack_data() { | |
607 address base = binding()->section_start(CodeBuffer::SECT_INSTS); | |
608 _static_call = address_from_scaled_offset(unpack_1_int(), base); | |
609 } | |
610 | |
14397
53fa76359eb1
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
11041
diff
changeset
|
611 void trampoline_stub_Relocation::pack_data_to(CodeSection* dest ) { |
53fa76359eb1
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
11041
diff
changeset
|
612 short* p = (short*) dest->locs_end(); |
53fa76359eb1
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
11041
diff
changeset
|
613 CodeSection* insts = dest->outer()->insts(); |
53fa76359eb1
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
11041
diff
changeset
|
614 normalize_address(_owner, insts); |
53fa76359eb1
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
11041
diff
changeset
|
615 p = pack_1_int_to(p, scaled_offset(_owner, insts->start())); |
53fa76359eb1
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
11041
diff
changeset
|
616 dest->set_locs_end((relocInfo*) p); |
53fa76359eb1
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
11041
diff
changeset
|
617 } |
53fa76359eb1
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
11041
diff
changeset
|
618 |
53fa76359eb1
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
11041
diff
changeset
|
619 void trampoline_stub_Relocation::unpack_data() { |
53fa76359eb1
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
11041
diff
changeset
|
620 address base = binding()->section_start(CodeBuffer::SECT_INSTS); |
53fa76359eb1
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
11041
diff
changeset
|
621 _owner = address_from_scaled_offset(unpack_1_int(), base); |
53fa76359eb1
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
11041
diff
changeset
|
622 } |
0 | 623 |
624 void external_word_Relocation::pack_data_to(CodeSection* dest) { | |
625 short* p = (short*) dest->locs_end(); | |
626 int32_t index = runtime_address_to_index(_target); | |
627 #ifndef _LP64 | |
628 p = pack_1_int_to(p, index); | |
629 #else | |
2455
479b4b4b6950
6777083: assert(target != __null,"must not be null")
never
parents:
2375
diff
changeset
|
630 if (is_reloc_index(index)) { |
0 | 631 p = pack_2_ints_to(p, index, 0); |
632 } else { | |
633 jlong t = (jlong) _target; | |
634 int32_t lo = low(t); | |
635 int32_t hi = high(t); | |
636 p = pack_2_ints_to(p, lo, hi); | |
637 DEBUG_ONLY(jlong t1 = jlong_from(hi, lo)); | |
2455
479b4b4b6950
6777083: assert(target != __null,"must not be null")
never
parents:
2375
diff
changeset
|
638 assert(!is_reloc_index(t1) && (address) t1 == _target, "not symmetric"); |
0 | 639 } |
640 #endif /* _LP64 */ | |
641 dest->set_locs_end((relocInfo*) p); | |
642 } | |
643 | |
644 | |
645 void external_word_Relocation::unpack_data() { | |
646 #ifndef _LP64 | |
647 _target = index_to_runtime_address(unpack_1_int()); | |
648 #else | |
649 int32_t lo, hi; | |
650 unpack_2_ints(lo, hi); | |
651 jlong t = jlong_from(hi, lo);; | |
2455
479b4b4b6950
6777083: assert(target != __null,"must not be null")
never
parents:
2375
diff
changeset
|
652 if (is_reloc_index(t)) { |
0 | 653 _target = index_to_runtime_address(t); |
654 } else { | |
655 _target = (address) t; | |
656 } | |
657 #endif /* _LP64 */ | |
658 } | |
659 | |
660 | |
661 void internal_word_Relocation::pack_data_to(CodeSection* dest) { | |
662 short* p = (short*) dest->locs_end(); | |
663 normalize_address(_target, dest, true); | |
664 | |
665 // Check whether my target address is valid within this section. | |
666 // If not, strengthen the relocation type to point to another section. | |
667 int sindex = _section; | |
668 if (sindex == CodeBuffer::SECT_NONE && _target != NULL | |
669 && (!dest->allocates(_target) || _target == dest->locs_point())) { | |
670 sindex = dest->outer()->section_index_of(_target); | |
671 guarantee(sindex != CodeBuffer::SECT_NONE, "must belong somewhere"); | |
672 relocInfo* base = dest->locs_end() - 1; | |
673 assert(base->type() == this->type(), "sanity"); | |
674 // Change the written type, to be section_word_type instead. | |
675 base->set_type(relocInfo::section_word_type); | |
676 } | |
677 | |
678 // Note: An internal_word relocation cannot refer to its own instruction, | |
679 // because we reserve "0" to mean that the pointer itself is embedded | |
680 // in the code stream. We use a section_word relocation for such cases. | |
681 | |
682 if (sindex == CodeBuffer::SECT_NONE) { | |
683 assert(type() == relocInfo::internal_word_type, "must be base class"); | |
684 guarantee(_target == NULL || dest->allocates2(_target), "must be within the given code section"); | |
685 jint x0 = scaled_offset_null_special(_target, dest->locs_point()); | |
686 assert(!(x0 == 0 && _target != NULL), "correct encoding of null target"); | |
687 p = pack_1_int_to(p, x0); | |
688 } else { | |
689 assert(_target != NULL, "sanity"); | |
690 CodeSection* sect = dest->outer()->code_section(sindex); | |
691 guarantee(sect->allocates2(_target), "must be in correct section"); | |
692 address base = sect->start(); | |
693 jint offset = scaled_offset(_target, base); | |
694 assert((uint)sindex < (uint)CodeBuffer::SECT_LIMIT, "sanity"); | |
695 assert(CodeBuffer::SECT_LIMIT <= (1 << section_width), "section_width++"); | |
696 p = pack_1_int_to(p, (offset << section_width) | sindex); | |
697 } | |
698 | |
699 dest->set_locs_end((relocInfo*) p); | |
700 } | |
701 | |
702 | |
703 void internal_word_Relocation::unpack_data() { | |
704 jint x0 = unpack_1_int(); | |
705 _target = x0==0? NULL: address_from_scaled_offset(x0, addr()); | |
706 _section = CodeBuffer::SECT_NONE; | |
707 } | |
708 | |
709 | |
710 void section_word_Relocation::unpack_data() { | |
711 jint x = unpack_1_int(); | |
712 jint offset = (x >> section_width); | |
713 int sindex = (x & ((1<<section_width)-1)); | |
714 address base = binding()->section_start(sindex); | |
715 | |
716 _section = sindex; | |
717 _target = address_from_scaled_offset(offset, base); | |
718 } | |
719 | |
720 //// miscellaneous methods | |
721 oop* oop_Relocation::oop_addr() { | |
722 int n = _oop_index; | |
723 if (n == 0) { | |
724 // oop is stored in the code stream | |
725 return (oop*) pd_address_in_code(); | |
726 } else { | |
1563
1a5913bf5e19
6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents:
0
diff
changeset
|
727 // oop is stored in table at nmethod::oops_begin |
0 | 728 return code()->oop_addr_at(n); |
729 } | |
730 } | |
731 | |
732 | |
733 oop oop_Relocation::oop_value() { | |
734 oop v = *oop_addr(); | |
735 // clean inline caches store a special pseudo-null | |
736 if (v == (oop)Universe::non_oop_word()) v = NULL; | |
737 return v; | |
738 } | |
739 | |
740 | |
741 void oop_Relocation::fix_oop_relocation() { | |
742 if (!oop_is_immediate()) { | |
743 // get the oop from the pool, and re-insert it into the instruction: | |
744 set_value(value()); | |
745 } | |
746 } | |
747 | |
748 | |
2375
d673ef06fe96
7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents:
2192
diff
changeset
|
749 void oop_Relocation::verify_oop_relocation() { |
d673ef06fe96
7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents:
2192
diff
changeset
|
750 if (!oop_is_immediate()) { |
d673ef06fe96
7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents:
2192
diff
changeset
|
751 // get the oop from the pool, and re-insert it into the instruction: |
d673ef06fe96
7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents:
2192
diff
changeset
|
752 verify_value(value()); |
d673ef06fe96
7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents:
2192
diff
changeset
|
753 } |
d673ef06fe96
7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents:
2192
diff
changeset
|
754 } |
d673ef06fe96
7028374: race in fix_oop_relocations for scavengeable nmethods
never
parents:
2192
diff
changeset
|
755 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
756 // meta data versions |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
757 Metadata** metadata_Relocation::metadata_addr() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
758 int n = _metadata_index; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
759 if (n == 0) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
760 // metadata is stored in the code stream |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
761 return (Metadata**) pd_address_in_code(); |
0 | 762 } else { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
763 // metadata is stored in table at nmethod::metadatas_begin |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
764 return code()->metadata_addr_at(n); |
0 | 765 } |
766 } | |
767 | |
768 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
769 Metadata* metadata_Relocation::metadata_value() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
770 Metadata* v = *metadata_addr(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
771 // clean inline caches store a special pseudo-null |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
772 if (v == (Metadata*)Universe::non_oop_word()) v = NULL; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
773 return v; |
0 | 774 } |
775 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
776 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
777 void metadata_Relocation::fix_metadata_relocation() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
778 if (!metadata_is_immediate()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
779 // get the metadata from the pool, and re-insert it into the instruction: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
780 pd_fix_value(value()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
781 } |
0 | 782 } |
783 | |
784 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
785 void metadata_Relocation::verify_metadata_relocation() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
786 if (!metadata_is_immediate()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
787 // get the metadata from the pool, and re-insert it into the instruction: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
788 verify_value(value()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
789 } |
0 | 790 } |
791 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
792 address virtual_call_Relocation::cached_value() { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
793 assert(_cached_value != NULL && _cached_value < addr(), "must precede ic_call"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
794 return _cached_value; |
0 | 795 } |
796 | |
797 | |
798 void virtual_call_Relocation::clear_inline_cache() { | |
799 // No stubs for ICs | |
800 // Clean IC | |
801 ResourceMark rm; | |
802 CompiledIC* icache = CompiledIC_at(this); | |
803 icache->set_to_clean(); | |
804 } | |
805 | |
806 | |
807 void opt_virtual_call_Relocation::clear_inline_cache() { | |
808 // No stubs for ICs | |
809 // Clean IC | |
810 ResourceMark rm; | |
811 CompiledIC* icache = CompiledIC_at(this); | |
812 icache->set_to_clean(); | |
813 } | |
814 | |
815 | |
816 address opt_virtual_call_Relocation::static_stub() { | |
817 // search for the static stub who points back to this static call | |
818 address static_call_addr = addr(); | |
819 RelocIterator iter(code()); | |
820 while (iter.next()) { | |
821 if (iter.type() == relocInfo::static_stub_type) { | |
822 if (iter.static_stub_reloc()->static_call() == static_call_addr) { | |
823 return iter.addr(); | |
824 } | |
825 } | |
826 } | |
827 return NULL; | |
828 } | |
829 | |
830 | |
831 void static_call_Relocation::clear_inline_cache() { | |
832 // Safe call site info | |
833 CompiledStaticCall* handler = compiledStaticCall_at(this); | |
834 handler->set_to_clean(); | |
835 } | |
836 | |
837 | |
838 address static_call_Relocation::static_stub() { | |
839 // search for the static stub who points back to this static call | |
840 address static_call_addr = addr(); | |
841 RelocIterator iter(code()); | |
842 while (iter.next()) { | |
843 if (iter.type() == relocInfo::static_stub_type) { | |
844 if (iter.static_stub_reloc()->static_call() == static_call_addr) { | |
845 return iter.addr(); | |
846 } | |
847 } | |
848 } | |
849 return NULL; | |
850 } | |
851 | |
14397
53fa76359eb1
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
11041
diff
changeset
|
852 // Finds the trampoline address for a call. If no trampoline stub is |
53fa76359eb1
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
11041
diff
changeset
|
853 // found NULL is returned which can be handled by the caller. |
53fa76359eb1
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
11041
diff
changeset
|
854 address trampoline_stub_Relocation::get_trampoline_for(address call, nmethod* code) { |
53fa76359eb1
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
11041
diff
changeset
|
855 // There are no relocations available when the code gets relocated |
53fa76359eb1
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
11041
diff
changeset
|
856 // because of CodeBuffer expansion. |
53fa76359eb1
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
11041
diff
changeset
|
857 if (code->relocation_size() == 0) |
53fa76359eb1
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
11041
diff
changeset
|
858 return NULL; |
53fa76359eb1
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
11041
diff
changeset
|
859 |
53fa76359eb1
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
11041
diff
changeset
|
860 RelocIterator iter(code, call); |
53fa76359eb1
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
11041
diff
changeset
|
861 while (iter.next()) { |
53fa76359eb1
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
11041
diff
changeset
|
862 if (iter.type() == relocInfo::trampoline_stub_type) { |
53fa76359eb1
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
11041
diff
changeset
|
863 if (iter.trampoline_stub_reloc()->owner() == call) { |
53fa76359eb1
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
11041
diff
changeset
|
864 return iter.addr(); |
53fa76359eb1
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
11041
diff
changeset
|
865 } |
53fa76359eb1
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
11041
diff
changeset
|
866 } |
53fa76359eb1
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
11041
diff
changeset
|
867 } |
53fa76359eb1
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
11041
diff
changeset
|
868 |
53fa76359eb1
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
11041
diff
changeset
|
869 return NULL; |
53fa76359eb1
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
11041
diff
changeset
|
870 } |
0 | 871 |
872 void static_stub_Relocation::clear_inline_cache() { | |
873 // Call stub is only used when calling the interpreted code. | |
874 // It does not really need to be cleared, except that we want to clean out the methodoop. | |
875 CompiledStaticCall::set_stub_to_clean(this); | |
876 } | |
877 | |
878 | |
879 void external_word_Relocation::fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) { | |
880 address target = _target; | |
881 if (target == NULL) { | |
882 // An absolute embedded reference to an external location, | |
883 // which means there is nothing to fix here. | |
884 return; | |
885 } | |
886 // Probably this reference is absolute, not relative, so the | |
887 // following is probably a no-op. | |
888 assert(src->section_index_of(target) == CodeBuffer::SECT_NONE, "sanity"); | |
889 set_value(target); | |
890 } | |
891 | |
892 | |
893 address external_word_Relocation::target() { | |
894 address target = _target; | |
895 if (target == NULL) { | |
896 target = pd_get_address_from_code(); | |
897 } | |
898 return target; | |
899 } | |
900 | |
901 | |
902 void internal_word_Relocation::fix_relocation_after_move(const CodeBuffer* src, CodeBuffer* dest) { | |
903 address target = _target; | |
904 if (target == NULL) { | |
905 if (addr_in_const()) { | |
906 target = new_addr_for(*(address*)addr(), src, dest); | |
907 } else { | |
908 target = new_addr_for(pd_get_address_from_code(), src, dest); | |
909 } | |
910 } | |
911 set_value(target); | |
912 } | |
913 | |
914 | |
915 address internal_word_Relocation::target() { | |
916 address target = _target; | |
917 if (target == NULL) { | |
918 target = pd_get_address_from_code(); | |
919 } | |
920 return target; | |
921 } | |
922 | |
923 //--------------------------------------------------------------------------------- | |
924 // Non-product code | |
925 | |
926 #ifndef PRODUCT | |
927 | |
928 static const char* reloc_type_string(relocInfo::relocType t) { | |
929 switch (t) { | |
930 #define EACH_CASE(name) \ | |
931 case relocInfo::name##_type: \ | |
932 return #name; | |
933 | |
934 APPLY_TO_RELOCATIONS(EACH_CASE); | |
935 #undef EACH_CASE | |
936 | |
937 case relocInfo::none: | |
938 return "none"; | |
939 case relocInfo::data_prefix_tag: | |
940 return "prefix"; | |
941 default: | |
942 return "UNKNOWN RELOC TYPE"; | |
943 } | |
944 } | |
945 | |
946 | |
947 void RelocIterator::print_current() { | |
948 if (!has_current()) { | |
949 tty->print_cr("(no relocs)"); | |
950 return; | |
951 } | |
2002 | 952 tty->print("relocInfo@" INTPTR_FORMAT " [type=%d(%s) addr=" INTPTR_FORMAT " offset=%d", |
953 _current, type(), reloc_type_string((relocInfo::relocType) type()), _addr, _current->addr_offset()); | |
0 | 954 if (current()->format() != 0) |
955 tty->print(" format=%d", current()->format()); | |
956 if (datalen() == 1) { | |
957 tty->print(" data=%d", data()[0]); | |
958 } else if (datalen() > 0) { | |
959 tty->print(" data={"); | |
960 for (int i = 0; i < datalen(); i++) { | |
961 tty->print("%04x", data()[i] & 0xFFFF); | |
962 } | |
963 tty->print("}"); | |
964 } | |
965 tty->print("]"); | |
966 switch (type()) { | |
967 case relocInfo::oop_type: | |
968 { | |
969 oop_Relocation* r = oop_reloc(); | |
970 oop* oop_addr = NULL; | |
971 oop raw_oop = NULL; | |
972 oop oop_value = NULL; | |
973 if (code() != NULL || r->oop_is_immediate()) { | |
974 oop_addr = r->oop_addr(); | |
975 raw_oop = *oop_addr; | |
976 oop_value = r->oop_value(); | |
977 } | |
978 tty->print(" | [oop_addr=" INTPTR_FORMAT " *=" INTPTR_FORMAT " offset=%d]", | |
979 oop_addr, (address)raw_oop, r->offset()); | |
980 // Do not print the oop by default--we want this routine to | |
981 // work even during GC or other inconvenient times. | |
982 if (WizardMode && oop_value != NULL) { | |
983 tty->print("oop_value=" INTPTR_FORMAT ": ", (address)oop_value); | |
984 oop_value->print_value_on(tty); | |
985 } | |
986 break; | |
987 } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
988 case relocInfo::metadata_type: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
989 { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
990 metadata_Relocation* r = metadata_reloc(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
991 Metadata** metadata_addr = NULL; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
992 Metadata* raw_metadata = NULL; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
993 Metadata* metadata_value = NULL; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
994 if (code() != NULL || r->metadata_is_immediate()) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
995 metadata_addr = r->metadata_addr(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
996 raw_metadata = *metadata_addr; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
997 metadata_value = r->metadata_value(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
998 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
999 tty->print(" | [metadata_addr=" INTPTR_FORMAT " *=" INTPTR_FORMAT " offset=%d]", |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
1000 metadata_addr, (address)raw_metadata, r->offset()); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
1001 if (metadata_value != NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
1002 tty->print("metadata_value=" INTPTR_FORMAT ": ", (address)metadata_value); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
1003 metadata_value->print_value_on(tty); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
1004 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
1005 break; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
1006 } |
0 | 1007 case relocInfo::external_word_type: |
1008 case relocInfo::internal_word_type: | |
1009 case relocInfo::section_word_type: | |
1010 { | |
1011 DataRelocation* r = (DataRelocation*) reloc(); | |
1012 tty->print(" | [target=" INTPTR_FORMAT "]", r->value()); //value==target | |
1013 break; | |
1014 } | |
1015 case relocInfo::static_call_type: | |
1016 case relocInfo::runtime_call_type: | |
1017 { | |
1018 CallRelocation* r = (CallRelocation*) reloc(); | |
1019 tty->print(" | [destination=" INTPTR_FORMAT "]", r->destination()); | |
1020 break; | |
1021 } | |
1022 case relocInfo::virtual_call_type: | |
1023 { | |
1024 virtual_call_Relocation* r = (virtual_call_Relocation*) reloc(); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
1025 tty->print(" | [destination=" INTPTR_FORMAT " cached_value=" INTPTR_FORMAT "]", |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2468
diff
changeset
|
1026 r->destination(), r->cached_value()); |
0 | 1027 break; |
1028 } | |
1029 case relocInfo::static_stub_type: | |
1030 { | |
1031 static_stub_Relocation* r = (static_stub_Relocation*) reloc(); | |
1032 tty->print(" | [static_call=" INTPTR_FORMAT "]", r->static_call()); | |
1033 break; | |
1034 } | |
14397
53fa76359eb1
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
11041
diff
changeset
|
1035 case relocInfo::trampoline_stub_type: |
53fa76359eb1
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
11041
diff
changeset
|
1036 { |
53fa76359eb1
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
11041
diff
changeset
|
1037 trampoline_stub_Relocation* r = (trampoline_stub_Relocation*) reloc(); |
53fa76359eb1
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
11041
diff
changeset
|
1038 tty->print(" | [trampoline owner=" INTPTR_FORMAT "]", r->owner()); |
53fa76359eb1
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
11041
diff
changeset
|
1039 break; |
53fa76359eb1
8016696: PPC64 (part 4): add relocation for trampoline stubs
goetz
parents:
11041
diff
changeset
|
1040 } |
0 | 1041 } |
1042 tty->cr(); | |
1043 } | |
1044 | |
1045 | |
1046 void RelocIterator::print() { | |
1047 RelocIterator save_this = (*this); | |
1048 relocInfo* scan = _current; | |
1049 if (!has_current()) scan += 1; // nothing to scan here! | |
1050 | |
1051 bool skip_next = has_current(); | |
1052 bool got_next; | |
1053 while (true) { | |
1054 got_next = (skip_next || next()); | |
1055 skip_next = false; | |
1056 | |
1057 tty->print(" @" INTPTR_FORMAT ": ", scan); | |
1058 relocInfo* newscan = _current+1; | |
1059 if (!has_current()) newscan -= 1; // nothing to scan here! | |
1060 while (scan < newscan) { | |
1061 tty->print("%04x", *(short*)scan & 0xFFFF); | |
1062 scan++; | |
1063 } | |
1064 tty->cr(); | |
1065 | |
1066 if (!got_next) break; | |
1067 print_current(); | |
1068 } | |
1069 | |
1070 (*this) = save_this; | |
1071 } | |
1072 | |
1073 // For the debugger: | |
1074 extern "C" | |
1563
1a5913bf5e19
6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents:
0
diff
changeset
|
1075 void print_blob_locs(nmethod* nm) { |
1a5913bf5e19
6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents:
0
diff
changeset
|
1076 nm->print(); |
1a5913bf5e19
6951083: oops and relocations should part of nmethod not CodeBlob
twisti
parents:
0
diff
changeset
|
1077 RelocIterator iter(nm); |
0 | 1078 iter.print(); |
1079 } | |
1080 extern "C" | |
1081 void print_buf_locs(CodeBuffer* cb) { | |
1082 FlagSetting fs(PrintRelocations, true); | |
1083 cb->print(); | |
1084 } | |
1085 #endif // !PRODUCT |