1.1 --- a/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.cpp Tue Feb 04 17:38:01 2020 +0800 1.2 +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.cpp Tue Feb 04 18:13:14 2020 +0800 1.3 @@ -161,6 +161,8 @@ 1.4 } 1.5 _dictionary->set_par_lock(&_parDictionaryAllocLock); 1.6 } 1.7 + 1.8 + _used_stable = 0; 1.9 } 1.10 1.11 // Like CompactibleSpace forward() but always calls cross_threshold() to 1.12 @@ -377,6 +379,14 @@ 1.13 return capacity() - free(); 1.14 } 1.15 1.16 +size_t CompactibleFreeListSpace::used_stable() const { 1.17 + return _used_stable; 1.18 +} 1.19 + 1.20 +void CompactibleFreeListSpace::recalculate_used_stable() { 1.21 + _used_stable = used(); 1.22 +} 1.23 + 1.24 size_t CompactibleFreeListSpace::free() const { 1.25 // "MT-safe, but not MT-precise"(TM), if you will: i.e. 1.26 // if you do this while the structures are in flux you 1.27 @@ -1218,6 +1228,13 @@ 1.28 debug_only(fc->mangleAllocated(size)); 1.29 } 1.30 1.31 + // During GC we do not need to recalculate the stable used value for 1.32 + // every allocation in old gen. It is done once at the end of GC instead 1.33 + // for performance reasons. 1.34 + if (!Universe::heap()->is_gc_active()) { 1.35 + recalculate_used_stable(); 1.36 + } 1.37 + 1.38 return res; 1.39 } 1.40