< prev index next >

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

Print this page
rev 48545 : Value-based classes (vbc) / Oop value test via metadata ptr


  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 template <typename T>
  75 bool Klass::is_instanceof_or_null(T element) {
  76   if (oopDesc::is_null(element)) {
  77     return true;
  78   }
  79   oop obj = oopDesc::decode_heap_oop_not_null(element);
  80   return obj->klass()->is_subtype_of(this);
  81 }
  82 
  83 #endif // SHARE_VM_OOPS_KLASS_INLINE_HPP


  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 #if INCLUDE_VBC
  75 inline bool Klass::decode_ptr_is_value_based(narrowKlass v) {
  76         return (v & Universe::oop_metadata_odd_mask());
  77 }
  78 inline bool Klass::ptr_is_value_based(Klass* v) {
  79         return ((uintptr_t)v & Universe::oop_metadata_odd_mask());
  80 }
  81 #endif
  82 
  83 
  84 template <typename T>
  85 bool Klass::is_instanceof_or_null(T element) {
  86   if (oopDesc::is_null(element)) {
  87     return true;
  88   }
  89   oop obj = oopDesc::decode_heap_oop_not_null(element);
  90   return obj->klass()->is_subtype_of(this);
  91 }
  92 
  93 #endif // SHARE_VM_OOPS_KLASS_INLINE_HPP
< prev index next >