< prev index next >

src/hotspot/share/oops/oop.cpp

Print this page




  79 }
  80 
  81 
  82 void oopDesc::verify_on(outputStream* st, oopDesc* oop_desc) {
  83   if (oop_desc != NULL) {
  84     oop_desc->klass()->oop_verify_on(oop_desc, st);
  85   }
  86 }
  87 
  88 
  89 void oopDesc::verify(oopDesc* oop_desc) {
  90   verify_on(tty, oop_desc);
  91 }
  92 
  93 intptr_t oopDesc::slow_identity_hash() {
  94   // slow case; we have to acquire the micro lock in order to locate the header
  95   Thread* THREAD = Thread::current();
  96   ResetNoHandleMark rnm; // Might be called from LEAF/QUICK ENTRY
  97   HandleMark hm(THREAD);
  98   Handle object(THREAD, this);
  99   return ObjectSynchronizer::identity_hash_value_for(object);
 100 }
 101 
 102 // used only for asserts and guarantees
 103 bool oopDesc::is_oop(oop obj, bool ignore_mark_word) {
 104   if (!Universe::heap()->is_oop(obj)) {
 105     return false;
 106   }
 107 
 108   // Header verification: the mark is typically non-NULL. If we're
 109   // at a safepoint, it must not be null.
 110   // Outside of a safepoint, the header could be changing (for example,
 111   // another thread could be inflating a lock on this object).
 112   if (ignore_mark_word) {
 113     return true;
 114   }
 115   if (obj->mark_raw() != NULL) {
 116     return true;
 117   }
 118   return !SafepointSynchronize::is_at_safepoint();
 119 }
 120 
 121 // used only for asserts and guarantees
 122 bool oopDesc::is_oop_or_null(oop obj, bool ignore_mark_word) {
 123   return obj == NULL ? true : is_oop(obj, ignore_mark_word);
 124 }
 125 
 126 #ifndef PRODUCT
 127 #if INCLUDE_CDS_JAVA_HEAP
 128 bool oopDesc::is_archived_object(oop p) {
 129   return HeapShared::is_archived_object(p);
 130 }
 131 #endif
 132 #endif // PRODUCT
 133 
 134 VerifyOopClosure VerifyOopClosure::verify_oop;
 135 
 136 template <class T> void VerifyOopClosure::do_oop_work(T* p) {
 137   oop obj = RawAccess<>::oop_load(p);
 138   guarantee(oopDesc::is_oop_or_null(obj), "invalid oop: " INTPTR_FORMAT, p2i((oopDesc*) obj));
 139 }
 140 
 141 void VerifyOopClosure::do_oop(oop* p)       { VerifyOopClosure::do_oop_work(p); }
 142 void VerifyOopClosure::do_oop(narrowOop* p) { VerifyOopClosure::do_oop_work(p); }
 143 
 144 // type test operations that doesn't require inclusion of oop.inline.hpp.
 145 bool oopDesc::is_instance_noinline()          const { return is_instance();            }
 146 bool oopDesc::is_array_noinline()             const { return is_array();               }
 147 bool oopDesc::is_objArray_noinline()          const { return is_objArray();            }
 148 bool oopDesc::is_typeArray_noinline()         const { return is_typeArray();           }


 149 
 150 bool oopDesc::has_klass_gap() {
 151   // Only has a klass gap when compressed class pointers are used.
 152   return UseCompressedClassPointers;
 153 }
 154 
 155 void* oopDesc::load_klass_raw(oop obj) {
 156   if (UseCompressedClassPointers) {
 157     narrowKlass narrow_klass = *(obj->compressed_klass_addr());
 158     if (narrow_klass == 0) return NULL;
 159     return (void*)CompressedKlassPointers::decode_raw(narrow_klass);
 160   } else {
 161     return *(void**)(obj->klass_addr());
 162   }
 163 }
 164 
 165 void* oopDesc::load_oop_raw(oop obj, int offset) {
 166   uintptr_t addr = (uintptr_t)(void*)obj + (uint)offset;
 167   if (UseCompressedOops) {
 168     narrowOop narrow_oop = *(narrowOop*)addr;




  79 }
  80 
  81 
  82 void oopDesc::verify_on(outputStream* st, oopDesc* oop_desc) {
  83   if (oop_desc != NULL) {
  84     oop_desc->klass()->oop_verify_on(oop_desc, st);
  85   }
  86 }
  87 
  88 
  89 void oopDesc::verify(oopDesc* oop_desc) {
  90   verify_on(tty, oop_desc);
  91 }
  92 
  93 intptr_t oopDesc::slow_identity_hash() {
  94   // slow case; we have to acquire the micro lock in order to locate the header
  95   Thread* THREAD = Thread::current();
  96   ResetNoHandleMark rnm; // Might be called from LEAF/QUICK ENTRY
  97   HandleMark hm(THREAD);
  98   Handle object(THREAD, this);
  99   return ObjectSynchronizer::FastHashCode(THREAD, object());
 100 }
 101 
 102 // used only for asserts and guarantees
 103 bool oopDesc::is_oop(oop obj, bool ignore_mark_word) {
 104   if (!Universe::heap()->is_oop(obj)) {
 105     return false;
 106   }
 107 
 108   // Header verification: the mark is typically non-NULL. If we're
 109   // at a safepoint, it must not be null.
 110   // Outside of a safepoint, the header could be changing (for example,
 111   // another thread could be inflating a lock on this object).
 112   if (ignore_mark_word) {
 113     return true;
 114   }
 115   if (obj->mark_raw() != NULL) {
 116     return true;
 117   }
 118   return !SafepointSynchronize::is_at_safepoint() ;
 119 }
 120 
 121 // used only for asserts and guarantees
 122 bool oopDesc::is_oop_or_null(oop obj, bool ignore_mark_word) {
 123   return obj == NULL ? true : is_oop(obj, ignore_mark_word);
 124 }
 125 
 126 #ifndef PRODUCT
 127 #if INCLUDE_CDS_JAVA_HEAP
 128 bool oopDesc::is_archived_object(oop p) {
 129   return HeapShared::is_archived_object(p);
 130 }
 131 #endif
 132 #endif // PRODUCT
 133 
 134 VerifyOopClosure VerifyOopClosure::verify_oop;
 135 
 136 template <class T> void VerifyOopClosure::do_oop_work(T* p) {
 137   oop obj = RawAccess<>::oop_load(p);
 138   guarantee(oopDesc::is_oop_or_null(obj), "invalid oop: " INTPTR_FORMAT, p2i((oopDesc*) obj));
 139 }
 140 
 141 void VerifyOopClosure::do_oop(oop* p)       { VerifyOopClosure::do_oop_work(p); }
 142 void VerifyOopClosure::do_oop(narrowOop* p) { VerifyOopClosure::do_oop_work(p); }
 143 
 144 // type test operations that doesn't require inclusion of oop.inline.hpp.
 145 bool oopDesc::is_instance_noinline()          const { return is_instance();            }
 146 bool oopDesc::is_array_noinline()             const { return is_array();               }
 147 bool oopDesc::is_objArray_noinline()          const { return is_objArray();            }
 148 bool oopDesc::is_typeArray_noinline()         const { return is_typeArray();           }
 149 bool oopDesc::is_value_noinline()             const { return is_value();               }
 150 bool oopDesc::is_valueArray_noinline()        const { return is_valueArray();          }
 151 
 152 bool oopDesc::has_klass_gap() {
 153   // Only has a klass gap when compressed class pointers are used.
 154   return UseCompressedClassPointers;
 155 }
 156 
 157 void* oopDesc::load_klass_raw(oop obj) {
 158   if (UseCompressedClassPointers) {
 159     narrowKlass narrow_klass = *(obj->compressed_klass_addr());
 160     if (narrow_klass == 0) return NULL;
 161     return (void*)CompressedKlassPointers::decode_raw(narrow_klass);
 162   } else {
 163     return *(void**)(obj->klass_addr());
 164   }
 165 }
 166 
 167 void* oopDesc::load_oop_raw(oop obj, int offset) {
 168   uintptr_t addr = (uintptr_t)(void*)obj + (uint)offset;
 169   if (UseCompressedOops) {
 170     narrowOop narrow_oop = *(narrowOop*)addr;


< prev index next >