1.1 --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Mon Sep 17 10:46:59 2012 -0400 1.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Mon Sep 17 10:33:13 2012 +0200 1.3 @@ -3663,6 +3663,43 @@ 1.4 } 1.5 #endif // TASKQUEUE_STATS 1.6 1.7 +void G1CollectedHeap::log_gc_header() { 1.8 + if (!G1Log::fine()) { 1.9 + return; 1.10 + } 1.11 + 1.12 + gclog_or_tty->date_stamp(PrintGCDateStamps); 1.13 + gclog_or_tty->stamp(PrintGCTimeStamps); 1.14 + 1.15 + GCCauseString gc_cause_str = GCCauseString("GC pause", gc_cause()) 1.16 + .append(g1_policy()->gcs_are_young() ? " (young)" : " (mixed)") 1.17 + .append(g1_policy()->during_initial_mark_pause() ? " (initial-mark)" : ""); 1.18 + 1.19 + gclog_or_tty->print("[%s", (const char*)gc_cause_str); 1.20 +} 1.21 + 1.22 +void G1CollectedHeap::log_gc_footer(double pause_time_sec) { 1.23 + if (!G1Log::fine()) { 1.24 + return; 1.25 + } 1.26 + 1.27 + if (G1Log::finer()) { 1.28 + if (evacuation_failed()) { 1.29 + gclog_or_tty->print(" (to-space exhausted)"); 1.30 + } 1.31 + gclog_or_tty->print_cr(", %3.7f secs]", pause_time_sec); 1.32 + g1_policy()->phase_times()->note_gc_end(); 1.33 + g1_policy()->phase_times()->print(pause_time_sec); 1.34 + g1_policy()->print_detailed_heap_transition(); 1.35 + } else { 1.36 + if (evacuation_failed()) { 1.37 + gclog_or_tty->print("--"); 1.38 + } 1.39 + g1_policy()->print_heap_transition(); 1.40 + gclog_or_tty->print_cr(", %3.7f secs]", pause_time_sec); 1.41 + } 1.42 +} 1.43 + 1.44 bool 1.45 G1CollectedHeap::do_collection_pause_at_safepoint(double target_pause_time_ms) { 1.46 assert_at_safepoint(true /* should_be_vm_thread */); 1.47 @@ -3705,17 +3742,13 @@ 1.48 // full collection counter. 1.49 increment_old_marking_cycles_started(); 1.50 } 1.51 - // if the log level is "finer" is on, we'll print long statistics information 1.52 - // in the collector policy code, so let's not print this as the output 1.53 - // is messy if we do. 1.54 - gclog_or_tty->date_stamp(G1Log::fine() && PrintGCDateStamps); 1.55 TraceCPUTime tcpu(G1Log::finer(), true, gclog_or_tty); 1.56 1.57 int active_workers = (G1CollectedHeap::use_parallel_gc_threads() ? 1.58 workers()->active_workers() : 1); 1.59 double pause_start_sec = os::elapsedTime(); 1.60 g1_policy()->phase_times()->note_gc_start(active_workers); 1.61 - bool initial_mark_gc = g1_policy()->during_initial_mark_pause(); 1.62 + log_gc_header(); 1.63 1.64 TraceCollectorStats tcs(g1mm()->incremental_collection_counters()); 1.65 TraceMemoryManagerStats tms(false /* fullGC */, gc_cause()); 1.66 @@ -4012,35 +4045,7 @@ 1.67 1.68 gc_epilogue(false); 1.69 1.70 - if (G1Log::fine()) { 1.71 - if (PrintGCTimeStamps) { 1.72 - gclog_or_tty->stamp(); 1.73 - gclog_or_tty->print(": "); 1.74 - } 1.75 - 1.76 - GCCauseString gc_cause_str = GCCauseString("GC pause", gc_cause()) 1.77 - .append(g1_policy()->gcs_are_young() ? " (young)" : " (mixed)") 1.78 - .append(initial_mark_gc ? " (initial-mark)" : ""); 1.79 - 1.80 - double pause_time_sec = os::elapsedTime() - pause_start_sec; 1.81 - 1.82 - if (G1Log::finer()) { 1.83 - if (evacuation_failed()) { 1.84 - gc_cause_str.append(" (to-space exhausted)"); 1.85 - } 1.86 - gclog_or_tty->print_cr("[%s, %3.7f secs]", (const char*)gc_cause_str, pause_time_sec); 1.87 - g1_policy()->phase_times()->note_gc_end(); 1.88 - g1_policy()->phase_times()->print(pause_time_sec); 1.89 - g1_policy()->print_detailed_heap_transition(); 1.90 - } else { 1.91 - if (evacuation_failed()) { 1.92 - gc_cause_str.append("--"); 1.93 - } 1.94 - gclog_or_tty->print("[%s", (const char*)gc_cause_str); 1.95 - g1_policy()->print_heap_transition(); 1.96 - gclog_or_tty->print_cr(", %3.7f secs]", pause_time_sec); 1.97 - } 1.98 - } 1.99 + log_gc_footer(os::elapsedTime() - pause_start_sec); 1.100 } 1.101 1.102 // It is not yet to safe to tell the concurrent mark to