278 jlong* oopDesc::long_field_addr(int offset) const { return (jlong*) field_base(offset); }
279 jfloat* oopDesc::float_field_addr(int offset) const { return (jfloat*) field_base(offset); }
280 jdouble* oopDesc::double_field_addr(int offset) const { return (jdouble*) field_base(offset); }
281 Metadata** oopDesc::metadata_field_addr(int offset) const { return (Metadata**)field_base(offset); }
282
283 template <class T> T* oopDesc::obj_field_addr(int offset) const { return (T*) field_base(offset); }
284 address* oopDesc::address_field_addr(int offset) const { return (address*) field_base(offset); }
285
286
287 // Functions for getting and setting oops within instance objects.
288 // If the oops are compressed, the type passed to these overloaded functions
289 // is narrowOop. All functions are overloaded so they can be called by
290 // template functions without conditionals (the compiler instantiates via
291 // the right type and inlines the appopriate code).
292
293 // Algorithm for encoding and decoding oops from 64 bit pointers to 32 bit
294 // offset from the heap base. Saving the check for null can save instructions
295 // in inner GC loops so these are separated.
296
297 inline bool check_obj_alignment(oop obj) {
298 return cast_from_oop<intptr_t>(obj) % MinObjAlignmentInBytes == 0;
299 }
300
301 oop oopDesc::decode_heap_oop_not_null(narrowOop v) {
302 assert(!is_null(v), "narrow oop value can never be zero");
303 address base = Universe::narrow_oop_base();
304 int shift = Universe::narrow_oop_shift();
305 oop result = (oop)(void*)((uintptr_t)base + ((uintptr_t)v << shift));
306 assert(check_obj_alignment(result), "address not aligned: " INTPTR_FORMAT, p2i((void*) result));
307 return result;
308 }
309
310 oop oopDesc::decode_heap_oop(narrowOop v) {
311 return is_null(v) ? (oop)NULL : decode_heap_oop_not_null(v);
312 }
313
314 narrowOop oopDesc::encode_heap_oop_not_null(oop v) {
315 assert(!is_null(v), "oop value can never be zero");
316 assert(check_obj_alignment(v), "Address not aligned");
317 assert(Universe::heap()->is_in_reserved(v), "Address not in heap");
318 address base = Universe::narrow_oop_base();
|
278 jlong* oopDesc::long_field_addr(int offset) const { return (jlong*) field_base(offset); }
279 jfloat* oopDesc::float_field_addr(int offset) const { return (jfloat*) field_base(offset); }
280 jdouble* oopDesc::double_field_addr(int offset) const { return (jdouble*) field_base(offset); }
281 Metadata** oopDesc::metadata_field_addr(int offset) const { return (Metadata**)field_base(offset); }
282
283 template <class T> T* oopDesc::obj_field_addr(int offset) const { return (T*) field_base(offset); }
284 address* oopDesc::address_field_addr(int offset) const { return (address*) field_base(offset); }
285
286
287 // Functions for getting and setting oops within instance objects.
288 // If the oops are compressed, the type passed to these overloaded functions
289 // is narrowOop. All functions are overloaded so they can be called by
290 // template functions without conditionals (the compiler instantiates via
291 // the right type and inlines the appopriate code).
292
293 // Algorithm for encoding and decoding oops from 64 bit pointers to 32 bit
294 // offset from the heap base. Saving the check for null can save instructions
295 // in inner GC loops so these are separated.
296
297 inline bool check_obj_alignment(oop obj) {
298 return (cast_from_oop<intptr_t>(obj) & MinObjAlignmentInBytesMask) == 0;
299 }
300
301 oop oopDesc::decode_heap_oop_not_null(narrowOop v) {
302 assert(!is_null(v), "narrow oop value can never be zero");
303 address base = Universe::narrow_oop_base();
304 int shift = Universe::narrow_oop_shift();
305 oop result = (oop)(void*)((uintptr_t)base + ((uintptr_t)v << shift));
306 assert(check_obj_alignment(result), "address not aligned: " INTPTR_FORMAT, p2i((void*) result));
307 return result;
308 }
309
310 oop oopDesc::decode_heap_oop(narrowOop v) {
311 return is_null(v) ? (oop)NULL : decode_heap_oop_not_null(v);
312 }
313
314 narrowOop oopDesc::encode_heap_oop_not_null(oop v) {
315 assert(!is_null(v), "oop value can never be zero");
316 assert(check_obj_alignment(v), "Address not aligned");
317 assert(Universe::heap()->is_in_reserved(v), "Address not in heap");
318 address base = Universe::narrow_oop_base();
|