8367339: Parallel: Remove PSScavenge::should_scavenge

Reviewed-by: tschatzl, fandreuzzi
This commit is contained in:
Albert Mingkun Yang 2025-09-11 11:22:29 +00:00
parent 063f970f0f
commit a2d272a02a
8 changed files with 13 additions and 100 deletions

View File

@ -26,7 +26,6 @@
#include "gc/parallel/parallelScavengeHeap.inline.hpp"
#include "gc/parallel/psCardTable.hpp"
#include "gc/parallel/psPromotionManager.inline.hpp"
#include "gc/parallel/psScavenge.inline.hpp"
#include "gc/parallel/psYoungGen.hpp"
#include "memory/iterator.inline.hpp"
#include "oops/access.inline.hpp"

View File

@ -28,7 +28,7 @@
// No psClosure.hpp
#include "gc/parallel/psPromotionManager.inline.hpp"
#include "gc/parallel/psScavenge.inline.hpp"
#include "gc/parallel/psScavenge.hpp"
#include "memory/iterator.hpp"
#include "oops/access.inline.hpp"
#include "oops/oop.inline.hpp"
@ -39,8 +39,9 @@ public:
virtual void do_oop(narrowOop* p) { ShouldNotReachHere(); }
virtual void do_oop(oop* p) {
if (PSScavenge::should_scavenge(p)) {
oop o = RawAccess<IS_NOT_NULL>::oop_load(p);
oop o = RawAccess<>::oop_load(p);
if (PSScavenge::is_obj_in_young(o)) {
assert(!PSScavenge::is_obj_in_to_space(o), "Revisiting roots?");
assert(o->is_forwarded(), "Objects are already forwarded before weak processing");
oop new_obj = o->forwardee();
if (log_develop_is_enabled(Trace, gc, scavenge)) {
@ -89,12 +90,11 @@ public:
void do_oop(narrowOop* p) { ShouldNotReachHere(); }
void do_oop(oop* p) {
ParallelScavengeHeap* psh = ParallelScavengeHeap::heap();
assert(!psh->is_in_reserved(p), "GC barrier needed");
if (PSScavenge::should_scavenge(p)) {
assert(PSScavenge::should_scavenge(p, true), "revisiting object?");
assert(!ParallelScavengeHeap::heap()->is_in_reserved(p), "GC barrier needed");
oop o = RawAccess<IS_NOT_NULL>::oop_load(p);
oop o = RawAccess<>::oop_load(p);
if (PSScavenge::is_obj_in_young(o)) {
assert(!PSScavenge::is_obj_in_to_space(o), "Revisiting roots?");
oop new_obj = _pm->copy_to_survivor_space</*promote_immediately=*/false>(o);
RawAccess<IS_NOT_NULL>::oop_store(p, new_obj);

View File

@ -27,7 +27,7 @@
#include "gc/parallel/parallelScavengeHeap.hpp"
#include "gc/parallel/psOldGen.hpp"
#include "gc/parallel/psPromotionManager.inline.hpp"
#include "gc/parallel/psScavenge.inline.hpp"
#include "gc/parallel/psScavenge.hpp"
#include "gc/shared/continuationGCSupport.inline.hpp"
#include "gc/shared/gcTrace.hpp"
#include "gc/shared/partialArraySplitter.inline.hpp"
@ -86,15 +86,6 @@ void PSPromotionManager::initialize() {
}
}
// Helper functions to get around the circular dependency between
// psScavenge.inline.hpp and psPromotionManager.inline.hpp.
bool PSPromotionManager::should_scavenge(oop* p, bool check_to_space) {
return PSScavenge::should_scavenge(p, check_to_space);
}
bool PSPromotionManager::should_scavenge(narrowOop* p, bool check_to_space) {
return PSScavenge::should_scavenge(p, check_to_space);
}
PSPromotionManager* PSPromotionManager::gc_thread_promotion_manager(uint index) {
assert(index < ParallelGCThreads, "index out of range");
assert(_manager_array != nullptr, "Sanity");

View File

@ -167,9 +167,6 @@ class PSPromotionManager {
inline void process_popped_location_depth(ScannerTask task, bool stolen);
static bool should_scavenge(oop* p, bool check_to_space = false);
static bool should_scavenge(narrowOop* p, bool check_to_space = false);
template <bool promote_immediately, class T>
void copy_and_push_safe_barrier(T* p);

View File

@ -31,7 +31,7 @@
#include "gc/parallel/parMarkBitMap.inline.hpp"
#include "gc/parallel/psOldGen.hpp"
#include "gc/parallel/psPromotionLAB.inline.hpp"
#include "gc/parallel/psScavenge.inline.hpp"
#include "gc/parallel/psScavenge.hpp"
#include "gc/parallel/psStringDedup.hpp"
#include "gc/shared/continuationGCSupport.inline.hpp"
#include "gc/shared/taskqueue.inline.hpp"
@ -139,7 +139,8 @@ inline void PSPromotionManager::push_contents_bounded(oop obj, HeapWord* left, H
template<bool promote_immediately>
inline oop PSPromotionManager::copy_to_survivor_space(oop o) {
assert(should_scavenge(&o), "Sanity");
assert(PSScavenge::is_obj_in_young(o), "precondition");
assert(!PSScavenge::is_obj_in_to_space(o), "precondition");
// NOTE! We must be very careful with any methods that access the mark
// in o. There may be multiple threads racing on it, and it may be forwarded
@ -235,8 +236,6 @@ inline HeapWord* PSPromotionManager::allocate_in_old_gen(Klass* klass,
template<bool promote_immediately>
inline oop PSPromotionManager::copy_unmarked_to_survivor_space(oop o,
markWord test_mark) {
assert(should_scavenge(&o), "Sanity");
oop new_obj = nullptr;
bool new_obj_is_tenured = false;
@ -334,7 +333,6 @@ inline oop PSPromotionManager::copy_unmarked_to_survivor_space(oop o,
template <bool promote_immediately, class T>
inline void PSPromotionManager::copy_and_push_safe_barrier(T* p) {
assert(ParallelScavengeHeap::heap()->is_in_reserved(p), "precondition");
assert(should_scavenge(p, true), "revisiting object?");
oop o = RawAccess<IS_NOT_NULL>::oop_load(p);
oop new_obj = copy_to_survivor_space<promote_immediately>(o);

View File

@ -33,7 +33,7 @@
#include "gc/parallel/psParallelCompact.inline.hpp"
#include "gc/parallel/psPromotionManager.inline.hpp"
#include "gc/parallel/psRootType.hpp"
#include "gc/parallel/psScavenge.inline.hpp"
#include "gc/parallel/psScavenge.hpp"
#include "gc/shared/gcCause.hpp"
#include "gc/shared/gcHeapSummary.hpp"
#include "gc/shared/gcId.hpp"

View File

@ -100,15 +100,6 @@ class PSScavenge: AllStatic {
// Return true iff a young-gc is completed without promotion-failure.
static bool invoke(bool clear_soft_refs);
template <class T> static inline bool should_scavenge(T* p);
// These call should_scavenge() above and, if it returns true, also check that
// the object was not newly copied into to_space. The version with the bool
// argument is a convenience wrapper that fetches the to_space pointer from
// the heap and calls the other version (if the arg is true).
template <class T> static inline bool should_scavenge(T* p, MutableSpace* to_space);
template <class T> static inline bool should_scavenge(T* p, bool check_to_space);
// Is an object in the young generation
// This assumes that the 'o' is in the heap,
// so it only checks one side of the complete predicate.

View File

@ -1,63 +0,0 @@
/*
* Copyright (c) 2002, 2019, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#ifndef SHARE_GC_PARALLEL_PSSCAVENGE_INLINE_HPP
#define SHARE_GC_PARALLEL_PSSCAVENGE_INLINE_HPP
#include "gc/parallel/psScavenge.hpp"
#include "gc/parallel/parallelScavengeHeap.hpp"
#include "logging/log.hpp"
#include "memory/iterator.hpp"
#include "memory/resourceArea.hpp"
#include "oops/access.inline.hpp"
#include "oops/oop.inline.hpp"
#include "utilities/globalDefinitions.hpp"
template <class T> inline bool PSScavenge::should_scavenge(T* p) {
T heap_oop = RawAccess<>::oop_load(p);
return PSScavenge::is_obj_in_young(heap_oop);
}
template <class T>
inline bool PSScavenge::should_scavenge(T* p, MutableSpace* to_space) {
if (should_scavenge(p)) {
oop obj = RawAccess<IS_NOT_NULL>::oop_load(p);
// Skip objects copied to to_space since the scavenge started.
HeapWord* const addr = cast_from_oop<HeapWord*>(obj);
return addr < to_space->bottom() || addr >= to_space->end();
}
return false;
}
template <class T>
inline bool PSScavenge::should_scavenge(T* p, bool check_to_space) {
if (check_to_space) {
ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
return should_scavenge(p, heap->young_gen()->to_space());
}
return should_scavenge(p);
}
#endif // SHARE_GC_PARALLEL_PSSCAVENGE_INLINE_HPP