< prev index next >

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

Print this page

 60   Atomic::store(&_mark, m);
 61 }
 62 
 63 void oopDesc::set_mark(HeapWord* mem, markWord m) {
 64   *(markWord*)(((char*)mem) + mark_offset_in_bytes()) = m;
 65 }
 66 
 67 void oopDesc::release_set_mark(markWord m) {
 68   Atomic::release_store(&_mark, m);
 69 }
 70 
 71 markWord oopDesc::cas_set_mark(markWord new_mark, markWord old_mark) {
 72   return Atomic::cmpxchg(&_mark, old_mark, new_mark);
 73 }
 74 
 75 markWord oopDesc::cas_set_mark(markWord new_mark, markWord old_mark, atomic_memory_order order) {
 76   return Atomic::cmpxchg(&_mark, old_mark, new_mark, order);
 77 }
 78 
 79 void oopDesc::init_mark() {
 80   set_mark(markWord::prototype());
 81 }
 82 
 83 Klass* oopDesc::klass() const {
 84   if (UseCompressedClassPointers) {
 85     return CompressedKlassPointers::decode_not_null(_metadata._compressed_klass);
 86   } else {
 87     return _metadata._klass;
 88   }
 89 }
 90 
 91 Klass* oopDesc::klass_or_null() const {
 92   if (UseCompressedClassPointers) {
 93     return CompressedKlassPointers::decode(_metadata._compressed_klass);
 94   } else {
 95     return _metadata._klass;
 96   }
 97 }
 98 
 99 Klass* oopDesc::klass_or_null_acquire() const {
100   if (UseCompressedClassPointers) {

191       // a concurrent change.
192       assert((s == klass->oop_size(this)) ||
193              (Universe::is_gc_active() && is_objArray() && is_forwarded() && (get_UseParallelGC() || get_UseG1GC())),
194              "wrong array object size");
195     } else {
196       // Must be zero, so bite the bullet and take the virtual call.
197       s = klass->oop_size(this);
198     }
199   }
200 
201   assert(s > 0, "Oop size must be greater than zero, not %d", s);
202   assert(is_object_aligned(s), "Oop size is not properly aligned: %d", s);
203   return s;
204 }
205 
206 bool oopDesc::is_instance()  const { return klass()->is_instance_klass();  }
207 bool oopDesc::is_array()     const { return klass()->is_array_klass();     }
208 bool oopDesc::is_objArray()  const { return klass()->is_objArray_klass();  }
209 bool oopDesc::is_typeArray() const { return klass()->is_typeArray_klass(); }
210 















211 void*    oopDesc::field_addr(int offset)     const { return reinterpret_cast<void*>(cast_from_oop<intptr_t>(as_oop()) + offset); }
212 
213 template <class T>
214 T*       oopDesc::obj_field_addr(int offset) const { return (T*) field_addr(offset); }
215 
216 template <typename T>
217 size_t   oopDesc::field_offset(T* p) const { return pointer_delta((void*)p, (void*)this, 1); }
218 
219 template <DecoratorSet decorators>
220 inline oop  oopDesc::obj_field_access(int offset) const             { return HeapAccess<decorators>::oop_load_at(as_oop(), offset); }
221 inline oop  oopDesc::obj_field(int offset) const                    { return HeapAccess<>::oop_load_at(as_oop(), offset);  }
222 
223 inline void oopDesc::obj_field_put(int offset, oop value)           { HeapAccess<>::oop_store_at(as_oop(), offset, value); }
224 
225 inline jbyte oopDesc::byte_field(int offset) const                  { return HeapAccess<>::load_at(as_oop(), offset);  }
226 inline void  oopDesc::byte_field_put(int offset, jbyte value)       { HeapAccess<>::store_at(as_oop(), offset, value); }
227 
228 inline jchar oopDesc::char_field(int offset) const                  { return HeapAccess<>::load_at(as_oop(), offset);  }
229 inline void  oopDesc::char_field_put(int offset, jchar value)       { HeapAccess<>::store_at(as_oop(), offset, value); }
230 

 60   Atomic::store(&_mark, m);
 61 }
 62 
 63 void oopDesc::set_mark(HeapWord* mem, markWord m) {
 64   *(markWord*)(((char*)mem) + mark_offset_in_bytes()) = m;
 65 }
 66 
 67 void oopDesc::release_set_mark(markWord m) {
 68   Atomic::release_store(&_mark, m);
 69 }
 70 
 71 markWord oopDesc::cas_set_mark(markWord new_mark, markWord old_mark) {
 72   return Atomic::cmpxchg(&_mark, old_mark, new_mark);
 73 }
 74 
 75 markWord oopDesc::cas_set_mark(markWord new_mark, markWord old_mark, atomic_memory_order order) {
 76   return Atomic::cmpxchg(&_mark, old_mark, new_mark, order);
 77 }
 78 
 79 void oopDesc::init_mark() {
 80   set_mark(Klass::default_prototype_header(klass()));
 81 }
 82 
 83 Klass* oopDesc::klass() const {
 84   if (UseCompressedClassPointers) {
 85     return CompressedKlassPointers::decode_not_null(_metadata._compressed_klass);
 86   } else {
 87     return _metadata._klass;
 88   }
 89 }
 90 
 91 Klass* oopDesc::klass_or_null() const {
 92   if (UseCompressedClassPointers) {
 93     return CompressedKlassPointers::decode(_metadata._compressed_klass);
 94   } else {
 95     return _metadata._klass;
 96   }
 97 }
 98 
 99 Klass* oopDesc::klass_or_null_acquire() const {
100   if (UseCompressedClassPointers) {

191       // a concurrent change.
192       assert((s == klass->oop_size(this)) ||
193              (Universe::is_gc_active() && is_objArray() && is_forwarded() && (get_UseParallelGC() || get_UseG1GC())),
194              "wrong array object size");
195     } else {
196       // Must be zero, so bite the bullet and take the virtual call.
197       s = klass->oop_size(this);
198     }
199   }
200 
201   assert(s > 0, "Oop size must be greater than zero, not %d", s);
202   assert(is_object_aligned(s), "Oop size is not properly aligned: %d", s);
203   return s;
204 }
205 
206 bool oopDesc::is_instance()  const { return klass()->is_instance_klass();  }
207 bool oopDesc::is_array()     const { return klass()->is_array_klass();     }
208 bool oopDesc::is_objArray()  const { return klass()->is_objArray_klass();  }
209 bool oopDesc::is_typeArray() const { return klass()->is_typeArray_klass(); }
210 
211 bool oopDesc::is_inline_type() const { return mark().is_inline_type(); }
212 #ifdef _LP64
213 bool oopDesc::is_flatArray() const {
214   markWord mrk = mark();
215   return (mrk.is_unlocked()) ? mrk.is_flat_array() : klass()->is_flatArray_klass();
216 }
217 bool oopDesc::is_null_free_array() const {
218   markWord mrk = mark();
219   return (mrk.is_unlocked()) ? mrk.is_null_free_array() : klass()->is_null_free_array_klass();
220 }
221 #else
222 bool oopDesc::is_flatArray()       const { return klass()->is_flatArray_klass(); }
223 bool oopDesc::is_null_free_array() const { return klass()->is_null_free_array_klass(); }
224 #endif
225 
226 void*    oopDesc::field_addr(int offset)     const { return reinterpret_cast<void*>(cast_from_oop<intptr_t>(as_oop()) + offset); }
227 
228 template <class T>
229 T*       oopDesc::obj_field_addr(int offset) const { return (T*) field_addr(offset); }
230 
231 template <typename T>
232 size_t   oopDesc::field_offset(T* p) const { return pointer_delta((void*)p, (void*)this, 1); }
233 
234 template <DecoratorSet decorators>
235 inline oop  oopDesc::obj_field_access(int offset) const             { return HeapAccess<decorators>::oop_load_at(as_oop(), offset); }
236 inline oop  oopDesc::obj_field(int offset) const                    { return HeapAccess<>::oop_load_at(as_oop(), offset);  }
237 
238 inline void oopDesc::obj_field_put(int offset, oop value)           { HeapAccess<>::oop_store_at(as_oop(), offset, value); }
239 
240 inline jbyte oopDesc::byte_field(int offset) const                  { return HeapAccess<>::load_at(as_oop(), offset);  }
241 inline void  oopDesc::byte_field_put(int offset, jbyte value)       { HeapAccess<>::store_at(as_oop(), offset, value); }
242 
243 inline jchar oopDesc::char_field(int offset) const                  { return HeapAccess<>::load_at(as_oop(), offset);  }
244 inline void  oopDesc::char_field_put(int offset, jchar value)       { HeapAccess<>::store_at(as_oop(), offset, value); }
245 
< prev index next >