--- old/src/hotspot/share/gc/g1/g1CollectedHeap.hpp 2020-01-03 17:56:50.193807800 +0800 +++ new/src/hotspot/share/gc/g1/g1CollectedHeap.hpp 2020-01-03 17:56:50.195807871 +0800 @@ -30,6 +30,7 @@ #include "gc/g1/g1CardTable.hpp" #include "gc/g1/g1CollectionSet.hpp" #include "gc/g1/g1CollectorState.hpp" +#include "gc/g1/g1ConcurrentHeapResize.hpp" #include "gc/g1/g1ConcurrentMark.hpp" #include "gc/g1/g1EdenRegions.hpp" #include "gc/g1/g1EvacFailure.hpp" @@ -80,6 +81,8 @@ class G1HotCardCache; class G1RemSet; class G1YoungRemSetSamplingThread; +class G1ConcurrentHeapResize; +class G1ConcurrentHeapResizeThread; class G1ConcurrentMark; class G1ConcurrentMarkThread; class G1ConcurrentRefine; @@ -235,6 +238,10 @@ // start of each GC. bool _expand_heap_after_alloc_failure; + // The previous value of SoftMaxHeapSize to indicate if a new value is assigned + // The default value is MaxHeapSize + size_t _prev_soft_max_heap_size; + // Helper for monitoring and management support. G1MonitoringSupport* _g1mm; @@ -511,11 +518,14 @@ void abort_concurrent_cycle(); void verify_before_full_collection(bool explicit_gc); void prepare_heap_for_full_collection(); - void prepare_heap_for_mutators(); + void prepare_heap_for_mutators(bool explicit_gc); void abort_refinement(); void verify_after_full_collection(); void print_heap_after_full_collection(G1HeapTransition* heap_transition); + // Check if SoftMaxHeapSize has changed in runtime + bool check_soft_max_heap_size_changed(); + // Helper method for satisfy_failed_allocation() HeapWord* satisfy_failed_allocation_helper(size_t word_size, bool do_gc, @@ -565,7 +575,7 @@ return _g1mm; } - void resize_heap_if_necessary(); + void resize_heap_if_necessary(bool limit_within_soft_max_heap_size); G1NUMA* numa() const { return _numa; } @@ -781,7 +791,10 @@ G1RedirtyCardsQueueSet* rdcqs, G1ParScanThreadStateSet* pss); + void adjust_heap_after_young_collection(); void expand_heap_after_young_collection(); + void shrink_heap_after_young_collection(); + // Update object copying statistics. void record_obj_copy_mem_stats(); @@ -806,6 +819,10 @@ // The concurrent refiner. G1ConcurrentRefine* _cr; + // The concurrent heap resizer (and the thread it runs in.) + G1ConcurrentHeapResize* _concurrent_heap_resize; + G1ConcurrentHeapResizeThread* _concurrent_heap_resize_thread; + // The parallel task queues RefToScanQueueSet *_task_queues; @@ -1078,7 +1095,7 @@ inline void archive_set_add(HeapRegion* hr); - size_t non_young_capacity_bytes() { + size_t non_young_capacity_bytes() const { return (old_regions_count() + _archive_set.length() + humongous_regions_count()) * HeapRegion::GrainBytes; } @@ -1358,6 +1375,9 @@ G1ConcurrentRefine* concurrent_refine() const { return _cr; } + // Concurrent heap resizing + G1ConcurrentHeapResize* concurrent_heap_resize() const { return _concurrent_heap_resize; } + // Optimized nmethod scanning support routines // Register the given nmethod with the G1 heap.