diff --git a/src/hotspot/share/gc/z/zHeap.cpp b/src/hotspot/share/gc/z/zHeap.cpp index 21ff7037962..dc5f1e3d21d 100644 --- a/src/hotspot/share/gc/z/zHeap.cpp +++ b/src/hotspot/share/gc/z/zHeap.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -248,8 +248,7 @@ void ZHeap::free_page(ZPage* page) { _page_table.remove(page); if (page->is_old()) { - page->verify_remset_cleared_current(); - page->verify_remset_cleared_previous(); + page->remset_delete(); } // Free page @@ -261,12 +260,10 @@ size_t ZHeap::free_empty_pages(const ZArray* pages) { // Remove page table entries ZArrayIterator iter(pages); for (ZPage* page; iter.next(&page);) { - if (page->is_old()) { - // The remset of pages should be clean when installed into the page - // cache. - page->remset_clear(); - } _page_table.remove(page); + if (page->is_old()) { + page->remset_delete(); + } freed += page->size(); } diff --git a/src/hotspot/share/gc/z/zPage.cpp b/src/hotspot/share/gc/z/zPage.cpp index dc40c5367c1..ff56768e9ad 100644 --- a/src/hotspot/share/gc/z/zPage.cpp +++ b/src/hotspot/share/gc/z/zPage.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -78,27 +78,16 @@ void ZPage::reset_seqnum() { Atomic::store(&_seqnum_other, ZGeneration::generation(_generation_id == ZGenerationId::young ? ZGenerationId::old : ZGenerationId::young)->seqnum()); } -void ZPage::remset_initialize() { - // Remsets should only be initialized once and only for old pages. +void ZPage::remset_alloc() { + // Remsets should only be allocated/initialized once and only for old pages. assert(!_remembered_set.is_initialized(), "Should not be initialized"); assert(is_old(), "Only old pages need a remset"); _remembered_set.initialize(size()); } -void ZPage::remset_initialize_or_verify_cleared() { - assert(is_old(), "Only old pages need a remset"); - - if (_remembered_set.is_initialized()) { - verify_remset_cleared_current(); - verify_remset_cleared_previous(); - } else { - remset_initialize(); - } -} - -void ZPage::remset_clear() { - _remembered_set.clear_all(); +void ZPage::remset_delete() { + _remembered_set.delete_all(); } void ZPage::reset(ZPageAge age) { @@ -123,7 +112,6 @@ void ZPage::reset_top_for_allocation() { void ZPage::reset_type_and_size(ZPageType type) { _type = type; _livemap.resize(object_max_count()); - _remembered_set.resize(size()); } ZPage* ZPage::retype(ZPageType type) { @@ -216,10 +204,6 @@ void ZPage::verify_remset_cleared_previous() const { } } -void ZPage::clear_remset_current() { - _remembered_set.clear_current(); -} - void ZPage::clear_remset_previous() { _remembered_set.clear_previous(); } diff --git a/src/hotspot/share/gc/z/zPage.hpp b/src/hotspot/share/gc/z/zPage.hpp index 42e14f904bc..9b6c155f77d 100644 --- a/src/hotspot/share/gc/z/zPage.hpp +++ b/src/hotspot/share/gc/z/zPage.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -155,9 +155,8 @@ public: void clear_remset_range_non_par_current(uintptr_t l_offset, size_t size); void swap_remset_bitmaps(); - void remset_initialize(); - void remset_initialize_or_verify_cleared(); - void remset_clear(); + void remset_alloc(); + void remset_delete(); ZBitMap::ReverseIterator remset_reverse_iterator_previous(); BitMap::Iterator remset_iterator_limited_current(uintptr_t l_offset, size_t size); @@ -182,7 +181,6 @@ public: void verify_remset_cleared_current() const; void verify_remset_cleared_previous() const; - void clear_remset_current(); void clear_remset_previous(); void* remset_current(); diff --git a/src/hotspot/share/gc/z/zPageAllocator.cpp b/src/hotspot/share/gc/z/zPageAllocator.cpp index f5d8ae6e3d1..01200f76b51 100644 --- a/src/hotspot/share/gc/z/zPageAllocator.cpp +++ b/src/hotspot/share/gc/z/zPageAllocator.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -733,7 +733,7 @@ retry: page->reset_top_for_allocation(); page->reset_livemap(); if (age == ZPageAge::old) { - page->remset_initialize_or_verify_cleared(); + page->remset_alloc(); } // Update allocation statistics. Exclude gc relocations to avoid diff --git a/src/hotspot/share/gc/z/zRelocate.cpp b/src/hotspot/share/gc/z/zRelocate.cpp index 90209e4c622..33304bcefd3 100644 --- a/src/hotspot/share/gc/z/zRelocate.cpp +++ b/src/hotspot/share/gc/z/zRelocate.cpp @@ -848,7 +848,7 @@ private: to_page->reset(to_age); to_page->reset_top_for_allocation(); if (promotion) { - to_page->remset_initialize(); + to_page->remset_alloc(); } // Verify that the inactive remset is clear when resetting the page for @@ -943,35 +943,15 @@ public: return ZGeneration::old()->active_remset_is_current(); } - void clear_remset_before_reuse(ZPage* page, bool in_place) { + void clear_remset_before_in_place_reuse(ZPage* page) { if (_forwarding->from_age() != ZPageAge::old) { // No remset bits return; } - if (in_place) { - // Clear 'previous' remset bits. For in-place relocated pages, the previous - // remset bits are always used, even when active_remset_is_current(). - page->clear_remset_previous(); - - return; - } - - // Normal relocate - - // Clear active remset bits - if (active_remset_is_current()) { - page->clear_remset_current(); - } else { - page->clear_remset_previous(); - } - - // Verify that inactive remset bits are all cleared - if (active_remset_is_current()) { - page->verify_remset_cleared_previous(); - } else { - page->verify_remset_cleared_current(); - } + // Clear 'previous' remset bits. For in-place relocated pages, the previous + // remset bits are always used, even when active_remset_is_current(). + page->clear_remset_previous(); } void finish_in_place_relocation() { @@ -1017,7 +997,7 @@ public: ZPage* const page = _forwarding->detach_page(); // Ensure that previous remset bits are cleared - clear_remset_before_reuse(page, true /* in_place */); + clear_remset_before_in_place_reuse(page); page->log_msg(" (relocate page done in-place)"); @@ -1029,11 +1009,6 @@ public: // Wait for all other threads to call release_page ZPage* const page = _forwarding->detach_page(); - // Ensure that all remset bits are cleared - // Note: cleared after detach_page, when we know that - // the young generation isn't scanning the remset. - clear_remset_before_reuse(page, false /* in_place */); - page->log_msg(" (relocate page done normal)"); // Free page @@ -1292,7 +1267,7 @@ public: new_page->reset(to_age); new_page->reset_livemap(); if (promotion) { - new_page->remset_initialize(); + new_page->remset_alloc(); } if (promotion) { diff --git a/src/hotspot/share/gc/z/zRememberedSet.cpp b/src/hotspot/share/gc/z/zRememberedSet.cpp index ed1dcfaf14d..f605401648d 100644 --- a/src/hotspot/share/gc/z/zRememberedSet.cpp +++ b/src/hotspot/share/gc/z/zRememberedSet.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -55,18 +55,10 @@ void ZRememberedSet::initialize(size_t page_size) { _bitmap[1].initialize(size_in_bits, true /* clear */); } -void ZRememberedSet::resize(size_t page_size) { - // The bitmaps only need to be resized if remset has been - // initialized, and hence the bitmaps have been initialized. - if (is_initialized()) { - const BitMap::idx_t size_in_bits = to_bit_size(page_size); - - // The bitmaps need to be cleared when free, but since this function is - // only used for shrinking the clear argument is correct but not crucial. - assert(size_in_bits <= _bitmap[0].size(), "Only used for shrinking"); - _bitmap[0].resize(size_in_bits, true /* clear */); - _bitmap[1].resize(size_in_bits, true /* clear */); - } +void ZRememberedSet::delete_all() { + assert(is_initialized(), "precondition"); + _bitmap[0].resize(0); + _bitmap[1].resize(0); } bool ZRememberedSet::is_cleared_current() const { @@ -77,15 +69,6 @@ bool ZRememberedSet::is_cleared_previous() const { return previous()->is_empty(); } -void ZRememberedSet::clear_all() { - _bitmap[0].clear_large(); - _bitmap[1].clear_large(); -} - -void ZRememberedSet::clear_current() { - current()->clear_large(); -} - void ZRememberedSet::clear_previous() { previous()->clear_large(); } diff --git a/src/hotspot/share/gc/z/zRememberedSet.hpp b/src/hotspot/share/gc/z/zRememberedSet.hpp index d18c357f0dd..c3c6e8bc313 100644 --- a/src/hotspot/share/gc/z/zRememberedSet.hpp +++ b/src/hotspot/share/gc/z/zRememberedSet.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -114,8 +114,7 @@ public: bool is_initialized() const; void initialize(size_t page_size); - - void resize(size_t page_size); + void delete_all(); bool at_current(uintptr_t offset) const; bool at_previous(uintptr_t offset) const; @@ -133,8 +132,6 @@ public: bool is_cleared_current() const; bool is_cleared_previous() const; - void clear_all(); - void clear_current(); void clear_previous(); void swap_remset_bitmaps();