Skip to content

Commit 3f07337

Browse files
committed
8273614: Shenandoah: intermittent timeout with ConcurrentGCBreakpoint tests
Reviewed-by: shade
1 parent 0d80f6c commit 3f07337

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.cpp

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,24 +50,37 @@
5050

5151
// Breakpoint support
5252
class ShenandoahBreakpointGCScope : public StackObj {
53+
private:
54+
const GCCause::Cause _cause;
5355
public:
54-
ShenandoahBreakpointGCScope() {
55-
ShenandoahBreakpoint::at_before_gc();
56+
ShenandoahBreakpointGCScope(GCCause::Cause cause) : _cause(cause) {
57+
if (cause == GCCause::_wb_breakpoint) {
58+
ShenandoahBreakpoint::start_gc();
59+
ShenandoahBreakpoint::at_before_gc();
60+
}
5661
}
5762

5863
~ShenandoahBreakpointGCScope() {
59-
ShenandoahBreakpoint::at_after_gc();
64+
if (_cause == GCCause::_wb_breakpoint) {
65+
ShenandoahBreakpoint::at_after_gc();
66+
}
6067
}
6168
};
6269

6370
class ShenandoahBreakpointMarkScope : public StackObj {
71+
private:
72+
const GCCause::Cause _cause;
6473
public:
65-
ShenandoahBreakpointMarkScope() {
66-
ShenandoahBreakpoint::at_after_marking_started();
74+
ShenandoahBreakpointMarkScope(GCCause::Cause cause) : _cause(cause) {
75+
if (_cause == GCCause::_wb_breakpoint) {
76+
ShenandoahBreakpoint::at_after_marking_started();
77+
}
6778
}
6879

6980
~ShenandoahBreakpointMarkScope() {
70-
ShenandoahBreakpoint::at_before_marking_completed();
81+
if (_cause == GCCause::_wb_breakpoint) {
82+
ShenandoahBreakpoint::at_before_marking_completed();
83+
}
7184
}
7285
};
7386

@@ -86,10 +99,7 @@ void ShenandoahConcurrentGC::cancel() {
8699

87100
bool ShenandoahConcurrentGC::collect(GCCause::Cause cause) {
88101
ShenandoahHeap* const heap = ShenandoahHeap::heap();
89-
if (cause == GCCause::_wb_breakpoint) {
90-
ShenandoahBreakpoint::start_gc();
91-
}
92-
ShenandoahBreakpointGCScope breakpoint_gc_scope;
102+
ShenandoahBreakpointGCScope breakpoint_gc_scope(cause);
93103

94104
// Reset for upcoming marking
95105
entry_reset();
@@ -98,7 +108,7 @@ bool ShenandoahConcurrentGC::collect(GCCause::Cause cause) {
98108
vmop_entry_init_mark();
99109

100110
{
101-
ShenandoahBreakpointMarkScope breakpoint_mark_scope;
111+
ShenandoahBreakpointMarkScope breakpoint_mark_scope(cause);
102112
// Concurrent mark roots
103113
entry_mark_roots();
104114
if (check_cancellation_and_abort(ShenandoahDegenPoint::_degenerated_outside_cycle)) return false;
@@ -657,7 +667,9 @@ void ShenandoahConcurrentGC::op_weak_refs() {
657667
assert(heap->is_concurrent_weak_root_in_progress(), "Only during this phase");
658668
// Concurrent weak refs processing
659669
ShenandoahGCWorkerPhase worker_phase(ShenandoahPhaseTimings::conc_weak_refs);
660-
ShenandoahBreakpoint::at_after_reference_processing_started();
670+
if (heap->gc_cause() == GCCause::_wb_breakpoint) {
671+
ShenandoahBreakpoint::at_after_reference_processing_started();
672+
}
661673
heap->ref_processor()->process_references(ShenandoahPhaseTimings::conc_weak_refs, heap->workers(), true /* concurrent */);
662674
}
663675

0 commit comments

Comments
 (0)