50
50
51
51
// Breakpoint support
52
52
class ShenandoahBreakpointGCScope : public StackObj {
53
+ private:
54
+ const GCCause::Cause _cause;
53
55
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
+ }
56
61
}
57
62
58
63
~ShenandoahBreakpointGCScope () {
59
- ShenandoahBreakpoint::at_after_gc ();
64
+ if (_cause == GCCause::_wb_breakpoint) {
65
+ ShenandoahBreakpoint::at_after_gc ();
66
+ }
60
67
}
61
68
};
62
69
63
70
class ShenandoahBreakpointMarkScope : public StackObj {
71
+ private:
72
+ const GCCause::Cause _cause;
64
73
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
+ }
67
78
}
68
79
69
80
~ShenandoahBreakpointMarkScope () {
70
- ShenandoahBreakpoint::at_before_marking_completed ();
81
+ if (_cause == GCCause::_wb_breakpoint) {
82
+ ShenandoahBreakpoint::at_before_marking_completed ();
83
+ }
71
84
}
72
85
};
73
86
@@ -86,10 +99,7 @@ void ShenandoahConcurrentGC::cancel() {
86
99
87
100
bool ShenandoahConcurrentGC::collect (GCCause::Cause cause) {
88
101
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);
93
103
94
104
// Reset for upcoming marking
95
105
entry_reset ();
@@ -98,7 +108,7 @@ bool ShenandoahConcurrentGC::collect(GCCause::Cause cause) {
98
108
vmop_entry_init_mark ();
99
109
100
110
{
101
- ShenandoahBreakpointMarkScope breakpoint_mark_scope;
111
+ ShenandoahBreakpointMarkScope breakpoint_mark_scope (cause) ;
102
112
// Concurrent mark roots
103
113
entry_mark_roots ();
104
114
if (check_cancellation_and_abort (ShenandoahDegenPoint::_degenerated_outside_cycle)) return false ;
@@ -657,7 +667,9 @@ void ShenandoahConcurrentGC::op_weak_refs() {
657
667
assert (heap->is_concurrent_weak_root_in_progress (), " Only during this phase" );
658
668
// Concurrent weak refs processing
659
669
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
+ }
661
673
heap->ref_processor ()->process_references (ShenandoahPhaseTimings::conc_weak_refs, heap->workers (), true /* concurrent */ );
662
674
}
663
675
0 commit comments