< prev index next >

src/share/vm/oops/klass.inline.hpp

Print this page




  46 inline narrowKlass Klass::encode_klass_not_null(Klass* v) {
  47   assert(!is_null(v), "klass value can never be zero");
  48   assert(check_klass_alignment(v), "Address not aligned");
  49   int    shift = Universe::narrow_klass_shift();
  50   uint64_t pd = (uint64_t)(pointer_delta((void*)v, Universe::narrow_klass_base(), 1));
  51   assert(KlassEncodingMetaspaceMax > pd, "change encoding max if new encoding");
  52   uint64_t result = pd >> shift;
  53   assert((result & CONST64(0xffffffff00000000)) == 0, "narrow klass pointer overflow");
  54   assert(decode_klass(result) == v, "reversibility");
  55   return (narrowKlass)result;
  56 }
  57 
  58 inline narrowKlass Klass::encode_klass(Klass* v) {
  59   return is_null(v) ? (narrowKlass)0 : encode_klass_not_null(v);
  60 }
  61 
  62 inline Klass* Klass::decode_klass_not_null(narrowKlass v) {
  63   assert(!is_null(v), "narrow klass value can never be zero");
  64   int    shift = Universe::narrow_klass_shift();
  65   Klass* result = (Klass*)(void*)((uintptr_t)Universe::narrow_klass_base() + ((uintptr_t)v << shift));
  66   assert(check_klass_alignment(result), err_msg("address not aligned: " INTPTR_FORMAT, p2i((void*) result)));
  67   return result;
  68 }
  69 
  70 inline Klass* Klass::decode_klass(narrowKlass v) {
  71   return is_null(v) ? (Klass*)NULL : decode_klass_not_null(v);
  72 }
  73 
  74 #endif // SHARE_VM_OOPS_KLASS_INLINE_HPP


  46 inline narrowKlass Klass::encode_klass_not_null(Klass* v) {
  47   assert(!is_null(v), "klass value can never be zero");
  48   assert(check_klass_alignment(v), "Address not aligned");
  49   int    shift = Universe::narrow_klass_shift();
  50   uint64_t pd = (uint64_t)(pointer_delta((void*)v, Universe::narrow_klass_base(), 1));
  51   assert(KlassEncodingMetaspaceMax > pd, "change encoding max if new encoding");
  52   uint64_t result = pd >> shift;
  53   assert((result & CONST64(0xffffffff00000000)) == 0, "narrow klass pointer overflow");
  54   assert(decode_klass(result) == v, "reversibility");
  55   return (narrowKlass)result;
  56 }
  57 
  58 inline narrowKlass Klass::encode_klass(Klass* v) {
  59   return is_null(v) ? (narrowKlass)0 : encode_klass_not_null(v);
  60 }
  61 
  62 inline Klass* Klass::decode_klass_not_null(narrowKlass v) {
  63   assert(!is_null(v), "narrow klass value can never be zero");
  64   int    shift = Universe::narrow_klass_shift();
  65   Klass* result = (Klass*)(void*)((uintptr_t)Universe::narrow_klass_base() + ((uintptr_t)v << shift));
  66   assert(check_klass_alignment(result), "address not aligned: " INTPTR_FORMAT, p2i((void*) result));
  67   return result;
  68 }
  69 
  70 inline Klass* Klass::decode_klass(narrowKlass v) {
  71   return is_null(v) ? (Klass*)NULL : decode_klass_not_null(v);
  72 }
  73 
  74 #endif // SHARE_VM_OOPS_KLASS_INLINE_HPP
< prev index next >