annotate src/share/vm/code/relocInfo.cpp @ 14456:abec000618bf

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