< prev index next >

src/hotspot/share/oops/oop.cpp

Print this page

139 VerifyOopClosure VerifyOopClosure::verify_oop;
140 
141 template <class T> void VerifyOopClosure::do_oop_work(T* p) {
142   oop obj = RawAccess<>::oop_load(p);
143   guarantee(oopDesc::is_oop_or_null(obj), "invalid oop: " PTR_FORMAT, p2i(obj));
144 }
145 
146 void VerifyOopClosure::do_oop(oop* p)       { VerifyOopClosure::do_oop_work(p); }
147 void VerifyOopClosure::do_oop(narrowOop* p) { VerifyOopClosure::do_oop_work(p); }
148 
149 // type test operations that doesn't require inclusion of oop.inline.hpp.
150 bool oopDesc::is_instance_noinline()    const { return is_instance();    }
151 bool oopDesc::is_instanceRef_noinline() const { return is_instanceRef(); }
152 bool oopDesc::is_stackChunk_noinline()  const { return is_stackChunk();  }
153 bool oopDesc::is_array_noinline()       const { return is_array();       }
154 bool oopDesc::is_objArray_noinline()    const { return is_objArray();    }
155 bool oopDesc::is_typeArray_noinline()   const { return is_typeArray();   }
156 
157 bool oopDesc::has_klass_gap() {
158   // Only has a klass gap when compressed class pointers are used.
159   return UseCompressedClassPointers;

160 }
161 
162 #if INCLUDE_CDS_JAVA_HEAP
163 void oopDesc::set_narrow_klass(narrowKlass nk) {
164   assert(DumpSharedSpaces, "Used by CDS only. Do not abuse!");
165   assert(UseCompressedClassPointers, "must be");
166   _metadata._compressed_klass = nk;
167 }
168 #endif
169 
170 void* oopDesc::load_klass_raw(oop obj) {
171   if (UseCompressedClassPointers) {


172     narrowKlass narrow_klass = obj->_metadata._compressed_klass;
173     if (narrow_klass == 0) return nullptr;
174     return (void*)CompressedKlassPointers::decode_raw(narrow_klass);
175   } else {
176     return obj->_metadata._klass;
177   }
178 }
179 
180 void* oopDesc::load_oop_raw(oop obj, int offset) {
181   uintptr_t addr = (uintptr_t)(void*)obj + (uint)offset;
182   if (UseCompressedOops) {
183     narrowOop narrow_oop = *(narrowOop*)addr;
184     if (CompressedOops::is_null(narrow_oop)) return nullptr;
185     return (void*)CompressedOops::decode_raw(narrow_oop);
186   } else {
187     return *(void**)addr;
188   }
189 }
190 
191 oop oopDesc::obj_field_acquire(int offset) const                      { return HeapAccess<MO_ACQUIRE>::oop_load_at(as_oop(), offset); }

139 VerifyOopClosure VerifyOopClosure::verify_oop;
140 
141 template <class T> void VerifyOopClosure::do_oop_work(T* p) {
142   oop obj = RawAccess<>::oop_load(p);
143   guarantee(oopDesc::is_oop_or_null(obj), "invalid oop: " PTR_FORMAT, p2i(obj));
144 }
145 
146 void VerifyOopClosure::do_oop(oop* p)       { VerifyOopClosure::do_oop_work(p); }
147 void VerifyOopClosure::do_oop(narrowOop* p) { VerifyOopClosure::do_oop_work(p); }
148 
149 // type test operations that doesn't require inclusion of oop.inline.hpp.
150 bool oopDesc::is_instance_noinline()    const { return is_instance();    }
151 bool oopDesc::is_instanceRef_noinline() const { return is_instanceRef(); }
152 bool oopDesc::is_stackChunk_noinline()  const { return is_stackChunk();  }
153 bool oopDesc::is_array_noinline()       const { return is_array();       }
154 bool oopDesc::is_objArray_noinline()    const { return is_objArray();    }
155 bool oopDesc::is_typeArray_noinline()   const { return is_typeArray();   }
156 
157 bool oopDesc::has_klass_gap() {
158   // Only has a klass gap when compressed class pointers are used.
159   // Except when using compact headers.
160   return UseCompressedClassPointers && !UseCompactObjectHeaders;
161 }
162 
163 #if INCLUDE_CDS_JAVA_HEAP
164 void oopDesc::set_narrow_klass(narrowKlass nk) {
165   assert(DumpSharedSpaces, "Used by CDS only. Do not abuse!");
166   assert(UseCompressedClassPointers, "must be");
167   _metadata._compressed_klass = nk;
168 }
169 #endif
170 
171 void* oopDesc::load_klass_raw(oop obj) {
172   if (UseCompactObjectHeaders) {
173     return obj->klass();
174   } else if (UseCompressedClassPointers) {
175     narrowKlass narrow_klass = obj->_metadata._compressed_klass;
176     if (narrow_klass == 0) return nullptr;
177     return (void*)CompressedKlassPointers::decode_raw(narrow_klass);
178   } else {
179     return obj->_metadata._klass;
180   }
181 }
182 
183 void* oopDesc::load_oop_raw(oop obj, int offset) {
184   uintptr_t addr = (uintptr_t)(void*)obj + (uint)offset;
185   if (UseCompressedOops) {
186     narrowOop narrow_oop = *(narrowOop*)addr;
187     if (CompressedOops::is_null(narrow_oop)) return nullptr;
188     return (void*)CompressedOops::decode_raw(narrow_oop);
189   } else {
190     return *(void**)addr;
191   }
192 }
193 
194 oop oopDesc::obj_field_acquire(int offset) const                      { return HeapAccess<MO_ACQUIRE>::oop_load_at(as_oop(), offset); }
< prev index next >