11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "code/codeCache.hpp"
27 #include "code/compiledIC.hpp"
28 #include "code/nmethod.hpp"
29 #include "code/relocInfo.hpp"
30 #include "memory/resourceArea.hpp"
31 #include "runtime/stubCodeGenerator.hpp"
32 #include "utilities/copy.hpp"
33 #include "oops/oop.inline.hpp"
34
35 const RelocationHolder RelocationHolder::none; // its type is relocInfo::none
36
37
38 // Implementation of relocInfo
39
40 #ifdef ASSERT
41 relocInfo::relocInfo(relocType t, int off, int f) {
42 assert(t != data_prefix_tag, "cannot build a prefix this way");
43 assert((t & type_mask) == t, "wrong type");
44 assert((f & format_mask) == f, "wrong format");
45 assert(off >= 0 && off < offset_limit(), "offset out off bounds");
46 assert((off & (offset_unit-1)) == 0, "misaligned offset");
47 (*this) = relocInfo(t, RAW_BITS, off, f);
48 }
49 #endif
50
290
291
292 void Relocation::guarantee_size() {
293 guarantee(false, "Make _relocbuf bigger!");
294 }
295
296 // some relocations can compute their own values
297 address Relocation::value() {
298 ShouldNotReachHere();
299 return NULL;
300 }
301
302
303 void Relocation::set_value(address x) {
304 ShouldNotReachHere();
305 }
306
307 void Relocation::const_set_data_value(address x) {
308 #ifdef _LP64
309 if (format() == relocInfo::narrow_oop_in_const) {
310 *(narrowOop*)addr() = oopDesc::encode_heap_oop((oop) x);
311 } else {
312 #endif
313 *(address*)addr() = x;
314 #ifdef _LP64
315 }
316 #endif
317 }
318
319 void Relocation::const_verify_data_value(address x) {
320 #ifdef _LP64
321 if (format() == relocInfo::narrow_oop_in_const) {
322 guarantee(*(narrowOop*)addr() == oopDesc::encode_heap_oop((oop) x), "must agree");
323 } else {
324 #endif
325 guarantee(*(address*)addr() == x, "must agree");
326 #ifdef _LP64
327 }
328 #endif
329 }
330
331
332 RelocationHolder Relocation::spec_simple(relocInfo::relocType rtype) {
333 if (rtype == relocInfo::none) return RelocationHolder::none;
334 relocInfo ri = relocInfo(rtype, 0);
335 RelocIterator itr;
336 itr.set_current(ri);
337 itr.reloc();
338 return itr._rh;
339 }
340
341 address Relocation::old_addr_for(address newa,
342 const CodeBuffer* src, CodeBuffer* dest) {
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "code/codeCache.hpp"
27 #include "code/compiledIC.hpp"
28 #include "code/nmethod.hpp"
29 #include "code/relocInfo.hpp"
30 #include "memory/resourceArea.hpp"
31 #include "oops/compressedOops.inline.hpp"
32 #include "runtime/stubCodeGenerator.hpp"
33 #include "utilities/copy.hpp"
34 #include "oops/oop.inline.hpp"
35
36 const RelocationHolder RelocationHolder::none; // its type is relocInfo::none
37
38
39 // Implementation of relocInfo
40
41 #ifdef ASSERT
42 relocInfo::relocInfo(relocType t, int off, int f) {
43 assert(t != data_prefix_tag, "cannot build a prefix this way");
44 assert((t & type_mask) == t, "wrong type");
45 assert((f & format_mask) == f, "wrong format");
46 assert(off >= 0 && off < offset_limit(), "offset out off bounds");
47 assert((off & (offset_unit-1)) == 0, "misaligned offset");
48 (*this) = relocInfo(t, RAW_BITS, off, f);
49 }
50 #endif
51
291
292
293 void Relocation::guarantee_size() {
294 guarantee(false, "Make _relocbuf bigger!");
295 }
296
297 // some relocations can compute their own values
298 address Relocation::value() {
299 ShouldNotReachHere();
300 return NULL;
301 }
302
303
304 void Relocation::set_value(address x) {
305 ShouldNotReachHere();
306 }
307
308 void Relocation::const_set_data_value(address x) {
309 #ifdef _LP64
310 if (format() == relocInfo::narrow_oop_in_const) {
311 *(narrowOop*)addr() = CompressedOops::encode((oop) x);
312 } else {
313 #endif
314 *(address*)addr() = x;
315 #ifdef _LP64
316 }
317 #endif
318 }
319
320 void Relocation::const_verify_data_value(address x) {
321 #ifdef _LP64
322 if (format() == relocInfo::narrow_oop_in_const) {
323 guarantee(*(narrowOop*)addr() == CompressedOops::encode((oop) x), "must agree");
324 } else {
325 #endif
326 guarantee(*(address*)addr() == x, "must agree");
327 #ifdef _LP64
328 }
329 #endif
330 }
331
332
333 RelocationHolder Relocation::spec_simple(relocInfo::relocType rtype) {
334 if (rtype == relocInfo::none) return RelocationHolder::none;
335 relocInfo ri = relocInfo(rtype, 0);
336 RelocIterator itr;
337 itr.set_current(ri);
338 itr.reloc();
339 return itr._rh;
340 }
341
342 address Relocation::old_addr_for(address newa,
343 const CodeBuffer* src, CodeBuffer* dest) {
|