< prev index next >

src/hotspot/share/oops/compressedOops.inline.hpp

Print this page




  41 // offset from the heap base.  Saving the check for null can save instructions
  42 // in inner GC loops so these are separated.
  43 
  44 inline oop CompressedOops::decode_raw(narrowOop v) {
  45   return (oop)(void*)((uintptr_t)base() + ((uintptr_t)v << shift()));
  46 }
  47 
  48 inline oop CompressedOops::decode_not_null(narrowOop v) {
  49   assert(!is_null(v), "narrow oop value can never be zero");
  50   oop result = decode_raw(v);
  51   assert(is_object_aligned(result), "address not aligned: " INTPTR_FORMAT, p2i((void*) result));
  52   return result;
  53 }
  54 
  55 inline oop CompressedOops::decode(narrowOop v) {
  56   return is_null(v) ? (oop)NULL : decode_not_null(v);
  57 }
  58 
  59 inline narrowOop CompressedOops::encode_not_null(oop v) {
  60   assert(!is_null(v), "oop value can never be zero");
  61   DEBUG_ONLY(Universe::heap()->check_oop_location(v);)
  62   uint64_t  pd = (uint64_t)(pointer_delta((void*)v, (void*)base(), 1));
  63   assert(OopEncodingHeapMax > pd, "change encoding max if new encoding");
  64   uint64_t result = pd >> shift();
  65   assert((result & CONST64(0xffffffff00000000)) == 0, "narrow oop overflow");
  66   assert(decode(result) == v, "reversibility");
  67   return (narrowOop)result;
  68 }
  69 
  70 inline narrowOop CompressedOops::encode(oop v) {
  71   return is_null(v) ? (narrowOop)0 : encode_not_null(v);
  72 }
  73 
  74 static inline bool check_alignment(Klass* v) {
  75   return (intptr_t)v % KlassAlignmentInBytes == 0;
  76 }
  77 
  78 inline Klass* CompressedKlassPointers::decode_raw(narrowKlass v) {
  79     return (Klass*)(void*)((uintptr_t)base() +((uintptr_t)v << shift()));
  80   }
  81 




  41 // offset from the heap base.  Saving the check for null can save instructions
  42 // in inner GC loops so these are separated.
  43 
  44 inline oop CompressedOops::decode_raw(narrowOop v) {
  45   return (oop)(void*)((uintptr_t)base() + ((uintptr_t)v << shift()));
  46 }
  47 
  48 inline oop CompressedOops::decode_not_null(narrowOop v) {
  49   assert(!is_null(v), "narrow oop value can never be zero");
  50   oop result = decode_raw(v);
  51   assert(is_object_aligned(result), "address not aligned: " INTPTR_FORMAT, p2i((void*) result));
  52   return result;
  53 }
  54 
  55 inline oop CompressedOops::decode(narrowOop v) {
  56   return is_null(v) ? (oop)NULL : decode_not_null(v);
  57 }
  58 
  59 inline narrowOop CompressedOops::encode_not_null(oop v) {
  60   assert(!is_null(v), "oop value can never be zero");
  61   assert(Universe::heap()->is_oop_location(v), "invalid oop location");
  62   uint64_t  pd = (uint64_t)(pointer_delta((void*)v, (void*)base(), 1));
  63   assert(OopEncodingHeapMax > pd, "change encoding max if new encoding");
  64   uint64_t result = pd >> shift();
  65   assert((result & CONST64(0xffffffff00000000)) == 0, "narrow oop overflow");
  66   assert(decode(result) == v, "reversibility");
  67   return (narrowOop)result;
  68 }
  69 
  70 inline narrowOop CompressedOops::encode(oop v) {
  71   return is_null(v) ? (narrowOop)0 : encode_not_null(v);
  72 }
  73 
  74 static inline bool check_alignment(Klass* v) {
  75   return (intptr_t)v % KlassAlignmentInBytes == 0;
  76 }
  77 
  78 inline Klass* CompressedKlassPointers::decode_raw(narrowKlass v) {
  79     return (Klass*)(void*)((uintptr_t)base() +((uintptr_t)v << shift()));
  80   }
  81 


< prev index next >