src/share/vm/gc_implementation/shared/gcTimer.cpp

Print this page

        

@@ -23,56 +23,59 @@
  */
 
 #include "precompiled.hpp"
 #include "gc_implementation/shared/gcTimer.hpp"
 #include "utilities/growableArray.hpp"
+#include "utilities/ticks.inline.hpp"
 
-void GCTimer::register_gc_start(jlong time) {
+// the "time" parameter for most functions
+// has a default value set by Ticks::now()
+
+void GCTimer::register_gc_start(const Ticks& time) {
   _time_partitions.clear();
   _gc_start = time;
 }
 
-void GCTimer::register_gc_end(jlong time) {
+void GCTimer::register_gc_end(const Ticks& time) {
   assert(!_time_partitions.has_active_phases(),
       "We should have ended all started phases, before ending the GC");
 
   _gc_end = time;
 }
 
-void GCTimer::register_gc_pause_start(const char* name, jlong time) {
+void GCTimer::register_gc_pause_start(const char* name, const Ticks& time) {
   _time_partitions.report_gc_phase_start(name, time);
 }
 
-void GCTimer::register_gc_pause_end(jlong time) {
+void GCTimer::register_gc_pause_end(const Ticks& time) {
   _time_partitions.report_gc_phase_end(time);
 }
 
-void GCTimer::register_gc_phase_start(const char* name, jlong time) {
+void GCTimer::register_gc_phase_start(const char* name, const Ticks& time) {
   _time_partitions.report_gc_phase_start(name, time);
 }
 
-void GCTimer::register_gc_phase_end(jlong time) {
+void GCTimer::register_gc_phase_end(const Ticks& time) {
   _time_partitions.report_gc_phase_end(time);
 }
 
-
-void STWGCTimer::register_gc_start(jlong time) {
+void STWGCTimer::register_gc_start(const Ticks& time) {
   GCTimer::register_gc_start(time);
   register_gc_pause_start("GC Pause", time);
 }
 
-void STWGCTimer::register_gc_end(jlong time) {
+void STWGCTimer::register_gc_end(const Ticks& time) {
   register_gc_pause_end(time);
   GCTimer::register_gc_end(time);
 }
 
-void ConcurrentGCTimer::register_gc_pause_start(const char* name, jlong time) {
-  GCTimer::register_gc_pause_start(name, time);
+void ConcurrentGCTimer::register_gc_pause_start(const char* name) {
+  GCTimer::register_gc_pause_start(name);
 }
 
-void ConcurrentGCTimer::register_gc_pause_end(jlong time) {
-  GCTimer::register_gc_pause_end(time);
+void ConcurrentGCTimer::register_gc_pause_end() {
+  GCTimer::register_gc_pause_end();
 }
 
 void PhasesStack::clear() {
   _next_phase_level = 0;
 }

@@ -109,15 +112,15 @@
 }
 
 void TimePartitions::clear() {
   _phases->clear();
   _active_phases.clear();
-  _sum_of_pauses = 0;
-  _longest_pause = 0;
+  _sum_of_pauses = Tickspan();
+  _longest_pause = Tickspan();
 }
 
-void TimePartitions::report_gc_phase_start(const char* name, jlong time) {
+void TimePartitions::report_gc_phase_start(const char* name, const Ticks& time) {
   assert(_phases->length() <= 1000, "Too many recored phases?");
 
   int level = _active_phases.count();
 
   PausePhase phase;

@@ -131,17 +134,17 @@
 }
 
 void TimePartitions::update_statistics(GCPhase* phase) {
   // FIXME: This should only be done for pause phases
   if (phase->level() == 0) {
-    jlong pause = phase->end() - phase->start();
+    const Tickspan pause = phase->end() - phase->start();
     _sum_of_pauses += pause;
     _longest_pause = MAX2(pause, _longest_pause);
   }
 }
 
-void TimePartitions::report_gc_phase_end(jlong time) {
+void TimePartitions::report_gc_phase_end(const Ticks& time) {
   int phase_index = _active_phases.pop();
   GCPhase* phase = _phases->adr_at(phase_index);
   phase->set_end(time);
   update_statistics(phase);
 }

@@ -155,18 +158,10 @@
   assert(index < _phases->length(), "Out of bounds");
 
   return _phases->adr_at(index);
 }
 
-jlong TimePartitions::sum_of_pauses() {
-  return _sum_of_pauses;
-}
-
-jlong TimePartitions::longest_pause() {
-  return _longest_pause;
-}
-
 bool TimePartitions::has_active_phases() {
   return _active_phases.count() > 0;
 }
 
 bool TimePartitionPhasesIterator::has_next() {

@@ -192,11 +187,11 @@
     many_sub_pause_phases();
     many_sub_pause_phases2();
     max_nested_pause_phases();
   }
 
-  static void validate_pause_phase(GCPhase* phase, int level, const char* name, jlong start, jlong end) {
+  static void validate_pause_phase(GCPhase* phase, int level, const char* name, const Ticks& start, const Ticks& end) {
     assert(phase->level() == level, "Incorrect level");
     assert(strcmp(phase->name(), name) == 0, "Incorrect name");
     assert(phase->start() == start, "Incorrect start");
     assert(phase->end() == end, "Incorrect end");
   }

@@ -207,12 +202,12 @@
     time_partitions.report_gc_phase_end(8);
 
     TimePartitionPhasesIterator iter(&time_partitions);
 
     validate_pause_phase(iter.next(), 0, "PausePhase", 2, 8);
-    assert(time_partitions.sum_of_pauses() == 8-2, "Incorrect");
-    assert(time_partitions.longest_pause() == 8-2, "Incorrect");
+    assert(time_partitions.sum_of_pauses() == Ticks(8) - Ticks(2), "Incorrect");
+    assert(time_partitions.longest_pause() == Ticks(8) - Ticks(2), "Incorrect");
 
     assert(!iter.has_next(), "Too many elements");
   }
 
   static void two_pauses() {

@@ -225,12 +220,12 @@
     TimePartitionPhasesIterator iter(&time_partitions);
 
     validate_pause_phase(iter.next(), 0, "PausePhase1", 2, 3);
     validate_pause_phase(iter.next(), 0, "PausePhase2", 4, 6);
 
-    assert(time_partitions.sum_of_pauses() == 3, "Incorrect");
-    assert(time_partitions.longest_pause() == 2, "Incorrect");
+    assert(time_partitions.sum_of_pauses() == Ticks(3) - Ticks(0), "Incorrect");
+    assert(time_partitions.longest_pause() == Ticks(2) - Ticks(0), "Incorrect");
 
     assert(!iter.has_next(), "Too many elements");
   }
 
   static void one_sub_pause_phase() {

@@ -243,12 +238,12 @@
     TimePartitionPhasesIterator iter(&time_partitions);
 
     validate_pause_phase(iter.next(), 0, "PausePhase", 2, 5);
     validate_pause_phase(iter.next(), 1, "SubPhase", 3, 4);
 
-    assert(time_partitions.sum_of_pauses() == 3, "Incorrect");
-    assert(time_partitions.longest_pause() == 3, "Incorrect");
+    assert(time_partitions.sum_of_pauses() == Ticks(3) - Ticks(0), "Incorrect");
+    assert(time_partitions.longest_pause() == Ticks(3) - Ticks(0), "Incorrect");
 
     assert(!iter.has_next(), "Too many elements");
   }
 
   static void max_nested_pause_phases() {

@@ -267,12 +262,12 @@
     validate_pause_phase(iter.next(), 0, "PausePhase", 2, 9);
     validate_pause_phase(iter.next(), 1, "SubPhase1", 3, 8);
     validate_pause_phase(iter.next(), 2, "SubPhase2", 4, 7);
     validate_pause_phase(iter.next(), 3, "SubPhase3", 5, 6);
 
-    assert(time_partitions.sum_of_pauses() == 7, "Incorrect");
-    assert(time_partitions.longest_pause() == 7, "Incorrect");
+    assert(time_partitions.sum_of_pauses() == Ticks(7) - Ticks(0), "Incorrect");
+    assert(time_partitions.longest_pause() == Ticks(7) - Ticks(0), "Incorrect");
 
     assert(!iter.has_next(), "Too many elements");
   }
 
   static void many_sub_pause_phases() {

@@ -296,12 +291,12 @@
     validate_pause_phase(iter.next(), 1, "SubPhase1", 3, 4);
     validate_pause_phase(iter.next(), 1, "SubPhase2", 5, 6);
     validate_pause_phase(iter.next(), 1, "SubPhase3", 7, 8);
     validate_pause_phase(iter.next(), 1, "SubPhase4", 9, 10);
 
-    assert(time_partitions.sum_of_pauses() == 9, "Incorrect");
-    assert(time_partitions.longest_pause() == 9, "Incorrect");
+    assert(time_partitions.sum_of_pauses() == Ticks(9) - Ticks(0), "Incorrect");
+    assert(time_partitions.longest_pause() == Ticks(9) - Ticks(0), "Incorrect");
 
     assert(!iter.has_next(), "Too many elements");
   }
 
   static void many_sub_pause_phases2() {

@@ -334,12 +329,12 @@
     validate_pause_phase(iter.next(), 1, "SubPhase2", 9, 14);
     validate_pause_phase(iter.next(), 2, "SubPhase21", 10, 11);
     validate_pause_phase(iter.next(), 2, "SubPhase22", 12, 13);
     validate_pause_phase(iter.next(), 1, "SubPhase3", 15, 16);
 
-    assert(time_partitions.sum_of_pauses() == 15, "Incorrect");
-    assert(time_partitions.longest_pause() == 15, "Incorrect");
+    assert(time_partitions.sum_of_pauses() == Ticks(15) - Ticks(0), "Incorrect");
+    assert(time_partitions.longest_pause() == Ticks(15) - Ticks(0), "Incorrect");
 
     assert(!iter.has_next(), "Too many elements");
   }
 };