8220592: ZGC: Move destruction of detached ZPages into ZPageAllocator
Reviewed-by: stefank, eosterlund
--- a/src/hotspot/share/gc/z/zHeap.cpp Mon Mar 18 11:50:39 2019 +0100
+++ b/src/hotspot/share/gc/z/zHeap.cpp Mon Mar 18 11:50:40 2019 +0100
@@ -404,17 +404,6 @@
_reference_processor.enqueue_references();
}
-void ZHeap::destroy_detached_pages() {
- ZList<ZPage> list;
-
- _page_allocator.flush_detached_pages(&list);
-
- for (ZPage* page = list.remove_first(); page != NULL; page = list.remove_first()) {
- // Delete the page
- _page_allocator.destroy_page(page);
- }
-}
-
void ZHeap::select_relocation_set() {
// Register relocatable pages with selector
ZRelocationSetSelector selector;
@@ -464,6 +453,10 @@
_relocation_set.reset();
}
+void ZHeap::destroy_detached_pages() {
+ _page_allocator.destroy_detached_pages();
+}
+
void ZHeap::relocate_start() {
assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint");
--- a/src/hotspot/share/gc/z/zPageAllocator.cpp Mon Mar 18 11:50:39 2019 +0100
+++ b/src/hotspot/share/gc/z/zPageAllocator.cpp Mon Mar 18 11:50:40 2019 +0100
@@ -250,10 +250,19 @@
_detached.insert_last(page);
}
-void ZPageAllocator::destroy_page(ZPage* page) {
- assert(page->is_detached(), "Invalid page state");
+void ZPageAllocator::destroy_detached_pages() {
+ ZList<ZPage> list;
- delete page;
+ // Get and reset list of detached pages
+ {
+ ZLocker<ZLock> locker(&_lock);
+ list.transfer(&_detached);
+ }
+
+ // Destroy pages
+ for (ZPage* page = list.remove_first(); page != NULL; page = list.remove_first()) {
+ delete page;
+ }
}
void ZPageAllocator::map_page(ZPage* page) {
@@ -271,11 +280,6 @@
pmem.clear();
}
-void ZPageAllocator::flush_detached_pages(ZList<ZPage>* list) {
- ZLocker<ZLock> locker(&_lock);
- list->transfer(&_detached);
-}
-
void ZPageAllocator::flush_cache(size_t size) {
ZList<ZPage> list;
--- a/src/hotspot/share/gc/z/zPageAllocator.hpp Mon Mar 18 11:50:39 2019 +0100
+++ b/src/hotspot/share/gc/z/zPageAllocator.hpp Mon Mar 18 11:50:40 2019 +0100
@@ -97,13 +97,11 @@
ZPage* alloc_page(uint8_t type, size_t size, ZAllocationFlags flags);
void free_page(ZPage* page, bool reclaimed);
- void destroy_page(ZPage* page);
+ void destroy_detached_pages();
void map_page(ZPage* page);
void unmap_all_pages();
- void flush_detached_pages(ZList<ZPage>* list);
-
bool is_alloc_stalled() const;
void check_out_of_memory();
};