Skip to content

Commit f6fd2ed

Browse files
committed
Move ZToFreeEntry outside free_pages
1 parent 61d32a3 commit f6fd2ed

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/hotspot/share/gc/z/zPageAllocator.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ bool ZPageAllocator::claim_physical(ZPageAllocation* allocation, ZNUMALocal& sta
634634

635635
// Try to claim physical memory
636636
if (!claim_mapped_or_increase_capacity(state, size, mappings)) {
637-
// Failed to claim enough memory or increase capacity (on current NUMA node)
637+
// Failed to claim enough memory or increase capacity
638638
return false;
639639
}
640640

@@ -917,11 +917,10 @@ void ZPageAllocator::satisfy_stalled() {
917917
}
918918

919919
void ZPageAllocator::free_page(ZPage* page, bool allow_defragment) {
920-
const ZGenerationId generation_id = page->generation_id();
921-
922920
// Extract memory and destroy page
923921
ZVirtualMemory vmem = page->virtual_memory();
924-
ZPageType page_type = page->type();
922+
const ZGenerationId generation_id = page->generation_id();
923+
const ZPageType page_type = page->type();
925924
safe_destroy_page(page);
926925

927926
// Perhaps remap mapping
@@ -943,17 +942,21 @@ void ZPageAllocator::free_page(ZPage* page, bool allow_defragment) {
943942
satisfy_stalled();
944943
}
945944

945+
struct ZToFreeEntry {
946+
ZVirtualMemory vmem;
947+
ZGenerationId generation_id;
948+
};
949+
946950
void ZPageAllocator::free_pages(const ZArray<ZPage*>* pages) {
947-
struct ToCacheEntry { ZVirtualMemory vmem; ZGenerationId generation_id; };
948-
ZArray<ToCacheEntry> to_cache;
951+
ZArray<ZToFreeEntry> to_cache;
949952

950953
// Prepare memory from pages to be cached before taking the lock
951954
ZArrayIterator<ZPage*> pages_iter(pages);
952955
for (ZPage* page; pages_iter.next(&page);) {
953956
// Extract mapped memory, store generation id and destroy page
954957
ZVirtualMemory vmem = page->virtual_memory();
955-
ZGenerationId generation_id = page->generation_id();
956-
ZPageType page_type = page->type();
958+
const ZGenerationId generation_id = page->generation_id();
959+
const ZPageType page_type = page->type();
957960

958961
safe_destroy_page(page);
959962

@@ -969,8 +972,8 @@ void ZPageAllocator::free_pages(const ZArray<ZPage*>* pages) {
969972
ZLocker<ZLock> locker(&_lock);
970973

971974
// Insert mappings to the cache
972-
ZArrayIterator<ToCacheEntry> iter(&to_cache);
973-
for (ToCacheEntry entry; iter.next(&entry);) {
975+
ZArrayIterator<ZToFreeEntry> iter(&to_cache);
976+
for (ZToFreeEntry entry; iter.next(&entry);) {
974977
ZNUMALocal& state = state_from_vmem(entry.vmem);
975978

976979
// Update used statistics and cache memory

0 commit comments

Comments
 (0)