diff -r 9a7135d0a309 -r 7386b3a385ac src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.cpp --- a/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.cpp Tue Dec 17 05:07:06 2019 +0000 +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.cpp Tue Dec 17 05:26:57 2019 +0000 @@ -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; }