Skip to content

Commit

Permalink
[Backport] 8305895: Fix G1 root region scanning crash of original 830…
Browse files Browse the repository at this point in the history
…5895 backport

Summary: Fix G1 root region scanning crash of 8305895 backport

Testing : CI pipeline

Reviewers: yulei, ddh

Issue: #755
  • Loading branch information
mmyxym authored and Accelerator1996 committed Dec 27, 2023
1 parent 35874c1 commit 1070e67
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/hotspot/share/gc/g1/g1CollectedHeap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1403,6 +1403,8 @@ class G1CollectedHeap : public CollectedHeap {
G1HeapSummary create_g1_heap_summary();
G1EvacSummary create_g1_evac_summary(G1EvacStats* stats);

inline bool root_region_scanning();

// Printing
private:
void print_heap_regions() const;
Expand Down
4 changes: 4 additions & 0 deletions src/hotspot/share/gc/g1/g1CollectedHeap.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,4 +289,8 @@ inline void G1CollectedHeap::set_humongous_is_live(oop obj) {
}
}

inline bool G1CollectedHeap::root_region_scanning() {
return _cm->root_regions()->scan_in_progress();
}

#endif // SHARE_VM_GC_G1_G1COLLECTEDHEAP_INLINE_HPP
10 changes: 10 additions & 0 deletions src/hotspot/share/runtime/safepoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@
#ifdef COMPILER1
#include "c1/c1_globals.hpp"
#endif
#if INCLUDE_G1GC
#include "gc/g1/g1CollectedHeap.inline.hpp"
#endif // INCLUDE_G1GC

template <typename E>
static void set_current_safepoint_id(E* event, int adjustment = 0) {
Expand Down Expand Up @@ -732,6 +735,13 @@ void SafepointSynchronize::do_cleanup_tasks() {

TraceTime timer("safepoint cleanup tasks", TRACETIME_LOG(Info, safepoint, cleanup));

#if INCLUDE_G1GC
if (UseCompactObjectHeaders && UseG1GC && G1CollectedHeap::heap()->root_region_scanning()) {
log_info(safepoint)("Safepoint cancels cleanup due to G1 root region scanning.");
return;
}
#endif // INCLUDE_G1GC

// Prepare for monitor deflation.
DeflateMonitorCounters deflate_counters;
ObjectSynchronizer::prepare_deflate_idle_monitors(&deflate_counters);
Expand Down

0 comments on commit 1070e67

Please sign in to comment.