< prev index next >

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

Print this page




  49     int    shift = Universe::narrow_oop_shift();
  50     oop result = (oop)(void*)((uintptr_t)base + ((uintptr_t)v << shift));
  51     assert(check_obj_alignment(result), "address not aligned: " INTPTR_FORMAT, p2i((void*) result));
  52     return result;
  53   }
  54 
  55   inline oop decode(narrowOop v) {
  56     return is_null(v) ? (oop)NULL : decode_not_null(v);
  57   }
  58 
  59   inline narrowOop encode_not_null(oop v) {
  60     assert(!is_null(v), "oop value can never be zero");
  61     assert(check_obj_alignment(v), "Address not aligned");
  62     assert(Universe::heap()->is_in_reserved(v), "Address not in heap");
  63     address base = Universe::narrow_oop_base();
  64     int    shift = Universe::narrow_oop_shift();
  65     uint64_t  pd = (uint64_t)(pointer_delta((void*)v, (void*)base, 1));
  66     assert(OopEncodingHeapMax > pd, "change encoding max if new encoding");
  67     uint64_t result = pd >> shift;
  68     assert((result & CONST64(0xffffffff00000000)) == 0, "narrow oop overflow");
  69     assert(decode(result) == v, "reversibility");
  70     return (narrowOop)result;
  71   }
  72 
  73   inline narrowOop encode(oop v) {
  74     return is_null(v) ? (narrowOop)0 : encode_not_null(v);
  75   }
  76 
  77   // No conversions needed for these overloads
  78   inline oop decode_not_null(oop v)             { return v; }
  79   inline oop decode(oop v)                      { return v; }
  80   inline narrowOop encode_not_null(narrowOop v) { return v; }
  81   inline narrowOop encode(narrowOop v)          { return v; }
  82 }
  83 
  84 #endif // SHARE_OOPS_COMPRESSEDOOPS_INLINE_HPP


  49     int    shift = Universe::narrow_oop_shift();
  50     oop result = (oop)(void*)((uintptr_t)base + ((uintptr_t)v << shift));
  51     assert(check_obj_alignment(result), "address not aligned: " INTPTR_FORMAT, p2i((void*) result));
  52     return result;
  53   }
  54 
  55   inline oop decode(narrowOop v) {
  56     return is_null(v) ? (oop)NULL : decode_not_null(v);
  57   }
  58 
  59   inline narrowOop encode_not_null(oop v) {
  60     assert(!is_null(v), "oop value can never be zero");
  61     assert(check_obj_alignment(v), "Address not aligned");
  62     assert(Universe::heap()->is_in_reserved(v), "Address not in heap");
  63     address base = Universe::narrow_oop_base();
  64     int    shift = Universe::narrow_oop_shift();
  65     uint64_t  pd = (uint64_t)(pointer_delta((void*)v, (void*)base, 1));
  66     assert(OopEncodingHeapMax > pd, "change encoding max if new encoding");
  67     uint64_t result = pd >> shift;
  68     assert((result & CONST64(0xffffffff00000000)) == 0, "narrow oop overflow");
  69     assert(oopDesc::unsafe_equals(decode(result), v), "reversibility");
  70     return (narrowOop)result;
  71   }
  72 
  73   inline narrowOop encode(oop v) {
  74     return is_null(v) ? (narrowOop)0 : encode_not_null(v);
  75   }
  76 
  77   // No conversions needed for these overloads
  78   inline oop decode_not_null(oop v)             { return v; }
  79   inline oop decode(oop v)                      { return v; }
  80   inline narrowOop encode_not_null(narrowOop v) { return v; }
  81   inline narrowOop encode(narrowOop v)          { return v; }
  82 }
  83 
  84 #endif // SHARE_OOPS_COMPRESSEDOOPS_INLINE_HPP
< prev index next >