< prev index next >

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

Print this page

        

@@ -67,44 +67,55 @@
   register_gc_pause_end(time);
   GCTimer::register_gc_end(time);
 }
 
 void ConcurrentGCTimer::register_gc_pause_start(const char* name) {
+  assert(!_is_concurrent_phase_active, "A pause phase can't be started while a concurrent phase is active.");
   GCTimer::register_gc_pause_start(name);
 }
 
 void ConcurrentGCTimer::register_gc_pause_end() {
+  assert(!_is_concurrent_phase_active, "A pause phase can't be ended while a concurrent phase is active.");
   GCTimer::register_gc_pause_end();
 }
 
+void ConcurrentGCTimer::register_gc_concurrent_start(const char* name, const Ticks& time) {
+  assert(!_is_concurrent_phase_active, "A concurrent phase is already active.");
+  _time_partitions.report_gc_phase_start(name, time, GCPhase::ConcurrentPhaseType);
+  NOT_PRODUCT(_is_concurrent_phase_active = true;)
+}
+
+void ConcurrentGCTimer::register_gc_concurrent_end(const Ticks& time) {
+  assert(_is_concurrent_phase_active, "A concurrent phase is not active.");
+  _time_partitions.report_gc_phase_end(time, GCPhase::ConcurrentPhaseType);
+  NOT_PRODUCT(_is_concurrent_phase_active = false;)
+}
+
 void PhasesStack::clear() {
   _next_phase_level = 0;
 }
 
 void PhasesStack::push(int phase_index) {
   assert(_next_phase_level < PHASE_LEVELS, "Overflow");
 
   _phase_indices[_next_phase_level] = phase_index;
-
   _next_phase_level++;
 }
 
 int PhasesStack::pop() {
   assert(_next_phase_level > 0, "Underflow");
 
   _next_phase_level--;
-
   return _phase_indices[_next_phase_level];
 }
 
 int PhasesStack::count() const {
   return _next_phase_level;
 }
 
-
 TimePartitions::TimePartitions() {
-  _phases = new (ResourceObj::C_HEAP, mtGC) GrowableArray<PausePhase>(INITIAL_CAPACITY, true, mtGC);
+  _phases = new (ResourceObj::C_HEAP, mtGC) GrowableArray<GCPhase>(INITIAL_CAPACITY, true, mtGC);
   clear();
 }
 
 TimePartitions::~TimePartitions() {
   delete _phases;

@@ -116,35 +127,35 @@
   _active_phases.clear();
   _sum_of_pauses = Tickspan();
   _longest_pause = Tickspan();
 }
 
-void TimePartitions::report_gc_phase_start(const char* name, const Ticks& time) {
+void TimePartitions::report_gc_phase_start(const char* name, const Ticks& time, GCPhase::PhaseType type) {
   assert(_phases->length() <= 1000, "Too many recored phases?");
 
   int level = _active_phases.count();
 
-  PausePhase phase;
+  GCPhase phase;
+  phase.set_type(type);
   phase.set_level(level);
   phase.set_name(name);
   phase.set_start(time);
 
   int index = _phases->append(phase);
 
   _active_phases.push(index);
 }
 
 void TimePartitions::update_statistics(GCPhase* phase) {
-  // FIXME: This should only be done for pause phases
-  if (phase->level() == 0) {
+  if ((phase->type() == GCPhase::PausePhaseType) && (phase->level() == 0)) {
     const Tickspan pause = phase->end() - phase->start();
     _sum_of_pauses += pause;
     _longest_pause = MAX2(pause, _longest_pause);
   }
 }
 
-void TimePartitions::report_gc_phase_end(const Ticks& time) {
+void TimePartitions::report_gc_phase_end(const Ticks& time, GCPhase::PhaseType type) {
   int phase_index = _active_phases.pop();
   GCPhase* phase = _phases->adr_at(phase_index);
   phase->set_end(time);
   update_statistics(phase);
 }

@@ -185,13 +196,14 @@
     two_pauses();
     one_sub_pause_phase();
     many_sub_pause_phases();
     many_sub_pause_phases2();
     max_nested_pause_phases();
+    one_concurrent();
   }
 
-  static void validate_pause_phase(GCPhase* phase, int level, const char* name, const Ticks& start, const Ticks& end) {
+  static void validate_gc_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");
   }

@@ -201,11 +213,11 @@
     time_partitions.report_gc_phase_start("PausePhase", 2);
     time_partitions.report_gc_phase_end(8);
 
     TimePartitionPhasesIterator iter(&time_partitions);
 
-    validate_pause_phase(iter.next(), 0, "PausePhase", 2, 8);
+    validate_gc_phase(iter.next(), 0, "PausePhase", 2, 8);
     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");
   }

@@ -217,12 +229,12 @@
     time_partitions.report_gc_phase_start("PausePhase2", 4);
     time_partitions.report_gc_phase_end(6);
 
     TimePartitionPhasesIterator iter(&time_partitions);
 
-    validate_pause_phase(iter.next(), 0, "PausePhase1", 2, 3);
-    validate_pause_phase(iter.next(), 0, "PausePhase2", 4, 6);
+    validate_gc_phase(iter.next(), 0, "PausePhase1", 2, 3);
+    validate_gc_phase(iter.next(), 0, "PausePhase2", 4, 6);
 
     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");

@@ -235,12 +247,12 @@
     time_partitions.report_gc_phase_end(4);
     time_partitions.report_gc_phase_end(5);
 
     TimePartitionPhasesIterator iter(&time_partitions);
 
-    validate_pause_phase(iter.next(), 0, "PausePhase", 2, 5);
-    validate_pause_phase(iter.next(), 1, "SubPhase", 3, 4);
+    validate_gc_phase(iter.next(), 0, "PausePhase", 2, 5);
+    validate_gc_phase(iter.next(), 1, "SubPhase", 3, 4);
 
     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");

@@ -257,14 +269,14 @@
     time_partitions.report_gc_phase_end(8);
     time_partitions.report_gc_phase_end(9);
 
     TimePartitionPhasesIterator iter(&time_partitions);
 
-    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);
+    validate_gc_phase(iter.next(), 0, "PausePhase", 2, 9);
+    validate_gc_phase(iter.next(), 1, "SubPhase1", 3, 8);
+    validate_gc_phase(iter.next(), 2, "SubPhase2", 4, 7);
+    validate_gc_phase(iter.next(), 3, "SubPhase3", 5, 6);
 
     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");

@@ -285,15 +297,15 @@
 
     time_partitions.report_gc_phase_end(11);
 
     TimePartitionPhasesIterator iter(&time_partitions);
 
-    validate_pause_phase(iter.next(), 0, "PausePhase", 2, 11);
-    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);
+    validate_gc_phase(iter.next(), 0, "PausePhase", 2, 11);
+    validate_gc_phase(iter.next(), 1, "SubPhase1", 3, 4);
+    validate_gc_phase(iter.next(), 1, "SubPhase2", 5, 6);
+    validate_gc_phase(iter.next(), 1, "SubPhase3", 7, 8);
+    validate_gc_phase(iter.next(), 1, "SubPhase4", 9, 10);
 
     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");

@@ -320,24 +332,39 @@
 
     time_partitions.report_gc_phase_end(17);
 
     TimePartitionPhasesIterator iter(&time_partitions);
 
-    validate_pause_phase(iter.next(), 0, "PausePhase", 2, 17);
-    validate_pause_phase(iter.next(), 1, "SubPhase1", 3, 8);
-    validate_pause_phase(iter.next(), 2, "SubPhase11", 4, 5);
-    validate_pause_phase(iter.next(), 2, "SubPhase12", 6, 7);
-    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);
+    validate_gc_phase(iter.next(), 0, "PausePhase", 2, 17);
+    validate_gc_phase(iter.next(), 1, "SubPhase1", 3, 8);
+    validate_gc_phase(iter.next(), 2, "SubPhase11", 4, 5);
+    validate_gc_phase(iter.next(), 2, "SubPhase12", 6, 7);
+    validate_gc_phase(iter.next(), 1, "SubPhase2", 9, 14);
+    validate_gc_phase(iter.next(), 2, "SubPhase21", 10, 11);
+    validate_gc_phase(iter.next(), 2, "SubPhase22", 12, 13);
+    validate_gc_phase(iter.next(), 1, "SubPhase3", 15, 16);
 
     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");
   }
+
+  static void one_concurrent() {
+    TimePartitions time_partitions;
+    time_partitions.report_gc_phase_start("ConcurrentPhase", 2, GCPhase::ConcurrentPhaseType);
+    time_partitions.report_gc_phase_end(8, GCPhase::ConcurrentPhaseType);
+
+    TimePartitionPhasesIterator iter(&time_partitions);
+
+    validate_gc_phase(iter.next(), 0, "ConcurrentPhase", 2, 8);
+    // ConcurrentPhaseType should not affect to both 'sum_of_pauses()' and 'longest_pause()'.
+    assert(time_partitions.sum_of_pauses() == Tickspan(), "Incorrect");
+    assert(time_partitions.longest_pause() == Tickspan(), "Incorrect");
+
+    assert(!iter.has_next(), "Too many elements");
+  }
 };
 
 class GCTimerTest {
 public:
   static void all() {
< prev index next >