--- old/src/hotspot/share/gc/g1/heapRegionManager.hpp 2020-01-03 17:56:51.296847449 +0800 +++ new/src/hotspot/share/gc/g1/heapRegionManager.hpp 2020-01-03 17:56:51.299847557 +0800 @@ -82,6 +82,16 @@ // The number of regions committed in the heap. uint _num_committed; + // Each bit in this bitmap indicates that the corresponding region is in concurrent + // resizing + CHeapBitMap _concurrent_resizing_map; + +#ifdef ASSERT + // The number of regions for concurrent resizing which is treated as *committed* but + // not counted in length(). + uint _num_concurrent_resizing; +#endif + // Internal only. The highest heap region +1 we allocated a HeapRegion instance for. uint _allocated_heapregions_length; @@ -117,11 +127,23 @@ G1RegionToSpaceMapper* _prev_bitmap_mapper; G1RegionToSpaceMapper* _next_bitmap_mapper; FreeRegionList _free_list; + FreeRegionList _concurrent_uncommitting_list; void make_regions_available(uint index, uint num_regions = 1, WorkGang* pretouch_gang = NULL); void uncommit_regions(uint index, size_t num_regions = 1); // Allocate a new HeapRegion for the given index. HeapRegion* new_heap_region(uint hrm_index); + + // Set/clear region of concurrent resizing state + void set_region_for_concurrent_resizing(uint index); + void clear_region_for_concurrent_resizing(uint index); + + // Uncommit regions memory in concurrent thread + void concurrent_uncommit_regions_memory(uint start, size_t num_regions); + + // Uncommit regions memory in VM thread while in synchronization + void synchronize_uncommit_regions_memory(uint start, size_t num_regions); + #ifdef ASSERT public: bool is_free(HeapRegion* hr) const; @@ -161,6 +183,12 @@ // Returns whether the given region is available for allocation. bool is_available(uint region) const; + // Returns whether the given region is in concurrent resizing + bool is_in_concurrent_resizing(uint region) const; + + // Return true if neither available nor in concurrent resizing + bool is_unavailable_for_allocation(uint region) const; + // Return the next region (by index) that is part of the same // humongous object that hr is part of. inline HeapRegion* next_region_in_humongous(HeapRegion* hr) const; @@ -203,6 +231,11 @@ return num_free_regions() * HeapRegion::GrainBytes; } + // Return the number of free regions in the heap. + uint num_of_concurrent_resizing_regions() const { + return _concurrent_uncommitting_list.length(); + } + // Return the number of available (uncommitted) regions. uint available() const { return max_length() - length(); } @@ -270,6 +303,15 @@ // Do some sanity checking. void verify_optional() PRODUCT_RETURN; + + // Uncommit regions memory in concurrent thread + void concurrent_uncommit_regions(); + + // Prepare the regions to uncommit concurrently + void prepare_concurrent_uncommit_regions(uint num_regions_to_remove); + + // Synchhronize the regions which are resized concurrentlly in safepoint + void synchronize_concurrent_resizing_regions(); }; // The HeapRegionClaimer is used during parallel iteration over heap regions,