src/hotspot/share/gc/cms/compactibleFreeListSpace.cpp
Print this page
@@ -370,10 +370,12 @@
DEBUG_ONLY(
_indexedFreeList[i].set_protecting_lock(_indexedFreeListParLocks[i]);
)
}
_dictionary->set_par_lock(&_parDictionaryAllocLock);
+
+ _used_stable = 0;
}
// Like CompactibleSpace forward() but always calls cross_threshold() to
// update the block offset table. Removed initialize_threshold call because
// CFLS does not use a block offset array for contiguous spaces.
@@ -575,10 +577,18 @@
size_t CompactibleFreeListSpace::used() const {
return capacity() - free();
}
+size_t CompactibleFreeListSpace::used_stable() const {
+ return _used_stable;
+}
+
+void CompactibleFreeListSpace::recalculate_used_stable() {
+ _used_stable = used();
+}
+
size_t CompactibleFreeListSpace::free() const {
// "MT-safe, but not MT-precise"(TM), if you will: i.e.
// if you do this while the structures are in flux you
// may get an approximate answer only; for instance
// because there is concurrent allocation either
@@ -1372,10 +1382,17 @@
_bt.verify_not_unallocated(res, size);
// mangle a just allocated object with a distinct pattern.
debug_only(fc->mangleAllocated(size));
}
+ // During GC we do not need to recalculate the stable used value for
+ // every allocation in old gen. It is done once at the end of GC instead
+ // for performance reasons.
+ if (!CMSHeap::heap()->is_gc_active()) {
+ recalculate_used_stable();
+ }
+
return res;
}
HeapWord* CompactibleFreeListSpace::allocate_adaptive_freelists(size_t size) {
assert_lock_strong(freelistLock());