< prev index next >
src/hotspot/share/gc/shared/collectedHeap.cpp
Print this page
@@ -26,10 +26,11 @@
#include "classfile/systemDictionary.hpp"
#include "gc/shared/allocTracer.hpp"
#include "gc/shared/barrierSet.hpp"
#include "gc/shared/collectedHeap.hpp"
#include "gc/shared/collectedHeap.inline.hpp"
+#include "gc/shared/fill.hpp"
#include "gc/shared/gcLocker.inline.hpp"
#include "gc/shared/gcHeapSummary.hpp"
#include "gc/shared/gcTrace.hpp"
#include "gc/shared/gcTraceTime.inline.hpp"
#include "gc/shared/gcWhen.hpp"
@@ -53,12 +54,10 @@
#ifdef ASSERT
int CollectedHeap::_fire_out_of_memory_count = 0;
#endif
-size_t CollectedHeap::_filler_array_max_size = 0;
-
template <>
void EventLogBase<GCMessage>::print(outputStream* st, GCMessage& m) {
st->print_cr("GC heap %s", m.is_before ? "before" : "after");
st->print_raw(m);
}
@@ -188,24 +187,18 @@
}
return true;
}
-// Memory state functions.
-
-
CollectedHeap::CollectedHeap() :
_is_gc_active(false),
_total_collections(0),
_total_full_collections(0),
_gc_cause(GCCause::_no_gc),
_gc_lastcause(GCCause::_no_gc)
{
- const size_t max_len = size_t(arrayOopDesc::max_array_length(T_INT));
- const size_t elements_per_word = HeapWordSize / sizeof(jint);
- _filler_array_max_size = align_object_size(filler_array_hdr_size() +
- max_len / elements_per_word);
+ Fill::initialize();
NOT_PRODUCT(_promotion_failure_alot_count = 0;)
NOT_PRODUCT(_promotion_failure_alot_gc_number = 0;)
if (UsePerfData) {
@@ -357,105 +350,10 @@
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
-}
-
-size_t CollectedHeap::filler_array_min_size() {
- return align_object_size(filler_array_hdr_size()); // align to MinObjAlignment
-}
-
-#ifdef ASSERT
-void CollectedHeap::fill_args_check(HeapWord* start, size_t words)
-{
- assert(words >= min_fill_size(), "too small to fill");
- assert(is_object_aligned(words), "unaligned size");
- assert(Universe::heap()->is_in_reserved(start), "not in heap");
- assert(Universe::heap()->is_in_reserved(start + words - 1), "not in heap");
-}
-
-void CollectedHeap::zap_filler_array(HeapWord* start, size_t words, bool zap)
-{
- if (ZapFillerObjects && zap) {
- Copy::fill_to_words(start + filler_array_hdr_size(),
- words - filler_array_hdr_size(), 0XDEAFBABE);
- }
-}
-#endif // ASSERT
-
-void
-CollectedHeap::fill_with_array(HeapWord* start, size_t words, bool zap)
-{
- assert(words >= filler_array_min_size(), "too small for an array");
- assert(words <= filler_array_max_size(), "too big for a single object");
-
- const size_t payload_size = words - filler_array_hdr_size();
- const size_t len = payload_size * HeapWordSize / sizeof(jint);
- assert((int)len >= 0, "size too large " SIZE_FORMAT " becomes %d", words, (int)len);
-
- ObjArrayAllocator allocator(Universe::intArrayKlassObj(), words, (int)len, /* do_zero */ false);
- allocator.initialize(start);
- DEBUG_ONLY(zap_filler_array(start, words, zap);)
-}
-
-void
-CollectedHeap::fill_with_object_impl(HeapWord* start, size_t words, bool zap)
-{
- assert(words <= filler_array_max_size(), "too big for a single object");
-
- if (words >= filler_array_min_size()) {
- fill_with_array(start, words, zap);
- } else if (words > 0) {
- assert(words == min_fill_size(), "unaligned size");
- ObjAllocator allocator(SystemDictionary::Object_klass(), words);
- allocator.initialize(start);
- }
-}
-
-void CollectedHeap::fill_with_object(HeapWord* start, size_t words, bool zap)
-{
- DEBUG_ONLY(fill_args_check(start, words);)
- HandleMark hm; // Free handles before leaving.
- fill_with_object_impl(start, words, zap);
-}
-
-void CollectedHeap::fill_with_objects(HeapWord* start, size_t words, bool zap)
-{
- DEBUG_ONLY(fill_args_check(start, words);)
- HandleMark hm; // Free handles before leaving.
-
- // Multiple objects may be required depending on the filler array maximum size. Fill
- // the range up to that with objects that are filler_array_max_size sized. The
- // remainder is filled with a single object.
- const size_t min = min_fill_size();
- const size_t max = filler_array_max_size();
- while (words > max) {
- const size_t cur = (words - max) >= min ? max : max - min;
- fill_with_array(start, cur, zap);
- start += cur;
- words -= cur;
- }
-
- fill_with_object_impl(start, words, zap);
-}
-
-void CollectedHeap::fill_with_dummy_object(HeapWord* start, HeapWord* end, bool zap) {
- CollectedHeap::fill_with_object(start, end, zap);
-}
-
-size_t CollectedHeap::min_dummy_object_size() const {
- return oopDesc::header_size();
-}
-
-size_t CollectedHeap::tlab_alloc_reserve() const {
- size_t min_size = min_dummy_object_size();
- return min_size > (size_t)MinObjAlignment ? align_object_size(min_size) : 0;
-}
-
HeapWord* CollectedHeap::allocate_new_tlab(size_t min_size,
size_t requested_size,
size_t* actual_size) {
guarantee(false, "thread-local allocation buffers not supported");
return NULL;
< prev index next >