< prev index next >

src/hotspot/share/gc/shared/collectedHeap.cpp

Print this page
@@ -226,11 +226,13 @@
  
    if (!is_in(object)) {
      return false;
    }
  
-   if (!Metaspace::contains(object->klass_raw())) {
+   // With compact headers, we can't safely access the class, due
+   // to possibly forwarded objects.
+   if (!UseCompactObjectHeaders && !Metaspace::contains(object->klass_raw())) {
      return false;
    }
  
    return true;
  }

@@ -398,27 +400,34 @@
      _perf_gc_cause->set_value(GCCause::to_string(v));
    }
    _gc_cause = v;
  }
  
+ // Returns the header size in words aligned to the requirements of the
+ // array object type.
+ static int int_array_header_size() {
+   size_t typesize_in_bytes = arrayOopDesc::header_size_in_bytes();
+   return (int)align_up(typesize_in_bytes, HeapWordSize)/HeapWordSize;
+ }
+ 
  size_t CollectedHeap::max_tlab_size() const {
    // TLABs can't be bigger than we can fill with a int[Integer.MAX_VALUE].
    // This restriction could be removed by enabling filling with multiple arrays.
    // If we compute that the reasonable way as
    //    header_size + ((sizeof(jint) * max_jint) / HeapWordSize)
    // we'll overflow on the multiply, so we do the divide first.
    // We actually lose a little by dividing first,
    // but that just makes the TLAB  somewhat smaller than the biggest array,
    // which is fine, since we'll be able to fill that.
-   size_t max_int_size = typeArrayOopDesc::header_size(T_INT) +
+   size_t max_int_size = int_array_header_size() +
                sizeof(jint) *
                ((juint) max_jint / (size_t) HeapWordSize);
    return align_down(max_int_size, MinObjAlignment);
  }
  
  size_t CollectedHeap::filler_array_hdr_size() {
-   return align_object_offset(arrayOopDesc::header_size(T_INT)); // align to Long
+   return align_object_offset(int_array_header_size()); // align to Long
  }
  
  size_t CollectedHeap::filler_array_min_size() {
    return align_object_size(filler_array_hdr_size()); // align to MinObjAlignment
  }
< prev index next >