8367848: Parallel: Use NMethodToOopClosure during Young GC

Reviewed-by: stefank, tschatzl
This commit is contained in:
Albert Mingkun Yang 2025-09-19 07:37:14 +00:00
parent 48d394a245
commit 28879d3d03
2 changed files with 13 additions and 3 deletions

View File

@ -99,7 +99,7 @@ static void scavenge_roots_work(ParallelRootType::Value root_type, uint worker_i
case ParallelRootType::code_cache:
{
MarkingNMethodClosure code_closure(&roots_to_old_closure, NMethodToOopClosure::FixRelocations, false /* keepalive nmethods */);
NMethodToOopClosure code_closure(&roots_to_old_closure, NMethodToOopClosure::FixRelocations);
ScavengableNMethods::nmethods_do(&code_closure);
}
break;
@ -234,7 +234,7 @@ public:
};
class ScavengeRootsTask : public WorkerTask {
StrongRootsScope _strong_roots_scope; // needed for Threads::possibly_parallel_threads_do
ThreadsClaimTokenScope _threads_claim_token_scope; // needed for Threads::possibly_parallel_threads_do
OopStorageSetStrongParState<false /* concurrent */, false /* is_const */> _oop_storage_strong_par_state;
SequentialSubTasksDone _subtasks;
PSOldGen* _old_gen;
@ -247,7 +247,7 @@ public:
ScavengeRootsTask(PSOldGen* old_gen,
uint active_workers) :
WorkerTask("ScavengeRootsTask"),
_strong_roots_scope(active_workers),
_threads_claim_token_scope(),
_subtasks(ParallelRootType::sentinel),
_old_gen(old_gen),
_gen_top(old_gen->object_space()->top()),

View File

@ -145,4 +145,14 @@ public:
struct Test; // For private gtest access.
};
// Used by GC for calling Threads::possibly_parallel_oops_do.
struct ThreadsClaimTokenScope : StackObj {
ThreadsClaimTokenScope() {
Threads::change_thread_claim_token();
}
~ThreadsClaimTokenScope() {
Threads::assert_all_threads_claimed();
}
};
#endif // SHARE_RUNTIME_THREADS_HPP