Skip to content


8294059: Serial: Refactor GenCollectedHeap::collect
Browse files Browse the repository at this point in the history
Reviewed-by: sjohanss, tschatzl
  • Loading branch information
albertnetymk committed Sep 28, 2022
1 parent ea61671 commit 60616f2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 26 deletions.
30 changes: 8 additions & 22 deletions src/hotspot/share/gc/shared/genCollectedHeap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -813,29 +813,7 @@ bool GenCollectedHeap::no_allocs_since_save_marks() {

// public collection interfaces

void GenCollectedHeap::collect(GCCause::Cause cause) {
if ((cause == GCCause::_wb_young_gc) ||
(cause == GCCause::_gc_locker)) {
// Young collection for WhiteBox or GCLocker.
collect(cause, YoungGen);
} else {
#ifdef ASSERT
if (cause == GCCause::_scavenge_alot) {
// Young collection only.
collect(cause, YoungGen);
} else {
// Stop-the-world full collection.
collect(cause, OldGen);
// Stop-the-world full collection.
collect(cause, OldGen);

void GenCollectedHeap::collect(GCCause::Cause cause, GenerationType max_generation) {
// The caller doesn't have the Heap_lock
assert(!Heap_lock->owned_by_self(), "this thread should not own the Heap_lock");

Expand All @@ -853,6 +831,14 @@ void GenCollectedHeap::collect(GCCause::Cause cause, GenerationType max_generati

bool should_run_young_gc = (cause == GCCause::_wb_young_gc)
|| (cause == GCCause::_gc_locker)
DEBUG_ONLY(|| (cause == GCCause::_scavenge_alot));

const GenerationType max_generation = should_run_young_gc
? YoungGen
: OldGen;

VM_GenCollectFull op(gc_count_before, full_gc_count_before,
cause, max_generation);
Expand Down
4 changes: 0 additions & 4 deletions src/hotspot/share/gc/shared/genCollectedHeap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,6 @@ class GenCollectedHeap : public CollectedHeap {
// supports. Caller does not hold the Heap_lock on entry.
virtual void collect(GCCause::Cause cause);

// Perform a full collection of generations up to and including max_generation.
// Mostly used for testing purposes. Caller does not hold the Heap_lock on entry.
void collect(GCCause::Cause cause, GenerationType max_generation);

// Returns "TRUE" iff "p" points into the committed areas of the heap.
// The methods is_in() and is_in_youngest() may be expensive to compute
// in general, so, to prevent their inadvertent use in product jvm's, we
Expand Down

1 comment on commit 60616f2

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.