< prev index next >

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

Print this page
*** 30,15 ***
--- 30,17 ---
  #include "memory/universe.hpp"
  #include "oops/access.inline.hpp"
  #include "oops/arrayKlass.hpp"
  #include "oops/arrayOop.hpp"
  #include "oops/compressedOops.inline.hpp"
+ #include "oops/instanceKlass.hpp"
  #include "oops/markWord.hpp"
  #include "oops/oopsHierarchy.hpp"
  #include "runtime/atomic.hpp"
  #include "runtime/globals.hpp"
  #include "utilities/align.hpp"
+ #include "utilities/copy.hpp"
  #include "utilities/debug.hpp"
  #include "utilities/macros.hpp"
  #include "utilities/globalDefinitions.hpp"
  
  // Implementation of all inlined member functions defined in oop.hpp

*** 88,10 ***
--- 90,18 ---
    }
  }
  
  Klass* oopDesc::klass_or_null() const {
    if (UseCompressedClassPointers) {
+     // narrowKlass v = _metadata._compressed_klass;
+     // if (!CompressedKlassPointers::is_null(v)) {
+     //   Klass* result = CompressedKlassPointers::decode_raw(v);
+     //   if(!check_alignment(result)) {
+     //     tty->print_cr("oop klass unaligned: %p oop: %p",  (void*) result, this);
+     //     return NULL;
+     //   }
+     // }
      return CompressedKlassPointers::decode(_metadata._compressed_klass);
    } else {
      return _metadata._klass;
    }
  }

*** 182,18 ***
        // This code could be simplified, but by keeping array_header_in_bytes
        // in units of bytes and doing it this way we can round up just once,
        // skipping the intermediate round to HeapWordSize.
        s = (int)(align_up(size_in_bytes, MinObjAlignmentInBytes) / HeapWordSize);
  
!       // UseParallelGC and UseG1GC can change the length field
!       // of an "old copy" of an object array in the young gen so it indicates
-       // the grey portion of an already copied array. This will cause the first
-       // disjunct below to fail if the two comparands are computed across such
-       // a concurrent change.
-       assert((s == klass->oop_size(this)) ||
-              (Universe::is_gc_active() && is_objArray() && is_forwarded() && (get_UseParallelGC() || get_UseG1GC())),
-              "wrong array object size");
      } else {
        // Must be zero, so bite the bullet and take the virtual call.
        s = klass->oop_size(this);
      }
    }
--- 192,12 ---
        // This code could be simplified, but by keeping array_header_in_bytes
        // in units of bytes and doing it this way we can round up just once,
        // skipping the intermediate round to HeapWordSize.
        s = (int)(align_up(size_in_bytes, MinObjAlignmentInBytes) / HeapWordSize);
  
! 
!       assert(s == klass->oop_size(this) || size_might_change(), "wrong array object size");
      } else {
        // Must be zero, so bite the bullet and take the virtual call.
        s = klass->oop_size(this);
      }
    }

*** 201,14 ***
--- 205,40 ---
    assert(s > 0, "Oop size must be greater than zero, not %d", s);
    assert(is_object_aligned(s), "Oop size is not properly aligned: %d", s);
    return s;
  }
  
+ int oopDesc::compact_size()  {
+   return compact_size_given_klass(klass());
+ }
+ 
+ int oopDesc::compact_size(int size)  {
+   return compact_size_given_klass(klass(), size);
+ }
+ 
+ int oopDesc::compact_size_given_klass(Klass* klass) {
+   int lh = klass->layout_helper();
+   if (lh > Klass::_lh_neutral_value && Klass::layout_helper_needs_slow_path(lh) && TrimContinuationChunksInGC) {
+     return klass->compact_oop_size(this);
+   }
+   return size_given_klass(klass);
+ }
+ 
+ int oopDesc::compact_size_given_klass(Klass* klass, int size) {
+   int lh = klass->layout_helper();
+   if (lh > Klass::_lh_neutral_value && Klass::layout_helper_needs_slow_path(lh) && TrimContinuationChunksInGC) {
+     return klass->compact_oop_size(this);
+   }
+   assert (size == size_given_klass(klass), "");
+   return size;
+ }
+ 
  bool oopDesc::is_instance()  const { return klass()->is_instance_klass();  }
  bool oopDesc::is_array()     const { return klass()->is_array_klass();     }
  bool oopDesc::is_objArray()  const { return klass()->is_objArray_klass();  }
  bool oopDesc::is_typeArray() const { return klass()->is_typeArray_klass(); }
+ bool oopDesc::is_stackChunk()const { return klass()->is_instance_klass() && InstanceKlass::cast(klass())->is_stack_chunk_instance_klass(); }
  
  template<typename T>
  T*       oopDesc::field_addr(int offset)     const { return reinterpret_cast<T*>(cast_from_oop<intptr_t>(as_oop()) + offset); }
  
  template <typename T>

*** 383,6 ***
--- 413,70 ---
  
  bool oopDesc::mark_must_be_preserved(markWord m) const {
    return m.must_be_preserved(this);
  }
  
+ size_t oopDesc::copy_disjoint(HeapWord* to) { 
+   return copy_disjoint(to, size()); 
+ }
+ 
+ size_t oopDesc::copy_conjoint(HeapWord* to) { 
+   return copy_conjoint(to, size()); 
+ }
+ 
+ size_t oopDesc::copy_disjoint_compact(HeapWord* to) { 
+   return copy_disjoint_compact(to, compact_size()); 
+ }
+ 
+ size_t oopDesc::copy_conjoint_compact(HeapWord* to) { 
+   return copy_conjoint_compact(to, compact_size()); 
+ }
+ 
+ size_t oopDesc::copy_disjoint(HeapWord* to, size_t word_size) {
+   // if (is_stackChunk()) tty->print_cr(">>> copy_disjoint from: %p - %p to: %p - %p (word_size: %zu)", cast_from_oop<HeapWord*>(this), cast_from_oop<HeapWord*>(this) + word_size, to, to + word_size, word_size);
+   assert(word_size == (size_t)size() || size_might_change(), "");
+   int lh = klass()->layout_helper();
+   if (UNLIKELY(lh > Klass::_lh_neutral_value && Klass::layout_helper_needs_slow_path(lh))) {
+     size_t res = klass()->copy_disjoint(this, to, word_size);
+     assert (word_size == res, "");
+     return res;
+   }
+   Copy::aligned_disjoint_words(cast_from_oop<HeapWord*>(this), to, word_size);
+   return word_size;
+ }
+ 
+ size_t oopDesc::copy_disjoint_compact(HeapWord* to, size_t word_size) {
+   assert(word_size == (size_t)compact_size() || size_might_change(), "");
+   int lh = klass()->layout_helper();
+   if (UNLIKELY(lh > Klass::_lh_neutral_value && Klass::layout_helper_needs_slow_path(lh) && TrimContinuationChunksInGC)) {
+     size_t res = klass()->copy_disjoint_compact(this, to);
+     assert (word_size == res, "");
+     return res;
+   }
+   return copy_disjoint(to, word_size);
+ }
+ 
+ size_t oopDesc::copy_conjoint(HeapWord* to, size_t word_size) {
+   // if (is_stackChunk()) tty->print_cr(">>> copy_conjoint from: %p - %p to: %p - %p (word_size: %zu)", cast_from_oop<HeapWord*>(this), cast_from_oop<HeapWord*>(this) + word_size, to, to + word_size, word_size);
+   assert(word_size == (size_t)size() || size_might_change(), "");
+   int lh = klass()->layout_helper();
+   if (UNLIKELY(lh > Klass::_lh_neutral_value && Klass::layout_helper_needs_slow_path(lh))) {
+     size_t res = klass()->copy_conjoint(this, to, word_size);
+     assert (word_size == res, "");
+     return res;
+   }
+   Copy::aligned_conjoint_words(cast_from_oop<HeapWord*>(this), to, word_size);
+   return word_size;
+ }
+ 
+ size_t oopDesc::copy_conjoint_compact(HeapWord* to, size_t word_size) {
+   assert(word_size == (size_t)compact_size() || size_might_change(), "");
+   int lh = klass()->layout_helper();
+   if (UNLIKELY(lh > Klass::_lh_neutral_value && Klass::layout_helper_needs_slow_path(lh) && TrimContinuationChunksInGC)) {
+     size_t res = klass()->copy_conjoint_compact(this, to);
+     assert (word_size == res, "");
+     return res;
+   }
+   return copy_conjoint(to, word_size);
+ }
+ 
  #endif // SHARE_OOPS_OOP_INLINE_HPP
< prev index next >