Skip to content

Commit

Permalink
8297209: Serial: Refactor GenCollectedHeap::full_process_roots
Browse files Browse the repository at this point in the history
Reviewed-by: tschatzl, iwalulya
  • Loading branch information
albertnetymk committed Dec 7, 2022
1 parent 86270e3 commit 6ed3683
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 39 deletions.
28 changes: 13 additions & 15 deletions src/hotspot/share/gc/serial/genMarkSweep.cpp
Expand Up @@ -185,12 +185,13 @@ void GenMarkSweep::mark_sweep_phase1(bool clear_all_softrefs) {
{
StrongRootsScope srs(0);

gch->full_process_roots(false, // not the adjust phase
GenCollectedHeap::SO_None,
ClassUnloading, // only strong roots if ClassUnloading
// is enabled
&follow_root_closure,
&follow_cld_closure);
CLDClosure* weak_cld_closure = ClassUnloading ? NULL : &follow_cld_closure;
MarkingCodeBlobClosure mark_code_closure(&follow_root_closure, !CodeBlobToOopClosure::FixRelocations, true);
gch->process_roots(GenCollectedHeap::SO_None,
&follow_root_closure,
&follow_cld_closure,
weak_cld_closure,
&mark_code_closure);
}

// Process reference objects found during marking
Expand Down Expand Up @@ -262,15 +263,12 @@ void GenMarkSweep::mark_sweep_phase3() {

ClassLoaderDataGraph::verify_claimed_marks_cleared(ClassLoaderData::_claim_stw_fullgc_adjust);

{
StrongRootsScope srs(0);

gch->full_process_roots(true, // this is the adjust phase
GenCollectedHeap::SO_AllCodeCache,
false, // all roots
&adjust_pointer_closure,
&adjust_cld_closure);
}
CodeBlobToOopClosure code_closure(&adjust_pointer_closure, CodeBlobToOopClosure::FixRelocations);
gch->process_roots(GenCollectedHeap::SO_AllCodeCache,
&adjust_pointer_closure,
&adjust_cld_closure,
&adjust_cld_closure,
&code_closure);

gch->gen_process_weak_roots(&adjust_pointer_closure);

Expand Down
14 changes: 0 additions & 14 deletions src/hotspot/share/gc/shared/genCollectedHeap.cpp
Expand Up @@ -793,20 +793,6 @@ void GenCollectedHeap::process_roots(ScanningOption so,
DEBUG_ONLY(ScavengableNMethods::asserted_non_scavengable_nmethods_do(&assert_code_is_non_scavengable));
}

void GenCollectedHeap::full_process_roots(bool is_adjust_phase,
ScanningOption so,
bool only_strong_roots,
OopClosure* root_closure,
CLDClosure* cld_closure) {
// Called from either the marking phase or the adjust phase.
const bool is_marking_phase = !is_adjust_phase;

MarkingCodeBlobClosure mark_code_closure(root_closure, is_adjust_phase, is_marking_phase);
CLDClosure* weak_cld_closure = only_strong_roots ? NULL : cld_closure;

process_roots(so, root_closure, cld_closure, weak_cld_closure, &mark_code_closure);
}

void GenCollectedHeap::gen_process_weak_roots(OopClosure* root_closure) {
WeakProcessor::oops_do(root_closure);
}
Expand Down
15 changes: 5 additions & 10 deletions src/hotspot/share/gc/shared/genCollectedHeap.hpp
Expand Up @@ -326,22 +326,17 @@ class GenCollectedHeap : public CollectedHeap {
};

protected:
virtual void gc_prologue(bool full);
virtual void gc_epilogue(bool full);

public:
// Apply closures on various roots in Young GC or marking/adjust phases of Full GC.
void process_roots(ScanningOption so,
OopClosure* strong_roots,
CLDClosure* strong_cld_closure,
CLDClosure* weak_cld_closure,
CodeBlobToOopClosure* code_roots);

virtual void gc_prologue(bool full);
virtual void gc_epilogue(bool full);

public:
void full_process_roots(bool is_adjust_phase,
ScanningOption so,
bool only_strong_roots,
OopClosure* root_closure,
CLDClosure* cld_closure);

// Apply "root_closure" to all the weak roots of the system.
// These include JNI weak roots, string table,
// and referents of reachable weak refs.
Expand Down

1 comment on commit 6ed3683

@openjdk-notifier
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.