hotspot/src/share/vm/oops/oop.cpp
changeset 46968 9119841280f4
parent 46810 7dad333205cd
equal deleted inserted replaced
46953:39063b484ec2 46968:9119841280f4
   119     vm_exit_out_of_memory(length, OOM_MALLOC_ERROR, "unable to create Unicode strings for String table rehash");
   119     vm_exit_out_of_memory(length, OOM_MALLOC_ERROR, "unable to create Unicode strings for String table rehash");
   120     return 0;
   120     return 0;
   121   }
   121   }
   122 }
   122 }
   123 
   123 
       
   124 // used only for asserts and guarantees
       
   125 bool oopDesc::is_oop(oop obj, bool ignore_mark_word) {
       
   126   if (!check_obj_alignment(obj)) return false;
       
   127   if (!Universe::heap()->is_in_reserved(obj)) return false;
       
   128   // obj is aligned and accessible in heap
       
   129   if (Universe::heap()->is_in_reserved(obj->klass_or_null())) return false;
       
   130 
       
   131   // Header verification: the mark is typically non-NULL. If we're
       
   132   // at a safepoint, it must not be null.
       
   133   // Outside of a safepoint, the header could be changing (for example,
       
   134   // another thread could be inflating a lock on this object).
       
   135   if (ignore_mark_word) {
       
   136     return true;
       
   137   }
       
   138   if (obj->mark() != NULL) {
       
   139     return true;
       
   140   }
       
   141   return !SafepointSynchronize::is_at_safepoint();
       
   142 }
       
   143 
       
   144 // used only for asserts and guarantees
       
   145 bool oopDesc::is_oop_or_null(oop obj, bool ignore_mark_word) {
       
   146   return obj == NULL ? true : is_oop(obj, ignore_mark_word);
       
   147 }
       
   148 
       
   149 #ifndef PRODUCT
       
   150 // used only for asserts
       
   151 bool oopDesc::is_unlocked_oop() const {
       
   152   if (!Universe::heap()->is_in_reserved(this)) return false;
       
   153   return mark()->is_unlocked();
       
   154 }
       
   155 #endif // PRODUCT
       
   156 
   124 VerifyOopClosure VerifyOopClosure::verify_oop;
   157 VerifyOopClosure VerifyOopClosure::verify_oop;
   125 
   158 
   126 template <class T> void VerifyOopClosure::do_oop_work(T* p) {
   159 template <class T> void VerifyOopClosure::do_oop_work(T* p) {
   127   oop obj = oopDesc::load_decode_heap_oop(p);
   160   oop obj = oopDesc::load_decode_heap_oop(p);
   128   guarantee(obj->is_oop_or_null(), "invalid oop: " INTPTR_FORMAT, p2i((oopDesc*) obj));
   161   guarantee(oopDesc::is_oop_or_null(obj), "invalid oop: " INTPTR_FORMAT, p2i((oopDesc*) obj));
   129 }
   162 }
   130 
   163 
   131 void VerifyOopClosure::do_oop(oop* p)       { VerifyOopClosure::do_oop_work(p); }
   164 void VerifyOopClosure::do_oop(oop* p)       { VerifyOopClosure::do_oop_work(p); }
   132 void VerifyOopClosure::do_oop(narrowOop* p) { VerifyOopClosure::do_oop_work(p); }
   165 void VerifyOopClosure::do_oop(narrowOop* p) { VerifyOopClosure::do_oop_work(p); }
   133 
   166