< 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* current = Thread::current();
 96   ResetNoHandleMark rnm; // Might be called from LEAF/QUICK ENTRY
 97   HandleMark hm(current);
 98   Handle object(current, 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-zero. If we're
109   // at a safepoint, it must not be zero.
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().value() != 0) {
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 VerifyOopClosure VerifyOopClosure::verify_oop;
127 
128 template <class T> void VerifyOopClosure::do_oop_work(T* p) {
129   oop obj = RawAccess<>::oop_load(p);
130   guarantee(oopDesc::is_oop_or_null(obj), "invalid oop: " INTPTR_FORMAT, p2i((oopDesc*) obj));
131 }
132 
133 void VerifyOopClosure::do_oop(oop* p)       { VerifyOopClosure::do_oop_work(p); }
134 void VerifyOopClosure::do_oop(narrowOop* p) { VerifyOopClosure::do_oop_work(p); }
135 
136 // type test operations that doesn't require inclusion of oop.inline.hpp.
137 bool oopDesc::is_instance_noinline()          const { return is_instance();            }
138 bool oopDesc::is_array_noinline()             const { return is_array();               }
139 bool oopDesc::is_objArray_noinline()          const { return is_objArray();            }
140 bool oopDesc::is_typeArray_noinline()         const { return is_typeArray();           }


141 
142 bool oopDesc::has_klass_gap() {
143   // Only has a klass gap when compressed class pointers are used.
144   return UseCompressedClassPointers;
145 }
146 
147 #if INCLUDE_CDS_JAVA_HEAP
148 void oopDesc::set_narrow_klass(narrowKlass nk) {
149   assert(DumpSharedSpaces, "Used by CDS only. Do not abuse!");
150   assert(UseCompressedClassPointers, "must be");
151   _metadata._compressed_klass = nk;
152 }
153 #endif
154 
155 void* oopDesc::load_klass_raw(oop obj) {
156   if (UseCompressedClassPointers) {
157     narrowKlass narrow_klass = obj->_metadata._compressed_klass;
158     if (narrow_klass == 0) return NULL;
159     return (void*)CompressedKlassPointers::decode_raw(narrow_klass);
160   } else {

 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* current = Thread::current();
 96   ResetNoHandleMark rnm; // Might be called from LEAF/QUICK ENTRY
 97   HandleMark hm(current);
 98   Handle object(current, this);
 99   return ObjectSynchronizer::FastHashCode(current, 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-zero. If we're
109   // at a safepoint, it must not be zero.
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().value() != 0) {
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 VerifyOopClosure VerifyOopClosure::verify_oop;
127 
128 template <class T> void VerifyOopClosure::do_oop_work(T* p) {
129   oop obj = RawAccess<>::oop_load(p);
130   guarantee(oopDesc::is_oop_or_null(obj), "invalid oop: " INTPTR_FORMAT, p2i((oopDesc*) obj));
131 }
132 
133 void VerifyOopClosure::do_oop(oop* p)       { VerifyOopClosure::do_oop_work(p); }
134 void VerifyOopClosure::do_oop(narrowOop* p) { VerifyOopClosure::do_oop_work(p); }
135 
136 // type test operations that doesn't require inclusion of oop.inline.hpp.
137 bool oopDesc::is_instance_noinline()          const { return is_instance();            }
138 bool oopDesc::is_array_noinline()             const { return is_array();               }
139 bool oopDesc::is_objArray_noinline()          const { return is_objArray();            }
140 bool oopDesc::is_typeArray_noinline()         const { return is_typeArray();           }
141 bool oopDesc::is_flatArray_noinline()         const { return is_flatArray();           }
142 bool oopDesc::is_null_free_array_noinline()   const { return is_null_free_array();     }
143 
144 bool oopDesc::has_klass_gap() {
145   // Only has a klass gap when compressed class pointers are used.
146   return UseCompressedClassPointers;
147 }
148 
149 #if INCLUDE_CDS_JAVA_HEAP
150 void oopDesc::set_narrow_klass(narrowKlass nk) {
151   assert(DumpSharedSpaces, "Used by CDS only. Do not abuse!");
152   assert(UseCompressedClassPointers, "must be");
153   _metadata._compressed_klass = nk;
154 }
155 #endif
156 
157 void* oopDesc::load_klass_raw(oop obj) {
158   if (UseCompressedClassPointers) {
159     narrowKlass narrow_klass = obj->_metadata._compressed_klass;
160     if (narrow_klass == 0) return NULL;
161     return (void*)CompressedKlassPointers::decode_raw(narrow_klass);
162   } else {
< prev index next >