8210463: Recalculate_used() always sets time taken in G1GCPhaseTimes
authortschatzl
Tue, 11 Sep 2018 09:13:37 +0200
changeset 51694 0dca9b29bf30
parent 51693 59de57e466ba
child 51695 bbc7157ad9c5
8210463: Recalculate_used() always sets time taken in G1GCPhaseTimes Reviewed-by: phh, sjohanss
src/hotspot/share/gc/g1/g1CollectedHeap.cpp
--- a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp	Tue Sep 11 09:27:47 2018 +0800
+++ b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp	Tue Sep 11 09:13:37 2018 +0200
@@ -1950,12 +1950,8 @@
 };
 
 size_t G1CollectedHeap::recalculate_used() const {
-  double recalculate_used_start = os::elapsedTime();
-
   SumUsedClosure blk;
   heap_region_iterate(&blk);
-
-  g1_policy()->phase_times()->record_evac_fail_recalc_used_time((os::elapsedTime() - recalculate_used_start) * 1000.0);
   return blk.result();
 }
 
@@ -3013,7 +3009,10 @@
         g1_policy()->phase_times()->record_start_new_cset_time_ms((os::elapsedTime() - start) * 1000.0);
 
         if (evacuation_failed()) {
+          double recalculate_used_start = os::elapsedTime();
           set_used(recalculate_used());
+          g1_policy()->phase_times()->record_evac_fail_recalc_used_time((os::elapsedTime() - recalculate_used_start) * 1000.0);
+
           if (_archive_allocator != NULL) {
             _archive_allocator->clear_used();
           }