< 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) {

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















203 template<typename T>
204 T*       oopDesc::field_addr(int offset)     const { return reinterpret_cast<T*>(cast_from_oop<intptr_t>(as_oop()) + offset); }
205 
206 template <typename T>
207 size_t   oopDesc::field_offset(T* p) const { return pointer_delta((void*)p, (void*)this, 1); }
208 
209 template <DecoratorSet decorators>
210 inline oop  oopDesc::obj_field_access(int offset) const             { return HeapAccess<decorators>::oop_load_at(as_oop(), offset); }
211 inline oop  oopDesc::obj_field(int offset) const                    { return HeapAccess<>::oop_load_at(as_oop(), offset);  }
212 
213 inline void oopDesc::obj_field_put(int offset, oop value)           { HeapAccess<>::oop_store_at(as_oop(), offset, value); }
214 
215 inline jbyte oopDesc::byte_field(int offset) const                  { return *field_addr<jbyte>(offset);  }
216 inline void  oopDesc::byte_field_put(int offset, jbyte value)       { *field_addr<jbyte>(offset) = value; }
217 
218 inline jchar oopDesc::char_field(int offset) const                  { return *field_addr<jchar>(offset);  }
219 inline void  oopDesc::char_field_put(int offset, jchar value)       { *field_addr<jchar>(offset) = value; }
220 
221 inline jboolean oopDesc::bool_field(int offset) const               { return *field_addr<jboolean>(offset); }
222 inline void     oopDesc::bool_field_put(int offset, jboolean value) { *field_addr<jboolean>(offset) = jboolean(value & 1); }

 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) {

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