8204287: Phase timings not updated correctly after JDK-6672778
Reviewed-by: tschatzl, kbarrett
--- a/src/hotspot/share/gc/g1/g1GCPhaseTimes.cpp Wed Jun 06 13:58:57 2018 -0700
+++ b/src/hotspot/share/gc/g1/g1GCPhaseTimes.cpp Thu Jun 07 09:02:03 2018 +0200
@@ -468,15 +468,24 @@
_pss(pss),
_start(Ticks::now()),
_total_time(total_time),
- _trim_time(trim_time) {
+ _trim_time(trim_time),
+ _stopped(false) {
assert(_pss->trim_ticks().value() == 0, "Possibly remaining trim ticks left over from previous use");
}
G1EvacPhaseWithTrimTimeTracker::~G1EvacPhaseWithTrimTimeTracker() {
+ if (!_stopped) {
+ stop();
+ }
+}
+
+void G1EvacPhaseWithTrimTimeTracker::stop() {
+ assert(!_stopped, "Should only be called once");
_total_time += (Ticks::now() - _start) - _pss->trim_ticks();
_trim_time += _pss->trim_ticks();
_pss->reset_trim_ticks();
+ _stopped = true;
}
G1GCParPhaseTimesTracker::G1GCParPhaseTimesTracker(G1GCPhaseTimes* phase_times, G1GCPhaseTimes::GCParPhases phase, uint worker_id) :
@@ -504,6 +513,8 @@
G1EvacPhaseTimesTracker::~G1EvacPhaseTimesTracker() {
if (_phase_times != NULL) {
+ // Explicitly stop the trim tracker since it's not yet destructed.
+ _trim_tracker.stop();
// Exclude trim time by increasing the start time.
_start_time += _trim_time;
_phase_times->record_or_add_objcopy_time_secs(_worker_id, _trim_time.seconds());
--- a/src/hotspot/share/gc/g1/g1GCPhaseTimes.hpp Wed Jun 06 13:58:57 2018 -0700
+++ b/src/hotspot/share/gc/g1/g1GCPhaseTimes.hpp Thu Jun 07 09:02:03 2018 +0200
@@ -373,9 +373,13 @@
Tickspan& _total_time;
Tickspan& _trim_time;
+
+ bool _stopped;
public:
G1EvacPhaseWithTrimTimeTracker(G1ParScanThreadState* pss, Tickspan& total_time, Tickspan& trim_time);
~G1EvacPhaseWithTrimTimeTracker();
+
+ void stop();
};
class G1GCParPhaseTimesTracker : public CHeapObj<mtGC> {