diff -r c97db0855565 -r 758c07667682 src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.cpp --- a/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.cpp Tue Feb 04 17:38:01 2020 +0800 +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.cpp Tue Feb 04 18:13:14 2020 +0800 @@ -161,6 +161,8 @@ } _dictionary->set_par_lock(&_parDictionaryAllocLock); } + + _used_stable = 0; } // Like CompactibleSpace forward() but always calls cross_threshold() to @@ -377,6 +379,14 @@ 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 @@ -1218,6 +1228,13 @@ 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 (!Universe::heap()->is_gc_active()) { + recalculate_used_stable(); + } + return res; }