src/hotspot/share/oops/oop.inline.hpp
changeset 59053 ba6c248cae19
parent 58901 2700c409ff10
child 59247 56bf71d64d51
equal deleted inserted replaced
59051:f0312c7d5b37 59053:ba6c248cae19
   177 
   177 
   178 void oopDesc::set_klass_gap(int v) {
   178 void oopDesc::set_klass_gap(int v) {
   179   set_klass_gap((HeapWord*)this, v);
   179   set_klass_gap((HeapWord*)this, v);
   180 }
   180 }
   181 
   181 
   182 void oopDesc::set_klass_to_list_ptr(oop k) {
       
   183   // This is only to be used during GC, for from-space objects, so no
       
   184   // barrier is needed.
       
   185   if (UseCompressedClassPointers) {
       
   186     _metadata._compressed_klass = (narrowKlass)CompressedOops::encode(k);  // may be null (parnew overflow handling)
       
   187   } else {
       
   188     _metadata._klass = (Klass*)(address)k;
       
   189   }
       
   190 }
       
   191 
       
   192 oop oopDesc::list_ptr_from_klass() {
       
   193   // This is only to be used during GC, for from-space objects.
       
   194   if (UseCompressedClassPointers) {
       
   195     return CompressedOops::decode((narrowOop)_metadata._compressed_klass);
       
   196   } else {
       
   197     // Special case for GC
       
   198     return (oop)(address)_metadata._klass;
       
   199   }
       
   200 }
       
   201 
       
   202 bool oopDesc::is_a(Klass* k) const {
   182 bool oopDesc::is_a(Klass* k) const {
   203   return klass()->is_subtype_of(k);
   183   return klass()->is_subtype_of(k);
   204 }
   184 }
   205 
   185 
   206 int oopDesc::size()  {
   186 int oopDesc::size()  {
   242       // This code could be simplified, but by keeping array_header_in_bytes
   222       // This code could be simplified, but by keeping array_header_in_bytes
   243       // in units of bytes and doing it this way we can round up just once,
   223       // in units of bytes and doing it this way we can round up just once,
   244       // skipping the intermediate round to HeapWordSize.
   224       // skipping the intermediate round to HeapWordSize.
   245       s = (int)(align_up(size_in_bytes, MinObjAlignmentInBytes) / HeapWordSize);
   225       s = (int)(align_up(size_in_bytes, MinObjAlignmentInBytes) / HeapWordSize);
   246 
   226 
   247       // ParNew (used by CMS), UseParallelGC and UseG1GC can change the length field
   227       // UseParallelGC and UseG1GC can change the length field
   248       // of an "old copy" of an object array in the young gen so it indicates
   228       // of an "old copy" of an object array in the young gen so it indicates
   249       // the grey portion of an already copied array. This will cause the first
   229       // the grey portion of an already copied array. This will cause the first
   250       // disjunct below to fail if the two comparands are computed across such
   230       // disjunct below to fail if the two comparands are computed across such
   251       // a concurrent change.
   231       // a concurrent change.
   252       // ParNew also runs with promotion labs (which look like int
       
   253       // filler arrays) which are subject to changing their declared size
       
   254       // when finally retiring a PLAB; this also can cause the first disjunct
       
   255       // to fail for another worker thread that is concurrently walking the block
       
   256       // offset table. Both these invariant failures are benign for their
       
   257       // current uses; we relax the assertion checking to cover these two cases below:
       
   258       //     is_objArray() && is_forwarded()   // covers first scenario above
       
   259       //  || is_typeArray()                    // covers second scenario above
       
   260       // If and when UseParallelGC uses the same obj array oop stealing/chunking
       
   261       // technique, we will need to suitably modify the assertion.
       
   262       assert((s == klass->oop_size(this)) ||
   232       assert((s == klass->oop_size(this)) ||
   263              (Universe::heap()->is_gc_active() &&
   233              (Universe::heap()->is_gc_active() && is_objArray() && is_forwarded() && (UseParallelGC || UseG1GC)),
   264               ((is_typeArray() && UseConcMarkSweepGC) ||
       
   265                (is_objArray()  && is_forwarded() && (UseConcMarkSweepGC || UseParallelGC || UseG1GC)))),
       
   266              "wrong array object size");
   234              "wrong array object size");
   267     } else {
   235     } else {
   268       // Must be zero, so bite the bullet and take the virtual call.
   236       // Must be zero, so bite the bullet and take the virtual call.
   269       s = klass->oop_size(this);
   237       s = klass->oop_size(this);
   270     }
   238     }