Thu, 19 Jun 2014 13:31:14 +0200
8043607: Add a GC id as a log decoration similar to PrintGCTimeStamps
Reviewed-by: jwilhelm, ehelin, tschatzl
1.1 --- a/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp Wed Jun 25 15:51:15 2014 -0700 1.2 +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp Thu Jun 19 13:31:14 2014 +0200 1.3 @@ -1999,7 +1999,7 @@ 1.4 SerialOldTracer* gc_tracer = GenMarkSweep::gc_tracer(); 1.5 gc_tracer->report_gc_start(gch->gc_cause(), gc_timer->gc_start()); 1.6 1.7 - GCTraceTime t("CMS:MSC ", PrintGCDetails && Verbose, true, NULL); 1.8 + GCTraceTime t("CMS:MSC ", PrintGCDetails && Verbose, true, NULL, gc_tracer->gc_id()); 1.9 if (PrintGC && Verbose && !(GCCause::is_user_requested_gc(gch->gc_cause()))) { 1.10 gclog_or_tty->print_cr("Compact ConcurrentMarkSweepGeneration after %d " 1.11 "collections passed to foreground collector", _full_gcs_since_conc_gc); 1.12 @@ -2509,8 +2509,10 @@ 1.13 assert(ConcurrentMarkSweepThread::vm_thread_has_cms_token(), 1.14 "VM thread should have CMS token"); 1.15 1.16 + // The gc id is created in register_foreground_gc_start if this collection is synchronous 1.17 + const GCId gc_id = _collectorState == InitialMarking ? GCId::peek() : _gc_tracer_cm->gc_id(); 1.18 NOT_PRODUCT(GCTraceTime t("CMS:MS (foreground) ", PrintGCDetails && Verbose, 1.19 - true, NULL);) 1.20 + true, NULL, gc_id);) 1.21 if (UseAdaptiveSizePolicy) { 1.22 size_policy()->ms_collection_begin(); 1.23 } 1.24 @@ -3527,6 +3529,7 @@ 1.25 public: 1.26 CMSPhaseAccounting(CMSCollector *collector, 1.27 const char *phase, 1.28 + const GCId gc_id, 1.29 bool print_cr = true); 1.30 ~CMSPhaseAccounting(); 1.31 1.32 @@ -3535,6 +3538,7 @@ 1.33 const char *_phase; 1.34 elapsedTimer _wallclock; 1.35 bool _print_cr; 1.36 + const GCId _gc_id; 1.37 1.38 public: 1.39 // Not MT-safe; so do not pass around these StackObj's 1.40 @@ -3550,15 +3554,15 @@ 1.41 1.42 CMSPhaseAccounting::CMSPhaseAccounting(CMSCollector *collector, 1.43 const char *phase, 1.44 + const GCId gc_id, 1.45 bool print_cr) : 1.46 - _collector(collector), _phase(phase), _print_cr(print_cr) { 1.47 + _collector(collector), _phase(phase), _print_cr(print_cr), _gc_id(gc_id) { 1.48 1.49 if (PrintCMSStatistics != 0) { 1.50 _collector->resetYields(); 1.51 } 1.52 if (PrintGCDetails) { 1.53 - gclog_or_tty->date_stamp(PrintGCDateStamps); 1.54 - gclog_or_tty->stamp(PrintGCTimeStamps); 1.55 + gclog_or_tty->gclog_stamp(_gc_id); 1.56 gclog_or_tty->print_cr("[%s-concurrent-%s-start]", 1.57 _collector->cmsGen()->short_name(), _phase); 1.58 } 1.59 @@ -3572,8 +3576,7 @@ 1.60 _collector->stopTimer(); 1.61 _wallclock.stop(); 1.62 if (PrintGCDetails) { 1.63 - gclog_or_tty->date_stamp(PrintGCDateStamps); 1.64 - gclog_or_tty->stamp(PrintGCTimeStamps); 1.65 + gclog_or_tty->gclog_stamp(_gc_id); 1.66 gclog_or_tty->print("[%s-concurrent-%s: %3.3f/%3.3f secs]", 1.67 _collector->cmsGen()->short_name(), 1.68 _phase, _collector->timerValue(), _wallclock.seconds()); 1.69 @@ -3671,7 +3674,7 @@ 1.70 setup_cms_unloading_and_verification_state(); 1.71 1.72 NOT_PRODUCT(GCTraceTime t("\ncheckpointRootsInitialWork", 1.73 - PrintGCDetails && Verbose, true, _gc_timer_cm);) 1.74 + PrintGCDetails && Verbose, true, _gc_timer_cm, _gc_tracer_cm->gc_id());) 1.75 if (UseAdaptiveSizePolicy) { 1.76 size_policy()->checkpoint_roots_initial_begin(); 1.77 } 1.78 @@ -3796,7 +3799,7 @@ 1.79 1.80 CMSTokenSyncWithLocks ts(true, bitMapLock()); 1.81 TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty); 1.82 - CMSPhaseAccounting pa(this, "mark", !PrintGCDetails); 1.83 + CMSPhaseAccounting pa(this, "mark", _gc_tracer_cm->gc_id(), !PrintGCDetails); 1.84 res = markFromRootsWork(asynch); 1.85 if (res) { 1.86 _collectorState = Precleaning; 1.87 @@ -4519,7 +4522,7 @@ 1.88 _start_sampling = false; 1.89 } 1.90 TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty); 1.91 - CMSPhaseAccounting pa(this, "preclean", !PrintGCDetails); 1.92 + CMSPhaseAccounting pa(this, "preclean", _gc_tracer_cm->gc_id(), !PrintGCDetails); 1.93 preclean_work(CMSPrecleanRefLists1, CMSPrecleanSurvivors1); 1.94 } 1.95 CMSTokenSync x(true); // is cms thread 1.96 @@ -4548,7 +4551,7 @@ 1.97 // we will never do an actual abortable preclean cycle. 1.98 if (get_eden_used() > CMSScheduleRemarkEdenSizeThreshold) { 1.99 TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty); 1.100 - CMSPhaseAccounting pa(this, "abortable-preclean", !PrintGCDetails); 1.101 + CMSPhaseAccounting pa(this, "abortable-preclean", _gc_tracer_cm->gc_id(), !PrintGCDetails); 1.102 // We need more smarts in the abortable preclean 1.103 // loop below to deal with cases where allocation 1.104 // in young gen is very very slow, and our precleaning 1.105 @@ -4693,7 +4696,7 @@ 1.106 GCTimer *gc_timer = NULL; // Currently not tracing concurrent phases 1.107 rp->preclean_discovered_references( 1.108 rp->is_alive_non_header(), &keep_alive, &complete_trace, &yield_cl, 1.109 - gc_timer); 1.110 + gc_timer, _gc_tracer_cm->gc_id()); 1.111 } 1.112 1.113 if (clean_survivor) { // preclean the active survivor space(s) 1.114 @@ -5036,7 +5039,7 @@ 1.115 // expect it to be false and set to true 1.116 FlagSetting fl(gch->_is_gc_active, false); 1.117 NOT_PRODUCT(GCTraceTime t("Scavenge-Before-Remark", 1.118 - PrintGCDetails && Verbose, true, _gc_timer_cm);) 1.119 + PrintGCDetails && Verbose, true, _gc_timer_cm, _gc_tracer_cm->gc_id());) 1.120 int level = _cmsGen->level() - 1; 1.121 if (level >= 0) { 1.122 gch->do_collection(true, // full (i.e. force, see below) 1.123 @@ -5065,7 +5068,7 @@ 1.124 void CMSCollector::checkpointRootsFinalWork(bool asynch, 1.125 bool clear_all_soft_refs, bool init_mark_was_synchronous) { 1.126 1.127 - NOT_PRODUCT(GCTraceTime tr("checkpointRootsFinalWork", PrintGCDetails, false, _gc_timer_cm);) 1.128 + NOT_PRODUCT(GCTraceTime tr("checkpointRootsFinalWork", PrintGCDetails, false, _gc_timer_cm, _gc_tracer_cm->gc_id());) 1.129 1.130 assert(haveFreelistLocks(), "must have free list locks"); 1.131 assert_lock_strong(bitMapLock()); 1.132 @@ -5120,11 +5123,11 @@ 1.133 // the most recent young generation GC, minus those cleaned up by the 1.134 // concurrent precleaning. 1.135 if (CMSParallelRemarkEnabled && CollectedHeap::use_parallel_gc_threads()) { 1.136 - GCTraceTime t("Rescan (parallel) ", PrintGCDetails, false, _gc_timer_cm); 1.137 + GCTraceTime t("Rescan (parallel) ", PrintGCDetails, false, _gc_timer_cm, _gc_tracer_cm->gc_id()); 1.138 do_remark_parallel(); 1.139 } else { 1.140 GCTraceTime t("Rescan (non-parallel) ", PrintGCDetails, false, 1.141 - _gc_timer_cm); 1.142 + _gc_timer_cm, _gc_tracer_cm->gc_id()); 1.143 do_remark_non_parallel(); 1.144 } 1.145 } 1.146 @@ -5137,7 +5140,7 @@ 1.147 verify_overflow_empty(); 1.148 1.149 { 1.150 - NOT_PRODUCT(GCTraceTime ts("refProcessingWork", PrintGCDetails, false, _gc_timer_cm);) 1.151 + NOT_PRODUCT(GCTraceTime ts("refProcessingWork", PrintGCDetails, false, _gc_timer_cm, _gc_tracer_cm->gc_id());) 1.152 refProcessingWork(asynch, clear_all_soft_refs); 1.153 } 1.154 verify_work_stacks_empty(); 1.155 @@ -5922,7 +5925,7 @@ 1.156 NULL, // space is set further below 1.157 &_markBitMap, &_markStack, &mrias_cl); 1.158 { 1.159 - GCTraceTime t("grey object rescan", PrintGCDetails, false, _gc_timer_cm); 1.160 + GCTraceTime t("grey object rescan", PrintGCDetails, false, _gc_timer_cm, _gc_tracer_cm->gc_id()); 1.161 // Iterate over the dirty cards, setting the corresponding bits in the 1.162 // mod union table. 1.163 { 1.164 @@ -5959,7 +5962,7 @@ 1.165 Universe::verify(); 1.166 } 1.167 { 1.168 - GCTraceTime t("root rescan", PrintGCDetails, false, _gc_timer_cm); 1.169 + GCTraceTime t("root rescan", PrintGCDetails, false, _gc_timer_cm, _gc_tracer_cm->gc_id()); 1.170 1.171 verify_work_stacks_empty(); 1.172 1.173 @@ -5981,7 +5984,7 @@ 1.174 } 1.175 1.176 { 1.177 - GCTraceTime t("visit unhandled CLDs", PrintGCDetails, false, _gc_timer_cm); 1.178 + GCTraceTime t("visit unhandled CLDs", PrintGCDetails, false, _gc_timer_cm, _gc_tracer_cm->gc_id()); 1.179 1.180 verify_work_stacks_empty(); 1.181 1.182 @@ -6000,7 +6003,7 @@ 1.183 } 1.184 1.185 { 1.186 - GCTraceTime t("dirty klass scan", PrintGCDetails, false, _gc_timer_cm); 1.187 + GCTraceTime t("dirty klass scan", PrintGCDetails, false, _gc_timer_cm, _gc_tracer_cm->gc_id()); 1.188 1.189 verify_work_stacks_empty(); 1.190 1.191 @@ -6202,7 +6205,7 @@ 1.192 _span, &_markBitMap, &_markStack, 1.193 &cmsKeepAliveClosure, false /* !preclean */); 1.194 { 1.195 - GCTraceTime t("weak refs processing", PrintGCDetails, false, _gc_timer_cm); 1.196 + GCTraceTime t("weak refs processing", PrintGCDetails, false, _gc_timer_cm, _gc_tracer_cm->gc_id()); 1.197 1.198 ReferenceProcessorStats stats; 1.199 if (rp->processing_is_mt()) { 1.200 @@ -6227,13 +6230,15 @@ 1.201 &cmsKeepAliveClosure, 1.202 &cmsDrainMarkingStackClosure, 1.203 &task_executor, 1.204 - _gc_timer_cm); 1.205 + _gc_timer_cm, 1.206 + _gc_tracer_cm->gc_id()); 1.207 } else { 1.208 stats = rp->process_discovered_references(&_is_alive_closure, 1.209 &cmsKeepAliveClosure, 1.210 &cmsDrainMarkingStackClosure, 1.211 NULL, 1.212 - _gc_timer_cm); 1.213 + _gc_timer_cm, 1.214 + _gc_tracer_cm->gc_id()); 1.215 } 1.216 _gc_tracer_cm->report_gc_reference_stats(stats); 1.217 1.218 @@ -6244,7 +6249,7 @@ 1.219 1.220 if (should_unload_classes()) { 1.221 { 1.222 - GCTraceTime t("class unloading", PrintGCDetails, false, _gc_timer_cm); 1.223 + GCTraceTime t("class unloading", PrintGCDetails, false, _gc_timer_cm, _gc_tracer_cm->gc_id()); 1.224 1.225 // Unload classes and purge the SystemDictionary. 1.226 bool purged_class = SystemDictionary::do_unloading(&_is_alive_closure); 1.227 @@ -6257,7 +6262,7 @@ 1.228 } 1.229 1.230 { 1.231 - GCTraceTime t("scrub symbol table", PrintGCDetails, false, _gc_timer_cm); 1.232 + GCTraceTime t("scrub symbol table", PrintGCDetails, false, _gc_timer_cm, _gc_tracer_cm->gc_id()); 1.233 // Clean up unreferenced symbols in symbol table. 1.234 SymbolTable::unlink(); 1.235 } 1.236 @@ -6266,7 +6271,7 @@ 1.237 // CMS doesn't use the StringTable as hard roots when class unloading is turned off. 1.238 // Need to check if we really scanned the StringTable. 1.239 if ((roots_scanning_options() & SharedHeap::SO_Strings) == 0) { 1.240 - GCTraceTime t("scrub string table", PrintGCDetails, false, _gc_timer_cm); 1.241 + GCTraceTime t("scrub string table", PrintGCDetails, false, _gc_timer_cm, _gc_tracer_cm->gc_id()); 1.242 // Delete entries for dead interned strings. 1.243 StringTable::unlink(&_is_alive_closure); 1.244 } 1.245 @@ -6333,7 +6338,7 @@ 1.246 _intra_sweep_timer.start(); 1.247 if (asynch) { 1.248 TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty); 1.249 - CMSPhaseAccounting pa(this, "sweep", !PrintGCDetails); 1.250 + CMSPhaseAccounting pa(this, "sweep", _gc_tracer_cm->gc_id(), !PrintGCDetails); 1.251 // First sweep the old gen 1.252 { 1.253 CMSTokenSyncWithLocks ts(true, _cmsGen->freelistLock(), 1.254 @@ -6554,7 +6559,7 @@ 1.255 // Clear the mark bitmap (no grey objects to start with) 1.256 // for the next cycle. 1.257 TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty); 1.258 - CMSPhaseAccounting cmspa(this, "reset", !PrintGCDetails); 1.259 + CMSPhaseAccounting cmspa(this, "reset", _gc_tracer_cm->gc_id(), !PrintGCDetails); 1.260 1.261 HeapWord* curAddr = _markBitMap.startWord(); 1.262 while (curAddr < _markBitMap.endWord()) { 1.263 @@ -6620,7 +6625,7 @@ 1.264 void CMSCollector::do_CMS_operation(CMS_op_type op, GCCause::Cause gc_cause) { 1.265 gclog_or_tty->date_stamp(PrintGC && PrintGCDateStamps); 1.266 TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty); 1.267 - GCTraceTime t(GCCauseString("GC", gc_cause), PrintGC, !PrintGCDetails, NULL); 1.268 + GCTraceTime t(GCCauseString("GC", gc_cause), PrintGC, !PrintGCDetails, NULL, _gc_tracer_cm->gc_id()); 1.269 TraceCollectorStats tcs(counters()); 1.270 1.271 switch (op) {
2.1 --- a/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp Wed Jun 25 15:51:15 2014 -0700 2.2 +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp Thu Jun 19 13:31:14 2014 +0200 2.3 @@ -64,7 +64,7 @@ 2.4 void VM_CMS_Operation::verify_before_gc() { 2.5 if (VerifyBeforeGC && 2.6 GenCollectedHeap::heap()->total_collections() >= VerifyGCStartAt) { 2.7 - GCTraceTime tm("Verify Before", false, false, _collector->_gc_timer_cm); 2.8 + GCTraceTime tm("Verify Before", false, false, _collector->_gc_timer_cm, _collector->_gc_tracer_cm->gc_id()); 2.9 HandleMark hm; 2.10 FreelistLocker x(_collector); 2.11 MutexLockerEx y(_collector->bitMapLock(), Mutex::_no_safepoint_check_flag); 2.12 @@ -76,7 +76,7 @@ 2.13 void VM_CMS_Operation::verify_after_gc() { 2.14 if (VerifyAfterGC && 2.15 GenCollectedHeap::heap()->total_collections() >= VerifyGCStartAt) { 2.16 - GCTraceTime tm("Verify After", false, false, _collector->_gc_timer_cm); 2.17 + GCTraceTime tm("Verify After", false, false, _collector->_gc_timer_cm, _collector->_gc_tracer_cm->gc_id()); 2.18 HandleMark hm; 2.19 FreelistLocker x(_collector); 2.20 MutexLockerEx y(_collector->bitMapLock(), Mutex::_no_safepoint_check_flag);
3.1 --- a/src/share/vm/gc_implementation/g1/concurrentMark.cpp Wed Jun 25 15:51:15 2014 -0700 3.2 +++ b/src/share/vm/gc_implementation/g1/concurrentMark.cpp Thu Jun 19 13:31:14 2014 +0200 3.3 @@ -510,6 +510,7 @@ 3.4 _has_overflown(false), 3.5 _concurrent(false), 3.6 _has_aborted(false), 3.7 + _aborted_gc_id(GCId::undefined()), 3.8 _restart_for_overflow(false), 3.9 _concurrent_marking_in_progress(false), 3.10 3.11 @@ -1019,8 +1020,7 @@ 3.12 force_overflow()->update(); 3.13 3.14 if (G1Log::fine()) { 3.15 - gclog_or_tty->date_stamp(PrintGCDateStamps); 3.16 - gclog_or_tty->stamp(PrintGCTimeStamps); 3.17 + gclog_or_tty->gclog_stamp(concurrent_gc_id()); 3.18 gclog_or_tty->print_cr("[GC concurrent-mark-reset-for-overflow]"); 3.19 } 3.20 } 3.21 @@ -2464,7 +2464,7 @@ 3.22 if (G1Log::finer()) { 3.23 gclog_or_tty->put(' '); 3.24 } 3.25 - GCTraceTime t("GC ref-proc", G1Log::finer(), false, g1h->gc_timer_cm()); 3.26 + GCTraceTime t("GC ref-proc", G1Log::finer(), false, g1h->gc_timer_cm(), concurrent_gc_id()); 3.27 3.28 ReferenceProcessor* rp = g1h->ref_processor_cm(); 3.29 3.30 @@ -2521,7 +2521,8 @@ 3.31 &g1_keep_alive, 3.32 &g1_drain_mark_stack, 3.33 executor, 3.34 - g1h->gc_timer_cm()); 3.35 + g1h->gc_timer_cm(), 3.36 + concurrent_gc_id()); 3.37 g1h->gc_tracer_cm()->report_gc_reference_stats(stats); 3.38 3.39 // The do_oop work routines of the keep_alive and drain_marking_stack 3.40 @@ -3252,6 +3253,12 @@ 3.41 } 3.42 _first_overflow_barrier_sync.abort(); 3.43 _second_overflow_barrier_sync.abort(); 3.44 + const GCId& gc_id = _g1h->gc_tracer_cm()->gc_id(); 3.45 + if (!gc_id.is_undefined()) { 3.46 + // We can do multiple full GCs before ConcurrentMarkThread::run() gets a chance 3.47 + // to detect that it was aborted. Only keep track of the first GC id that we aborted. 3.48 + _aborted_gc_id = gc_id; 3.49 + } 3.50 _has_aborted = true; 3.51 3.52 SATBMarkQueueSet& satb_mq_set = JavaThread::satb_mark_queue_set(); 3.53 @@ -3266,6 +3273,13 @@ 3.54 _g1h->register_concurrent_cycle_end(); 3.55 } 3.56 3.57 +const GCId& ConcurrentMark::concurrent_gc_id() { 3.58 + if (has_aborted()) { 3.59 + return _aborted_gc_id; 3.60 + } 3.61 + return _g1h->gc_tracer_cm()->gc_id(); 3.62 +} 3.63 + 3.64 static void print_ms_time_info(const char* prefix, const char* name, 3.65 NumberSeq& ns) { 3.66 gclog_or_tty->print_cr("%s%5d %12s: total time = %8.2f s (avg = %8.2f ms).",
4.1 --- a/src/share/vm/gc_implementation/g1/concurrentMark.hpp Wed Jun 25 15:51:15 2014 -0700 4.2 +++ b/src/share/vm/gc_implementation/g1/concurrentMark.hpp Thu Jun 19 13:31:14 2014 +0200 4.3 @@ -26,6 +26,7 @@ 4.4 #define SHARE_VM_GC_IMPLEMENTATION_G1_CONCURRENTMARK_HPP 4.5 4.6 #include "gc_implementation/g1/heapRegionSet.hpp" 4.7 +#include "gc_implementation/shared/gcId.hpp" 4.8 #include "utilities/taskqueue.hpp" 4.9 4.10 class G1CollectedHeap; 4.11 @@ -444,6 +445,7 @@ 4.12 volatile bool _concurrent; 4.13 // set at the end of a Full GC so that marking aborts 4.14 volatile bool _has_aborted; 4.15 + GCId _aborted_gc_id; 4.16 4.17 // used when remark aborts due to an overflow to indicate that 4.18 // another concurrent marking phase should start 4.19 @@ -825,6 +827,8 @@ 4.20 4.21 bool has_aborted() { return _has_aborted; } 4.22 4.23 + const GCId& concurrent_gc_id(); 4.24 + 4.25 // This prints the global/local fingers. It is used for debugging. 4.26 NOT_PRODUCT(void print_finger();) 4.27
5.1 --- a/src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp Wed Jun 25 15:51:15 2014 -0700 5.2 +++ b/src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp Thu Jun 19 13:31:14 2014 +0200 5.3 @@ -1,4 +1,4 @@ 5.4 -/* 5.5 + /* 5.6 * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. 5.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5.8 * 5.9 @@ -29,6 +29,7 @@ 5.10 #include "gc_implementation/g1/g1Log.hpp" 5.11 #include "gc_implementation/g1/g1MMUTracker.hpp" 5.12 #include "gc_implementation/g1/vm_operations_g1.hpp" 5.13 +#include "gc_implementation/shared/gcTrace.hpp" 5.14 #include "memory/resourceArea.hpp" 5.15 #include "runtime/vmThread.hpp" 5.16 5.17 @@ -109,8 +110,7 @@ 5.18 double scan_start = os::elapsedTime(); 5.19 if (!cm()->has_aborted()) { 5.20 if (G1Log::fine()) { 5.21 - gclog_or_tty->date_stamp(PrintGCDateStamps); 5.22 - gclog_or_tty->stamp(PrintGCTimeStamps); 5.23 + gclog_or_tty->gclog_stamp(cm()->concurrent_gc_id()); 5.24 gclog_or_tty->print_cr("[GC concurrent-root-region-scan-start]"); 5.25 } 5.26 5.27 @@ -118,8 +118,7 @@ 5.28 5.29 double scan_end = os::elapsedTime(); 5.30 if (G1Log::fine()) { 5.31 - gclog_or_tty->date_stamp(PrintGCDateStamps); 5.32 - gclog_or_tty->stamp(PrintGCTimeStamps); 5.33 + gclog_or_tty->gclog_stamp(cm()->concurrent_gc_id()); 5.34 gclog_or_tty->print_cr("[GC concurrent-root-region-scan-end, %1.7lf secs]", 5.35 scan_end - scan_start); 5.36 } 5.37 @@ -127,8 +126,7 @@ 5.38 5.39 double mark_start_sec = os::elapsedTime(); 5.40 if (G1Log::fine()) { 5.41 - gclog_or_tty->date_stamp(PrintGCDateStamps); 5.42 - gclog_or_tty->stamp(PrintGCTimeStamps); 5.43 + gclog_or_tty->gclog_stamp(cm()->concurrent_gc_id()); 5.44 gclog_or_tty->print_cr("[GC concurrent-mark-start]"); 5.45 } 5.46 5.47 @@ -151,8 +149,7 @@ 5.48 } 5.49 5.50 if (G1Log::fine()) { 5.51 - gclog_or_tty->date_stamp(PrintGCDateStamps); 5.52 - gclog_or_tty->stamp(PrintGCTimeStamps); 5.53 + gclog_or_tty->gclog_stamp(cm()->concurrent_gc_id()); 5.54 gclog_or_tty->print_cr("[GC concurrent-mark-end, %1.7lf secs]", 5.55 mark_end_sec - mark_start_sec); 5.56 } 5.57 @@ -167,8 +164,7 @@ 5.58 "in remark (restart #%d).", iter); 5.59 } 5.60 if (G1Log::fine()) { 5.61 - gclog_or_tty->date_stamp(PrintGCDateStamps); 5.62 - gclog_or_tty->stamp(PrintGCTimeStamps); 5.63 + gclog_or_tty->gclog_stamp(cm()->concurrent_gc_id()); 5.64 gclog_or_tty->print_cr("[GC concurrent-mark-restart-for-overflow]"); 5.65 } 5.66 } 5.67 @@ -212,8 +208,7 @@ 5.68 5.69 double cleanup_start_sec = os::elapsedTime(); 5.70 if (G1Log::fine()) { 5.71 - gclog_or_tty->date_stamp(PrintGCDateStamps); 5.72 - gclog_or_tty->stamp(PrintGCTimeStamps); 5.73 + gclog_or_tty->gclog_stamp(cm()->concurrent_gc_id()); 5.74 gclog_or_tty->print_cr("[GC concurrent-cleanup-start]"); 5.75 } 5.76 5.77 @@ -233,8 +228,7 @@ 5.78 5.79 double cleanup_end_sec = os::elapsedTime(); 5.80 if (G1Log::fine()) { 5.81 - gclog_or_tty->date_stamp(PrintGCDateStamps); 5.82 - gclog_or_tty->stamp(PrintGCTimeStamps); 5.83 + gclog_or_tty->gclog_stamp(cm()->concurrent_gc_id()); 5.84 gclog_or_tty->print_cr("[GC concurrent-cleanup-end, %1.7lf secs]", 5.85 cleanup_end_sec - cleanup_start_sec); 5.86 } 5.87 @@ -274,8 +268,7 @@ 5.88 5.89 if (cm()->has_aborted()) { 5.90 if (G1Log::fine()) { 5.91 - gclog_or_tty->date_stamp(PrintGCDateStamps); 5.92 - gclog_or_tty->stamp(PrintGCTimeStamps); 5.93 + gclog_or_tty->gclog_stamp(cm()->concurrent_gc_id()); 5.94 gclog_or_tty->print_cr("[GC concurrent-mark-abort]"); 5.95 } 5.96 }
6.1 --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Wed Jun 25 15:51:15 2014 -0700 6.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Thu Jun 19 13:31:14 2014 +0200 6.3 @@ -1305,7 +1305,7 @@ 6.4 TraceCPUTime tcpu(G1Log::finer(), true, gclog_or_tty); 6.5 6.6 { 6.7 - GCTraceTime t(GCCauseString("Full GC", gc_cause()), G1Log::fine(), true, NULL); 6.8 + GCTraceTime t(GCCauseString("Full GC", gc_cause()), G1Log::fine(), true, NULL, gc_tracer->gc_id()); 6.9 TraceCollectorStats tcs(g1mm()->full_collection_counters()); 6.10 TraceMemoryManagerStats tms(true /* fullGC */, gc_cause()); 6.11 6.12 @@ -3893,8 +3893,7 @@ 6.13 return; 6.14 } 6.15 6.16 - gclog_or_tty->date_stamp(PrintGCDateStamps); 6.17 - gclog_or_tty->stamp(PrintGCTimeStamps); 6.18 + gclog_or_tty->gclog_stamp(_gc_tracer_stw->gc_id()); 6.19 6.20 GCCauseString gc_cause_str = GCCauseString("GC pause", gc_cause()) 6.21 .append(g1_policy()->gcs_are_young() ? "(young)" : "(mixed)") 6.22 @@ -5781,7 +5780,8 @@ 6.23 &keep_alive, 6.24 &drain_queue, 6.25 NULL, 6.26 - _gc_timer_stw); 6.27 + _gc_timer_stw, 6.28 + _gc_tracer_stw->gc_id()); 6.29 } else { 6.30 // Parallel reference processing 6.31 assert(rp->num_q() == no_of_gc_workers, "sanity"); 6.32 @@ -5792,7 +5792,8 @@ 6.33 &keep_alive, 6.34 &drain_queue, 6.35 &par_task_executor, 6.36 - _gc_timer_stw); 6.37 + _gc_timer_stw, 6.38 + _gc_tracer_stw->gc_id()); 6.39 } 6.40 6.41 _gc_tracer_stw->report_gc_reference_stats(stats);
7.1 --- a/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp Wed Jun 25 15:51:15 2014 -0700 7.2 +++ b/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp Thu Jun 19 13:31:14 2014 +0200 7.3 @@ -123,7 +123,7 @@ 7.4 void G1MarkSweep::mark_sweep_phase1(bool& marked_for_unloading, 7.5 bool clear_all_softrefs) { 7.6 // Recursively traverse all live objects and mark them 7.7 - GCTraceTime tm("phase 1", G1Log::fine() && Verbose, true, gc_timer()); 7.8 + GCTraceTime tm("phase 1", G1Log::fine() && Verbose, true, gc_timer(), gc_tracer()->gc_id()); 7.9 GenMarkSweep::trace(" 1"); 7.10 7.11 SharedHeap* sh = SharedHeap::heap(); 7.12 @@ -148,7 +148,8 @@ 7.13 &GenMarkSweep::keep_alive, 7.14 &GenMarkSweep::follow_stack_closure, 7.15 NULL, 7.16 - gc_timer()); 7.17 + gc_timer(), 7.18 + gc_tracer()->gc_id()); 7.19 gc_tracer()->report_gc_reference_stats(stats); 7.20 7.21 7.22 @@ -262,7 +263,7 @@ 7.23 7.24 G1CollectedHeap* g1h = G1CollectedHeap::heap(); 7.25 7.26 - GCTraceTime tm("phase 2", G1Log::fine() && Verbose, true, gc_timer()); 7.27 + GCTraceTime tm("phase 2", G1Log::fine() && Verbose, true, gc_timer(), gc_tracer()->gc_id()); 7.28 GenMarkSweep::trace("2"); 7.29 7.30 // find the first region 7.31 @@ -299,7 +300,7 @@ 7.32 G1CollectedHeap* g1h = G1CollectedHeap::heap(); 7.33 7.34 // Adjust the pointers to reflect the new locations 7.35 - GCTraceTime tm("phase 3", G1Log::fine() && Verbose, true, gc_timer()); 7.36 + GCTraceTime tm("phase 3", G1Log::fine() && Verbose, true, gc_timer(), gc_tracer()->gc_id()); 7.37 GenMarkSweep::trace("3"); 7.38 7.39 SharedHeap* sh = SharedHeap::heap(); 7.40 @@ -362,7 +363,7 @@ 7.41 // to use a higher index (saved from phase2) when verifying perm_gen. 7.42 G1CollectedHeap* g1h = G1CollectedHeap::heap(); 7.43 7.44 - GCTraceTime tm("phase 4", G1Log::fine() && Verbose, true, gc_timer()); 7.45 + GCTraceTime tm("phase 4", G1Log::fine() && Verbose, true, gc_timer(), gc_tracer()->gc_id()); 7.46 GenMarkSweep::trace("4"); 7.47 7.48 G1SpaceCompactClosure blk;
8.1 --- a/src/share/vm/gc_implementation/g1/vm_operations_g1.cpp Wed Jun 25 15:51:15 2014 -0700 8.2 +++ b/src/share/vm/gc_implementation/g1/vm_operations_g1.cpp Thu Jun 19 13:31:14 2014 +0200 8.3 @@ -226,7 +226,7 @@ 8.4 void VM_CGC_Operation::doit() { 8.5 gclog_or_tty->date_stamp(G1Log::fine() && PrintGCDateStamps); 8.6 TraceCPUTime tcpu(G1Log::finer(), true, gclog_or_tty); 8.7 - GCTraceTime t(_printGCMessage, G1Log::fine(), true, G1CollectedHeap::heap()->gc_timer_cm()); 8.8 + GCTraceTime t(_printGCMessage, G1Log::fine(), true, G1CollectedHeap::heap()->gc_timer_cm(), G1CollectedHeap::heap()->concurrent_mark()->concurrent_gc_id()); 8.9 SharedHeap* sh = SharedHeap::heap(); 8.10 // This could go away if CollectedHeap gave access to _gc_is_active... 8.11 if (sh != NULL) {
9.1 --- a/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp Wed Jun 25 15:51:15 2014 -0700 9.2 +++ b/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp Thu Jun 19 13:31:14 2014 +0200 9.3 @@ -957,7 +957,7 @@ 9.4 size_policy->minor_collection_begin(); 9.5 } 9.6 9.7 - GCTraceTime t1(GCCauseString("GC", gch->gc_cause()), PrintGC && !PrintGCDetails, true, NULL); 9.8 + GCTraceTime t1(GCCauseString("GC", gch->gc_cause()), PrintGC && !PrintGCDetails, true, NULL, gc_tracer.gc_id()); 9.9 // Capture heap used before collection (for printing). 9.10 size_t gch_prev_used = gch->used(); 9.11 9.12 @@ -1015,14 +1015,14 @@ 9.13 ParNewRefProcTaskExecutor task_executor(*this, thread_state_set); 9.14 stats = rp->process_discovered_references(&is_alive, &keep_alive, 9.15 &evacuate_followers, &task_executor, 9.16 - _gc_timer); 9.17 + _gc_timer, gc_tracer.gc_id()); 9.18 } else { 9.19 thread_state_set.flush(); 9.20 gch->set_par_threads(0); // 0 ==> non-parallel. 9.21 gch->save_marks(); 9.22 stats = rp->process_discovered_references(&is_alive, &keep_alive, 9.23 &evacuate_followers, NULL, 9.24 - _gc_timer); 9.25 + _gc_timer, gc_tracer.gc_id()); 9.26 } 9.27 gc_tracer.report_gc_reference_stats(stats); 9.28 if (!promotion_failed()) {
10.1 --- a/src/share/vm/gc_implementation/parallelScavenge/pcTasks.cpp Wed Jun 25 15:51:15 2014 -0700 10.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/pcTasks.cpp Thu Jun 19 13:31:14 2014 +0200 10.3 @@ -53,7 +53,7 @@ 10.4 ResourceMark rm; 10.5 10.6 NOT_PRODUCT(GCTraceTime tm("ThreadRootsMarkingTask", 10.7 - PrintGCDetails && TraceParallelOldGCTasks, true, NULL)); 10.8 + PrintGCDetails && TraceParallelOldGCTasks, true, NULL, PSParallelCompact::gc_tracer()->gc_id())); 10.9 ParCompactionManager* cm = 10.10 ParCompactionManager::gc_thread_compaction_manager(which); 10.11 10.12 @@ -82,7 +82,7 @@ 10.13 assert(Universe::heap()->is_gc_active(), "called outside gc"); 10.14 10.15 NOT_PRODUCT(GCTraceTime tm("MarkFromRootsTask", 10.16 - PrintGCDetails && TraceParallelOldGCTasks, true, NULL)); 10.17 + PrintGCDetails && TraceParallelOldGCTasks, true, NULL, PSParallelCompact::gc_tracer()->gc_id())); 10.18 ParCompactionManager* cm = 10.19 ParCompactionManager::gc_thread_compaction_manager(which); 10.20 PSParallelCompact::MarkAndPushClosure mark_and_push_closure(cm); 10.21 @@ -153,7 +153,7 @@ 10.22 assert(Universe::heap()->is_gc_active(), "called outside gc"); 10.23 10.24 NOT_PRODUCT(GCTraceTime tm("RefProcTask", 10.25 - PrintGCDetails && TraceParallelOldGCTasks, true, NULL)); 10.26 + PrintGCDetails && TraceParallelOldGCTasks, true, NULL, PSParallelCompact::gc_tracer()->gc_id())); 10.27 ParCompactionManager* cm = 10.28 ParCompactionManager::gc_thread_compaction_manager(which); 10.29 PSParallelCompact::MarkAndPushClosure mark_and_push_closure(cm); 10.30 @@ -209,7 +209,7 @@ 10.31 assert(Universe::heap()->is_gc_active(), "called outside gc"); 10.32 10.33 NOT_PRODUCT(GCTraceTime tm("StealMarkingTask", 10.34 - PrintGCDetails && TraceParallelOldGCTasks, true, NULL)); 10.35 + PrintGCDetails && TraceParallelOldGCTasks, true, NULL, PSParallelCompact::gc_tracer()->gc_id())); 10.36 10.37 ParCompactionManager* cm = 10.38 ParCompactionManager::gc_thread_compaction_manager(which); 10.39 @@ -242,7 +242,7 @@ 10.40 assert(Universe::heap()->is_gc_active(), "called outside gc"); 10.41 10.42 NOT_PRODUCT(GCTraceTime tm("StealRegionCompactionTask", 10.43 - PrintGCDetails && TraceParallelOldGCTasks, true, NULL)); 10.44 + PrintGCDetails && TraceParallelOldGCTasks, true, NULL, PSParallelCompact::gc_tracer()->gc_id())); 10.45 10.46 ParCompactionManager* cm = 10.47 ParCompactionManager::gc_thread_compaction_manager(which); 10.48 @@ -309,7 +309,7 @@ 10.49 void UpdateDensePrefixTask::do_it(GCTaskManager* manager, uint which) { 10.50 10.51 NOT_PRODUCT(GCTraceTime tm("UpdateDensePrefixTask", 10.52 - PrintGCDetails && TraceParallelOldGCTasks, true, NULL)); 10.53 + PrintGCDetails && TraceParallelOldGCTasks, true, NULL, PSParallelCompact::gc_tracer()->gc_id())); 10.54 10.55 ParCompactionManager* cm = 10.56 ParCompactionManager::gc_thread_compaction_manager(which); 10.57 @@ -324,7 +324,7 @@ 10.58 assert(Universe::heap()->is_gc_active(), "called outside gc"); 10.59 10.60 NOT_PRODUCT(GCTraceTime tm("DrainStacksCompactionTask", 10.61 - PrintGCDetails && TraceParallelOldGCTasks, true, NULL)); 10.62 + PrintGCDetails && TraceParallelOldGCTasks, true, NULL, PSParallelCompact::gc_tracer()->gc_id())); 10.63 10.64 ParCompactionManager* cm = 10.65 ParCompactionManager::gc_thread_compaction_manager(which);
11.1 --- a/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp Wed Jun 25 15:51:15 2014 -0700 11.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp Thu Jun 19 13:31:14 2014 +0200 11.3 @@ -169,7 +169,7 @@ 11.4 11.5 gclog_or_tty->date_stamp(PrintGC && PrintGCDateStamps); 11.6 TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty); 11.7 - GCTraceTime t1(GCCauseString("Full GC", gc_cause), PrintGC, !PrintGCDetails, NULL); 11.8 + GCTraceTime t1(GCCauseString("Full GC", gc_cause), PrintGC, !PrintGCDetails, NULL, _gc_tracer->gc_id()); 11.9 TraceCollectorStats tcs(counters()); 11.10 TraceMemoryManagerStats tms(true /* Full GC */,gc_cause); 11.11 11.12 @@ -513,7 +513,7 @@ 11.13 11.14 void PSMarkSweep::mark_sweep_phase1(bool clear_all_softrefs) { 11.15 // Recursively traverse all live objects and mark them 11.16 - GCTraceTime tm("phase 1", PrintGCDetails && Verbose, true, _gc_timer); 11.17 + GCTraceTime tm("phase 1", PrintGCDetails && Verbose, true, _gc_timer, _gc_tracer->gc_id()); 11.18 trace(" 1"); 11.19 11.20 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); 11.21 @@ -548,7 +548,7 @@ 11.22 ref_processor()->setup_policy(clear_all_softrefs); 11.23 const ReferenceProcessorStats& stats = 11.24 ref_processor()->process_discovered_references( 11.25 - is_alive_closure(), mark_and_push_closure(), follow_stack_closure(), NULL, _gc_timer); 11.26 + is_alive_closure(), mark_and_push_closure(), follow_stack_closure(), NULL, _gc_timer, _gc_tracer->gc_id()); 11.27 gc_tracer()->report_gc_reference_stats(stats); 11.28 } 11.29 11.30 @@ -574,7 +574,7 @@ 11.31 11.32 11.33 void PSMarkSweep::mark_sweep_phase2() { 11.34 - GCTraceTime tm("phase 2", PrintGCDetails && Verbose, true, _gc_timer); 11.35 + GCTraceTime tm("phase 2", PrintGCDetails && Verbose, true, _gc_timer, _gc_tracer->gc_id()); 11.36 trace("2"); 11.37 11.38 // Now all live objects are marked, compute the new object addresses. 11.39 @@ -604,7 +604,7 @@ 11.40 11.41 void PSMarkSweep::mark_sweep_phase3() { 11.42 // Adjust the pointers to reflect the new locations 11.43 - GCTraceTime tm("phase 3", PrintGCDetails && Verbose, true, _gc_timer); 11.44 + GCTraceTime tm("phase 3", PrintGCDetails && Verbose, true, _gc_timer, _gc_tracer->gc_id()); 11.45 trace("3"); 11.46 11.47 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); 11.48 @@ -647,7 +647,7 @@ 11.49 11.50 void PSMarkSweep::mark_sweep_phase4() { 11.51 EventMark m("4 compact heap"); 11.52 - GCTraceTime tm("phase 4", PrintGCDetails && Verbose, true, _gc_timer); 11.53 + GCTraceTime tm("phase 4", PrintGCDetails && Verbose, true, _gc_timer, _gc_tracer->gc_id()); 11.54 trace("4"); 11.55 11.56 // All pointers are now adjusted, move objects accordingly
12.1 --- a/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp Wed Jun 25 15:51:15 2014 -0700 12.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp Thu Jun 19 13:31:14 2014 +0200 12.3 @@ -978,7 +978,7 @@ 12.4 // at each young gen gc. Do the update unconditionally (even though a 12.5 // promotion failure does not swap spaces) because an unknown number of minor 12.6 // collections will have swapped the spaces an unknown number of times. 12.7 - GCTraceTime tm("pre compact", print_phases(), true, &_gc_timer); 12.8 + GCTraceTime tm("pre compact", print_phases(), true, &_gc_timer, _gc_tracer.gc_id()); 12.9 ParallelScavengeHeap* heap = gc_heap(); 12.10 _space_info[from_space_id].set_space(heap->young_gen()->from_space()); 12.11 _space_info[to_space_id].set_space(heap->young_gen()->to_space()); 12.12 @@ -1021,7 +1021,7 @@ 12.13 12.14 void PSParallelCompact::post_compact() 12.15 { 12.16 - GCTraceTime tm("post compact", print_phases(), true, &_gc_timer); 12.17 + GCTraceTime tm("post compact", print_phases(), true, &_gc_timer, _gc_tracer.gc_id()); 12.18 12.19 for (unsigned int id = old_space_id; id < last_space_id; ++id) { 12.20 // Clear the marking bitmap, summary data and split info. 12.21 @@ -1847,7 +1847,7 @@ 12.22 void PSParallelCompact::summary_phase(ParCompactionManager* cm, 12.23 bool maximum_compaction) 12.24 { 12.25 - GCTraceTime tm("summary phase", print_phases(), true, &_gc_timer); 12.26 + GCTraceTime tm("summary phase", print_phases(), true, &_gc_timer, _gc_tracer.gc_id()); 12.27 // trace("2"); 12.28 12.29 #ifdef ASSERT 12.30 @@ -2056,7 +2056,7 @@ 12.31 12.32 gclog_or_tty->date_stamp(PrintGC && PrintGCDateStamps); 12.33 TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty); 12.34 - GCTraceTime t1(GCCauseString("Full GC", gc_cause), PrintGC, !PrintGCDetails, NULL); 12.35 + GCTraceTime t1(GCCauseString("Full GC", gc_cause), PrintGC, !PrintGCDetails, NULL, _gc_tracer.gc_id()); 12.36 TraceCollectorStats tcs(counters()); 12.37 TraceMemoryManagerStats tms(true /* Full GC */,gc_cause); 12.38 12.39 @@ -2351,7 +2351,7 @@ 12.40 bool maximum_heap_compaction, 12.41 ParallelOldTracer *gc_tracer) { 12.42 // Recursively traverse all live objects and mark them 12.43 - GCTraceTime tm("marking phase", print_phases(), true, &_gc_timer); 12.44 + GCTraceTime tm("marking phase", print_phases(), true, &_gc_timer, _gc_tracer.gc_id()); 12.45 12.46 ParallelScavengeHeap* heap = gc_heap(); 12.47 uint parallel_gc_threads = heap->gc_task_manager()->workers(); 12.48 @@ -2366,7 +2366,7 @@ 12.49 ClassLoaderDataGraph::clear_claimed_marks(); 12.50 12.51 { 12.52 - GCTraceTime tm_m("par mark", print_phases(), true, &_gc_timer); 12.53 + GCTraceTime tm_m("par mark", print_phases(), true, &_gc_timer, _gc_tracer.gc_id()); 12.54 12.55 ParallelScavengeHeap::ParStrongRootsScope psrs; 12.56 12.57 @@ -2395,24 +2395,24 @@ 12.58 12.59 // Process reference objects found during marking 12.60 { 12.61 - GCTraceTime tm_r("reference processing", print_phases(), true, &_gc_timer); 12.62 + GCTraceTime tm_r("reference processing", print_phases(), true, &_gc_timer, _gc_tracer.gc_id()); 12.63 12.64 ReferenceProcessorStats stats; 12.65 if (ref_processor()->processing_is_mt()) { 12.66 RefProcTaskExecutor task_executor; 12.67 stats = ref_processor()->process_discovered_references( 12.68 is_alive_closure(), &mark_and_push_closure, &follow_stack_closure, 12.69 - &task_executor, &_gc_timer); 12.70 + &task_executor, &_gc_timer, _gc_tracer.gc_id()); 12.71 } else { 12.72 stats = ref_processor()->process_discovered_references( 12.73 is_alive_closure(), &mark_and_push_closure, &follow_stack_closure, NULL, 12.74 - &_gc_timer); 12.75 + &_gc_timer, _gc_tracer.gc_id()); 12.76 } 12.77 12.78 gc_tracer->report_gc_reference_stats(stats); 12.79 } 12.80 12.81 - GCTraceTime tm_c("class unloading", print_phases(), true, &_gc_timer); 12.82 + GCTraceTime tm_c("class unloading", print_phases(), true, &_gc_timer, _gc_tracer.gc_id()); 12.83 12.84 // This is the point where the entire marking should have completed. 12.85 assert(cm->marking_stacks_empty(), "Marking should have completed"); 12.86 @@ -2451,7 +2451,7 @@ 12.87 12.88 void PSParallelCompact::adjust_roots() { 12.89 // Adjust the pointers to reflect the new locations 12.90 - GCTraceTime tm("adjust roots", print_phases(), true, &_gc_timer); 12.91 + GCTraceTime tm("adjust roots", print_phases(), true, &_gc_timer, _gc_tracer.gc_id()); 12.92 12.93 // Need new claim bits when tracing through and adjusting pointers. 12.94 ClassLoaderDataGraph::clear_claimed_marks(); 12.95 @@ -2487,7 +2487,7 @@ 12.96 void PSParallelCompact::enqueue_region_draining_tasks(GCTaskQueue* q, 12.97 uint parallel_gc_threads) 12.98 { 12.99 - GCTraceTime tm("drain task setup", print_phases(), true, &_gc_timer); 12.100 + GCTraceTime tm("drain task setup", print_phases(), true, &_gc_timer, _gc_tracer.gc_id()); 12.101 12.102 // Find the threads that are active 12.103 unsigned int which = 0; 12.104 @@ -2561,7 +2561,7 @@ 12.105 12.106 void PSParallelCompact::enqueue_dense_prefix_tasks(GCTaskQueue* q, 12.107 uint parallel_gc_threads) { 12.108 - GCTraceTime tm("dense prefix task setup", print_phases(), true, &_gc_timer); 12.109 + GCTraceTime tm("dense prefix task setup", print_phases(), true, &_gc_timer, _gc_tracer.gc_id()); 12.110 12.111 ParallelCompactData& sd = PSParallelCompact::summary_data(); 12.112 12.113 @@ -2643,7 +2643,7 @@ 12.114 GCTaskQueue* q, 12.115 ParallelTaskTerminator* terminator_ptr, 12.116 uint parallel_gc_threads) { 12.117 - GCTraceTime tm("steal task setup", print_phases(), true, &_gc_timer); 12.118 + GCTraceTime tm("steal task setup", print_phases(), true, &_gc_timer, _gc_tracer.gc_id()); 12.119 12.120 // Once a thread has drained it's stack, it should try to steal regions from 12.121 // other threads. 12.122 @@ -2691,7 +2691,7 @@ 12.123 12.124 void PSParallelCompact::compact() { 12.125 // trace("5"); 12.126 - GCTraceTime tm("compaction phase", print_phases(), true, &_gc_timer); 12.127 + GCTraceTime tm("compaction phase", print_phases(), true, &_gc_timer, _gc_tracer.gc_id()); 12.128 12.129 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); 12.130 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity"); 12.131 @@ -2708,7 +2708,7 @@ 12.132 enqueue_region_stealing_tasks(q, &terminator, active_gc_threads); 12.133 12.134 { 12.135 - GCTraceTime tm_pc("par compact", print_phases(), true, &_gc_timer); 12.136 + GCTraceTime tm_pc("par compact", print_phases(), true, &_gc_timer, _gc_tracer.gc_id()); 12.137 12.138 gc_task_manager()->execute_and_wait(q); 12.139 12.140 @@ -2722,7 +2722,7 @@ 12.141 12.142 { 12.143 // Update the deferred objects, if any. Any compaction manager can be used. 12.144 - GCTraceTime tm_du("deferred updates", print_phases(), true, &_gc_timer); 12.145 + GCTraceTime tm_du("deferred updates", print_phases(), true, &_gc_timer, _gc_tracer.gc_id()); 12.146 ParCompactionManager* cm = ParCompactionManager::manager_array(0); 12.147 for (unsigned int id = old_space_id; id < last_space_id; ++id) { 12.148 update_deferred_objects(cm, SpaceId(id));
13.1 --- a/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.hpp Wed Jun 25 15:51:15 2014 -0700 13.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.hpp Thu Jun 19 13:31:14 2014 +0200 13.3 @@ -1004,6 +1004,10 @@ 13.4 static bool _dwl_initialized; 13.5 #endif // #ifdef ASSERT 13.6 13.7 + 13.8 + public: 13.9 + static ParallelOldTracer* gc_tracer() { return &_gc_tracer; } 13.10 + 13.11 private: 13.12 13.13 static void initialize_space_info();
14.1 --- a/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp Wed Jun 25 15:51:15 2014 -0700 14.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp Thu Jun 19 13:31:14 2014 +0200 14.3 @@ -331,7 +331,7 @@ 14.4 14.5 gclog_or_tty->date_stamp(PrintGC && PrintGCDateStamps); 14.6 TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty); 14.7 - GCTraceTime t1(GCCauseString("GC", gc_cause), PrintGC, !PrintGCDetails, NULL); 14.8 + GCTraceTime t1(GCCauseString("GC", gc_cause), PrintGC, !PrintGCDetails, NULL, _gc_tracer.gc_id()); 14.9 TraceCollectorStats tcs(counters()); 14.10 TraceMemoryManagerStats tms(false /* not full GC */,gc_cause); 14.11 14.12 @@ -397,7 +397,7 @@ 14.13 // We'll use the promotion manager again later. 14.14 PSPromotionManager* promotion_manager = PSPromotionManager::vm_thread_promotion_manager(); 14.15 { 14.16 - GCTraceTime tm("Scavenge", false, false, &_gc_timer); 14.17 + GCTraceTime tm("Scavenge", false, false, &_gc_timer, _gc_tracer.gc_id()); 14.18 ParallelScavengeHeap::ParStrongRootsScope psrs; 14.19 14.20 GCTaskQueue* q = GCTaskQueue::create(); 14.21 @@ -439,7 +439,7 @@ 14.22 14.23 // Process reference objects discovered during scavenge 14.24 { 14.25 - GCTraceTime tm("References", false, false, &_gc_timer); 14.26 + GCTraceTime tm("References", false, false, &_gc_timer, _gc_tracer.gc_id()); 14.27 14.28 reference_processor()->setup_policy(false); // not always_clear 14.29 reference_processor()->set_active_mt_degree(active_workers); 14.30 @@ -450,10 +450,10 @@ 14.31 PSRefProcTaskExecutor task_executor; 14.32 stats = reference_processor()->process_discovered_references( 14.33 &_is_alive_closure, &keep_alive, &evac_followers, &task_executor, 14.34 - &_gc_timer); 14.35 + &_gc_timer, _gc_tracer.gc_id()); 14.36 } else { 14.37 stats = reference_processor()->process_discovered_references( 14.38 - &_is_alive_closure, &keep_alive, &evac_followers, NULL, &_gc_timer); 14.39 + &_is_alive_closure, &keep_alive, &evac_followers, NULL, &_gc_timer, _gc_tracer.gc_id()); 14.40 } 14.41 14.42 _gc_tracer.report_gc_reference_stats(stats); 14.43 @@ -468,7 +468,7 @@ 14.44 } 14.45 14.46 { 14.47 - GCTraceTime tm("StringTable", false, false, &_gc_timer); 14.48 + GCTraceTime tm("StringTable", false, false, &_gc_timer, _gc_tracer.gc_id()); 14.49 // Unlink any dead interned Strings and process the remaining live ones. 14.50 PSScavengeRootsClosure root_closure(promotion_manager); 14.51 StringTable::unlink_or_oops_do(&_is_alive_closure, &root_closure); 14.52 @@ -638,7 +638,7 @@ 14.53 NOT_PRODUCT(reference_processor()->verify_no_references_recorded()); 14.54 14.55 { 14.56 - GCTraceTime tm("Prune Scavenge Root Methods", false, false, &_gc_timer); 14.57 + GCTraceTime tm("Prune Scavenge Root Methods", false, false, &_gc_timer, _gc_tracer.gc_id()); 14.58 14.59 CodeCache::prune_scavenge_root_nmethods(); 14.60 }
15.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 15.2 +++ b/src/share/vm/gc_implementation/shared/gcId.cpp Thu Jun 19 13:31:14 2014 +0200 15.3 @@ -0,0 +1,42 @@ 15.4 +/* 15.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 15.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 15.7 + * 15.8 + * This code is free software; you can redistribute it and/or modify it 15.9 + * under the terms of the GNU General Public License version 2 only, as 15.10 + * published by the Free Software Foundation. 15.11 + * 15.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 15.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15.15 + * version 2 for more details (a copy is included in the LICENSE file that 15.16 + * accompanied this code). 15.17 + * 15.18 + * You should have received a copy of the GNU General Public License version 15.19 + * 2 along with this work; if not, write to the Free Software Foundation, 15.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 15.21 + * 15.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 15.23 + * or visit www.oracle.com if you need additional information or have any 15.24 + * questions. 15.25 + * 15.26 + */ 15.27 + 15.28 +#include "precompiled.hpp" 15.29 +#include "gc_implementation/shared/gcId.hpp" 15.30 +#include "runtime/safepoint.hpp" 15.31 + 15.32 +uint GCId::_next_id = 0; 15.33 + 15.34 +const GCId GCId::create() { 15.35 + return GCId(_next_id++); 15.36 +} 15.37 +const GCId GCId::peek() { 15.38 + return GCId(_next_id); 15.39 +} 15.40 +const GCId GCId::undefined() { 15.41 + return GCId(UNDEFINED); 15.42 +} 15.43 +bool GCId::is_undefined() const { 15.44 + return _id == UNDEFINED; 15.45 +}
16.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 16.2 +++ b/src/share/vm/gc_implementation/shared/gcId.hpp Thu Jun 19 13:31:14 2014 +0200 16.3 @@ -0,0 +1,51 @@ 16.4 +/* 16.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 16.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 16.7 + * 16.8 + * This code is free software; you can redistribute it and/or modify it 16.9 + * under the terms of the GNU General Public License version 2 only, as 16.10 + * published by the Free Software Foundation. 16.11 + * 16.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 16.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16.15 + * version 2 for more details (a copy is included in the LICENSE file that 16.16 + * accompanied this code). 16.17 + * 16.18 + * You should have received a copy of the GNU General Public License version 16.19 + * 2 along with this work; if not, write to the Free Software Foundation, 16.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 16.21 + * 16.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 16.23 + * or visit www.oracle.com if you need additional information or have any 16.24 + * questions. 16.25 + * 16.26 + */ 16.27 + 16.28 +#ifndef SHARE_VM_GC_IMPLEMENTATION_SHARED_GCID_HPP 16.29 +#define SHARE_VM_GC_IMPLEMENTATION_SHARED_GCID_HPP 16.30 + 16.31 +#include "memory/allocation.hpp" 16.32 + 16.33 +class GCId VALUE_OBJ_CLASS_SPEC { 16.34 + private: 16.35 + uint _id; 16.36 + GCId(uint id) : _id(id) {} 16.37 + GCId() { } // Unused 16.38 + 16.39 + static uint _next_id; 16.40 + static const uint UNDEFINED = (uint)-1; 16.41 + 16.42 + public: 16.43 + uint id() const { 16.44 + assert(_id != UNDEFINED, "Using undefined GC ID"); 16.45 + return _id; 16.46 + } 16.47 + bool is_undefined() const; 16.48 + 16.49 + static const GCId create(); 16.50 + static const GCId peek(); 16.51 + static const GCId undefined(); 16.52 +}; 16.53 + 16.54 +#endif // SHARE_VM_GC_IMPLEMENTATION_SHARED_GCID_HPP
17.1 --- a/src/share/vm/gc_implementation/shared/gcTrace.cpp Wed Jun 25 15:51:15 2014 -0700 17.2 +++ b/src/share/vm/gc_implementation/shared/gcTrace.cpp Thu Jun 19 13:31:14 2014 +0200 17.3 @@ -25,6 +25,7 @@ 17.4 #include "precompiled.hpp" 17.5 #include "gc_implementation/shared/copyFailedInfo.hpp" 17.6 #include "gc_implementation/shared/gcHeapSummary.hpp" 17.7 +#include "gc_implementation/shared/gcId.hpp" 17.8 #include "gc_implementation/shared/gcTimer.hpp" 17.9 #include "gc_implementation/shared/gcTrace.hpp" 17.10 #include "gc_implementation/shared/objectCountEventSender.hpp" 17.11 @@ -38,19 +39,14 @@ 17.12 #include "gc_implementation/g1/evacuationInfo.hpp" 17.13 #endif 17.14 17.15 -#define assert_unset_gc_id() assert(_shared_gc_info.id() == SharedGCInfo::UNSET_GCID, "GC already started?") 17.16 -#define assert_set_gc_id() assert(_shared_gc_info.id() != SharedGCInfo::UNSET_GCID, "GC not started?") 17.17 - 17.18 -static GCId GCTracer_next_gc_id = 0; 17.19 -static GCId create_new_gc_id() { 17.20 - return GCTracer_next_gc_id++; 17.21 -} 17.22 +#define assert_unset_gc_id() assert(_shared_gc_info.gc_id().is_undefined(), "GC already started?") 17.23 +#define assert_set_gc_id() assert(!_shared_gc_info.gc_id().is_undefined(), "GC not started?") 17.24 17.25 void GCTracer::report_gc_start_impl(GCCause::Cause cause, const Ticks& timestamp) { 17.26 assert_unset_gc_id(); 17.27 17.28 - GCId gc_id = create_new_gc_id(); 17.29 - _shared_gc_info.set_id(gc_id); 17.30 + GCId gc_id = GCId::create(); 17.31 + _shared_gc_info.set_gc_id(gc_id); 17.32 _shared_gc_info.set_cause(cause); 17.33 _shared_gc_info.set_start_timestamp(timestamp); 17.34 } 17.35 @@ -62,7 +58,7 @@ 17.36 } 17.37 17.38 bool GCTracer::has_reported_gc_start() const { 17.39 - return _shared_gc_info.id() != SharedGCInfo::UNSET_GCID; 17.40 + return !_shared_gc_info.gc_id().is_undefined(); 17.41 } 17.42 17.43 void GCTracer::report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions) { 17.44 @@ -81,7 +77,7 @@ 17.45 17.46 report_gc_end_impl(timestamp, time_partitions); 17.47 17.48 - _shared_gc_info.set_id(SharedGCInfo::UNSET_GCID); 17.49 + _shared_gc_info.set_gc_id(GCId::undefined()); 17.50 } 17.51 17.52 void GCTracer::report_gc_reference_stats(const ReferenceProcessorStats& rps) const { 17.53 @@ -132,7 +128,7 @@ 17.54 if (!cit.allocation_failed()) { 17.55 HeapInspection hi(false, false, false, NULL); 17.56 hi.populate_table(&cit, is_alive_cl); 17.57 - ObjectCountEventSenderClosure event_sender(_shared_gc_info.id(), cit.size_of_instances_in_words(), Ticks::now()); 17.58 + ObjectCountEventSenderClosure event_sender(_shared_gc_info.gc_id(), cit.size_of_instances_in_words(), Ticks::now()); 17.59 cit.iterate(&event_sender); 17.60 } 17.61 }
18.1 --- a/src/share/vm/gc_implementation/shared/gcTrace.hpp Wed Jun 25 15:51:15 2014 -0700 18.2 +++ b/src/share/vm/gc_implementation/shared/gcTrace.hpp Thu Jun 19 13:31:14 2014 +0200 18.3 @@ -27,6 +27,7 @@ 18.4 18.5 #include "gc_interface/gcCause.hpp" 18.6 #include "gc_interface/gcName.hpp" 18.7 +#include "gc_implementation/shared/gcId.hpp" 18.8 #include "gc_implementation/shared/gcWhen.hpp" 18.9 #include "gc_implementation/shared/copyFailedInfo.hpp" 18.10 #include "memory/allocation.hpp" 18.11 @@ -38,7 +39,6 @@ 18.12 #include "utilities/macros.hpp" 18.13 #include "utilities/ticks.hpp" 18.14 18.15 -typedef uint GCId; 18.16 18.17 class EvacuationInfo; 18.18 class GCHeapSummary; 18.19 @@ -50,11 +50,8 @@ 18.20 class BoolObjectClosure; 18.21 18.22 class SharedGCInfo VALUE_OBJ_CLASS_SPEC { 18.23 - public: 18.24 - static const GCId UNSET_GCID = (GCId)-1; 18.25 - 18.26 private: 18.27 - GCId _id; 18.28 + GCId _gc_id; 18.29 GCName _name; 18.30 GCCause::Cause _cause; 18.31 Ticks _start_timestamp; 18.32 @@ -64,7 +61,7 @@ 18.33 18.34 public: 18.35 SharedGCInfo(GCName name) : 18.36 - _id(UNSET_GCID), 18.37 + _gc_id(GCId::undefined()), 18.38 _name(name), 18.39 _cause(GCCause::_last_gc_cause), 18.40 _start_timestamp(), 18.41 @@ -73,8 +70,8 @@ 18.42 _longest_pause() { 18.43 } 18.44 18.45 - void set_id(GCId id) { _id = id; } 18.46 - GCId id() const { return _id; } 18.47 + void set_gc_id(GCId gc_id) { _gc_id = gc_id; } 18.48 + const GCId& gc_id() const { return _gc_id; } 18.49 18.50 void set_start_timestamp(const Ticks& timestamp) { _start_timestamp = timestamp; } 18.51 const Ticks start_timestamp() const { return _start_timestamp; } 18.52 @@ -131,10 +128,11 @@ 18.53 void report_gc_reference_stats(const ReferenceProcessorStats& rp) const; 18.54 void report_object_count_after_gc(BoolObjectClosure* object_filter) NOT_SERVICES_RETURN; 18.55 bool has_reported_gc_start() const; 18.56 + const GCId& gc_id() { return _shared_gc_info.gc_id(); } 18.57 18.58 protected: 18.59 GCTracer(GCName name) : _shared_gc_info(name) {} 18.60 - virtual void report_gc_start_impl(GCCause::Cause cause, const Ticks& timestamp); 18.61 + void report_gc_start_impl(GCCause::Cause cause, const Ticks& timestamp); 18.62 virtual void report_gc_end_impl(const Ticks& timestamp, TimePartitions* time_partitions); 18.63 18.64 private:
19.1 --- a/src/share/vm/gc_implementation/shared/gcTraceSend.cpp Wed Jun 25 15:51:15 2014 -0700 19.2 +++ b/src/share/vm/gc_implementation/shared/gcTraceSend.cpp Thu Jun 19 13:31:14 2014 +0200 19.3 @@ -43,7 +43,7 @@ 19.4 void GCTracer::send_garbage_collection_event() const { 19.5 EventGCGarbageCollection event(UNTIMED); 19.6 if (event.should_commit()) { 19.7 - event.set_gcId(_shared_gc_info.id()); 19.8 + event.set_gcId(_shared_gc_info.gc_id().id()); 19.9 event.set_name(_shared_gc_info.name()); 19.10 event.set_cause((u2) _shared_gc_info.cause()); 19.11 event.set_sumOfPauses(_shared_gc_info.sum_of_pauses()); 19.12 @@ -57,7 +57,7 @@ 19.13 void GCTracer::send_reference_stats_event(ReferenceType type, size_t count) const { 19.14 EventGCReferenceStatistics e; 19.15 if (e.should_commit()) { 19.16 - e.set_gcId(_shared_gc_info.id()); 19.17 + e.set_gcId(_shared_gc_info.gc_id().id()); 19.18 e.set_type((u1)type); 19.19 e.set_count(count); 19.20 e.commit(); 19.21 @@ -68,7 +68,7 @@ 19.22 const MetaspaceChunkFreeListSummary& summary) const { 19.23 EventMetaspaceChunkFreeListSummary e; 19.24 if (e.should_commit()) { 19.25 - e.set_gcId(_shared_gc_info.id()); 19.26 + e.set_gcId(_shared_gc_info.gc_id().id()); 19.27 e.set_when(when); 19.28 e.set_metadataType(mdtype); 19.29 19.30 @@ -91,7 +91,7 @@ 19.31 void ParallelOldTracer::send_parallel_old_event() const { 19.32 EventGCParallelOld e(UNTIMED); 19.33 if (e.should_commit()) { 19.34 - e.set_gcId(_shared_gc_info.id()); 19.35 + e.set_gcId(_shared_gc_info.gc_id().id()); 19.36 e.set_densePrefix((TraceAddress)_parallel_old_gc_info.dense_prefix()); 19.37 e.set_starttime(_shared_gc_info.start_timestamp()); 19.38 e.set_endtime(_shared_gc_info.end_timestamp()); 19.39 @@ -102,7 +102,7 @@ 19.40 void YoungGCTracer::send_young_gc_event() const { 19.41 EventGCYoungGarbageCollection e(UNTIMED); 19.42 if (e.should_commit()) { 19.43 - e.set_gcId(_shared_gc_info.id()); 19.44 + e.set_gcId(_shared_gc_info.gc_id().id()); 19.45 e.set_tenuringThreshold(_tenuring_threshold); 19.46 e.set_starttime(_shared_gc_info.start_timestamp()); 19.47 e.set_endtime(_shared_gc_info.end_timestamp()); 19.48 @@ -113,7 +113,7 @@ 19.49 void OldGCTracer::send_old_gc_event() const { 19.50 EventGCOldGarbageCollection e(UNTIMED); 19.51 if (e.should_commit()) { 19.52 - e.set_gcId(_shared_gc_info.id()); 19.53 + e.set_gcId(_shared_gc_info.gc_id().id()); 19.54 e.set_starttime(_shared_gc_info.start_timestamp()); 19.55 e.set_endtime(_shared_gc_info.end_timestamp()); 19.56 e.commit(); 19.57 @@ -132,7 +132,7 @@ 19.58 void YoungGCTracer::send_promotion_failed_event(const PromotionFailedInfo& pf_info) const { 19.59 EventPromotionFailed e; 19.60 if (e.should_commit()) { 19.61 - e.set_gcId(_shared_gc_info.id()); 19.62 + e.set_gcId(_shared_gc_info.gc_id().id()); 19.63 e.set_data(to_trace_struct(pf_info)); 19.64 e.set_thread(pf_info.thread()->thread_id()); 19.65 e.commit(); 19.66 @@ -143,7 +143,7 @@ 19.67 void OldGCTracer::send_concurrent_mode_failure_event() { 19.68 EventConcurrentModeFailure e; 19.69 if (e.should_commit()) { 19.70 - e.set_gcId(_shared_gc_info.id()); 19.71 + e.set_gcId(_shared_gc_info.gc_id().id()); 19.72 e.commit(); 19.73 } 19.74 } 19.75 @@ -152,7 +152,7 @@ 19.76 void G1NewTracer::send_g1_young_gc_event() { 19.77 EventGCG1GarbageCollection e(UNTIMED); 19.78 if (e.should_commit()) { 19.79 - e.set_gcId(_shared_gc_info.id()); 19.80 + e.set_gcId(_shared_gc_info.gc_id().id()); 19.81 e.set_type(_g1_young_gc_info.type()); 19.82 e.set_starttime(_shared_gc_info.start_timestamp()); 19.83 e.set_endtime(_shared_gc_info.end_timestamp()); 19.84 @@ -163,7 +163,7 @@ 19.85 void G1NewTracer::send_evacuation_info_event(EvacuationInfo* info) { 19.86 EventEvacuationInfo e; 19.87 if (e.should_commit()) { 19.88 - e.set_gcId(_shared_gc_info.id()); 19.89 + e.set_gcId(_shared_gc_info.gc_id().id()); 19.90 e.set_cSetRegions(info->collectionset_regions()); 19.91 e.set_cSetUsedBefore(info->collectionset_used_before()); 19.92 e.set_cSetUsedAfter(info->collectionset_used_after()); 19.93 @@ -179,7 +179,7 @@ 19.94 void G1NewTracer::send_evacuation_failed_event(const EvacuationFailedInfo& ef_info) const { 19.95 EventEvacuationFailed e; 19.96 if (e.should_commit()) { 19.97 - e.set_gcId(_shared_gc_info.id()); 19.98 + e.set_gcId(_shared_gc_info.gc_id().id()); 19.99 e.set_data(to_trace_struct(ef_info)); 19.100 e.commit(); 19.101 } 19.102 @@ -206,17 +206,17 @@ 19.103 } 19.104 19.105 class GCHeapSummaryEventSender : public GCHeapSummaryVisitor { 19.106 - GCId _id; 19.107 + GCId _gc_id; 19.108 GCWhen::Type _when; 19.109 public: 19.110 - GCHeapSummaryEventSender(GCId id, GCWhen::Type when) : _id(id), _when(when) {} 19.111 + GCHeapSummaryEventSender(GCId gc_id, GCWhen::Type when) : _gc_id(gc_id), _when(when) {} 19.112 19.113 void visit(const GCHeapSummary* heap_summary) const { 19.114 const VirtualSpaceSummary& heap_space = heap_summary->heap(); 19.115 19.116 EventGCHeapSummary e; 19.117 if (e.should_commit()) { 19.118 - e.set_gcId(_id); 19.119 + e.set_gcId(_gc_id.id()); 19.120 e.set_when((u1)_when); 19.121 e.set_heapSpace(to_trace_struct(heap_space)); 19.122 e.set_heapUsed(heap_summary->used()); 19.123 @@ -236,7 +236,7 @@ 19.124 19.125 EventPSHeapSummary e; 19.126 if (e.should_commit()) { 19.127 - e.set_gcId(_id); 19.128 + e.set_gcId(_gc_id.id()); 19.129 e.set_when((u1)_when); 19.130 19.131 e.set_oldSpace(to_trace_struct(ps_heap_summary->old())); 19.132 @@ -251,7 +251,7 @@ 19.133 }; 19.134 19.135 void GCTracer::send_gc_heap_summary_event(GCWhen::Type when, const GCHeapSummary& heap_summary) const { 19.136 - GCHeapSummaryEventSender visitor(_shared_gc_info.id(), when); 19.137 + GCHeapSummaryEventSender visitor(_shared_gc_info.gc_id(), when); 19.138 heap_summary.accept(&visitor); 19.139 } 19.140 19.141 @@ -268,7 +268,7 @@ 19.142 void GCTracer::send_meta_space_summary_event(GCWhen::Type when, const MetaspaceSummary& meta_space_summary) const { 19.143 EventMetaspaceSummary e; 19.144 if (e.should_commit()) { 19.145 - e.set_gcId(_shared_gc_info.id()); 19.146 + e.set_gcId(_shared_gc_info.gc_id().id()); 19.147 e.set_when((u1) when); 19.148 e.set_gcThreshold(meta_space_summary.capacity_until_GC()); 19.149 e.set_metaspace(to_trace_struct(meta_space_summary.meta_space())); 19.150 @@ -287,7 +287,7 @@ 19.151 void send_phase(PausePhase* pause) { 19.152 T event(UNTIMED); 19.153 if (event.should_commit()) { 19.154 - event.set_gcId(_gc_id); 19.155 + event.set_gcId(_gc_id.id()); 19.156 event.set_name(pause->name()); 19.157 event.set_starttime(pause->start()); 19.158 event.set_endtime(pause->end()); 19.159 @@ -311,7 +311,7 @@ 19.160 }; 19.161 19.162 void GCTracer::send_phase_events(TimePartitions* time_partitions) const { 19.163 - PhaseSender phase_reporter(_shared_gc_info.id()); 19.164 + PhaseSender phase_reporter(_shared_gc_info.gc_id()); 19.165 19.166 TimePartitionPhasesIterator iter(time_partitions); 19.167 while (iter.has_next()) {
20.1 --- a/src/share/vm/gc_implementation/shared/gcTraceTime.cpp Wed Jun 25 15:51:15 2014 -0700 20.2 +++ b/src/share/vm/gc_implementation/shared/gcTraceTime.cpp Thu Jun 19 13:31:14 2014 +0200 20.3 @@ -24,6 +24,7 @@ 20.4 20.5 #include "precompiled.hpp" 20.6 #include "gc_implementation/shared/gcTimer.hpp" 20.7 +#include "gc_implementation/shared/gcTrace.hpp" 20.8 #include "gc_implementation/shared/gcTraceTime.hpp" 20.9 #include "runtime/globals.hpp" 20.10 #include "runtime/os.hpp" 20.11 @@ -34,7 +35,7 @@ 20.12 #include "utilities/ticks.inline.hpp" 20.13 20.14 20.15 -GCTraceTime::GCTraceTime(const char* title, bool doit, bool print_cr, GCTimer* timer) : 20.16 +GCTraceTime::GCTraceTime(const char* title, bool doit, bool print_cr, GCTimer* timer, GCId gc_id) : 20.17 _title(title), _doit(doit), _print_cr(print_cr), _timer(timer), _start_counter() { 20.18 if (_doit || _timer != NULL) { 20.19 _start_counter.stamp(); 20.20 @@ -52,6 +53,9 @@ 20.21 gclog_or_tty->stamp(); 20.22 gclog_or_tty->print(": "); 20.23 } 20.24 + if (PrintGCID) { 20.25 + gclog_or_tty->print("#%u: ", gc_id.id()); 20.26 + } 20.27 gclog_or_tty->print("[%s", title); 20.28 gclog_or_tty->flush(); 20.29 }
21.1 --- a/src/share/vm/gc_implementation/shared/gcTraceTime.hpp Wed Jun 25 15:51:15 2014 -0700 21.2 +++ b/src/share/vm/gc_implementation/shared/gcTraceTime.hpp Thu Jun 19 13:31:14 2014 +0200 21.3 @@ -25,6 +25,7 @@ 21.4 #ifndef SHARE_VM_GC_IMPLEMENTATION_SHARED_GCTRACETIME_HPP 21.5 #define SHARE_VM_GC_IMPLEMENTATION_SHARED_GCTRACETIME_HPP 21.6 21.7 +#include "gc_implementation/shared/gcTrace.hpp" 21.8 #include "prims/jni_md.h" 21.9 #include "utilities/ticks.hpp" 21.10 21.11 @@ -38,7 +39,7 @@ 21.12 Ticks _start_counter; 21.13 21.14 public: 21.15 - GCTraceTime(const char* title, bool doit, bool print_cr, GCTimer* timer); 21.16 + GCTraceTime(const char* title, bool doit, bool print_cr, GCTimer* timer, GCId gc_id); 21.17 ~GCTraceTime(); 21.18 }; 21.19
22.1 --- a/src/share/vm/gc_implementation/shared/objectCountEventSender.cpp Wed Jun 25 15:51:15 2014 -0700 22.2 +++ b/src/share/vm/gc_implementation/shared/objectCountEventSender.cpp Thu Jun 19 13:31:14 2014 +0200 22.3 @@ -24,6 +24,7 @@ 22.4 22.5 22.6 #include "precompiled.hpp" 22.7 +#include "gc_implementation/shared/gcId.hpp" 22.8 #include "gc_implementation/shared/objectCountEventSender.hpp" 22.9 #include "memory/heapInspection.hpp" 22.10 #include "trace/tracing.hpp" 22.11 @@ -38,7 +39,7 @@ 22.12 "Only call this method if the event is enabled"); 22.13 22.14 EventObjectCountAfterGC event(UNTIMED); 22.15 - event.set_gcId(gc_id); 22.16 + event.set_gcId(gc_id.id()); 22.17 event.set_class(entry->klass()); 22.18 event.set_count(entry->count()); 22.19 event.set_totalSize(entry->words() * BytesPerWord);
23.1 --- a/src/share/vm/gc_interface/collectedHeap.cpp Wed Jun 25 15:51:15 2014 -0700 23.2 +++ b/src/share/vm/gc_interface/collectedHeap.cpp Thu Jun 19 13:31:14 2014 +0200 23.3 @@ -558,13 +558,13 @@ 23.4 23.5 void CollectedHeap::pre_full_gc_dump(GCTimer* timer) { 23.6 if (HeapDumpBeforeFullGC) { 23.7 - GCTraceTime tt("Heap Dump (before full gc): ", PrintGCDetails, false, timer); 23.8 + GCTraceTime tt("Heap Dump (before full gc): ", PrintGCDetails, false, timer, GCId::create()); 23.9 // We are doing a "major" collection and a heap dump before 23.10 // major collection has been requested. 23.11 HeapDumper::dump_heap(); 23.12 } 23.13 if (PrintClassHistogramBeforeFullGC) { 23.14 - GCTraceTime tt("Class Histogram (before full gc): ", PrintGCDetails, true, timer); 23.15 + GCTraceTime tt("Class Histogram (before full gc): ", PrintGCDetails, true, timer, GCId::create()); 23.16 VM_GC_HeapInspection inspector(gclog_or_tty, false /* ! full gc */); 23.17 inspector.doit(); 23.18 } 23.19 @@ -572,11 +572,11 @@ 23.20 23.21 void CollectedHeap::post_full_gc_dump(GCTimer* timer) { 23.22 if (HeapDumpAfterFullGC) { 23.23 - GCTraceTime tt("Heap Dump (after full gc): ", PrintGCDetails, false, timer); 23.24 + GCTraceTime tt("Heap Dump (after full gc): ", PrintGCDetails, false, timer, GCId::create()); 23.25 HeapDumper::dump_heap(); 23.26 } 23.27 if (PrintClassHistogramAfterFullGC) { 23.28 - GCTraceTime tt("Class Histogram (after full gc): ", PrintGCDetails, true, timer); 23.29 + GCTraceTime tt("Class Histogram (after full gc): ", PrintGCDetails, true, timer, GCId::create()); 23.30 VM_GC_HeapInspection inspector(gclog_or_tty, false /* ! full gc */); 23.31 inspector.doit(); 23.32 }
24.1 --- a/src/share/vm/memory/defNewGeneration.cpp Wed Jun 25 15:51:15 2014 -0700 24.2 +++ b/src/share/vm/memory/defNewGeneration.cpp Thu Jun 19 13:31:14 2014 +0200 24.3 @@ -584,7 +584,7 @@ 24.4 24.5 init_assuming_no_promotion_failure(); 24.6 24.7 - GCTraceTime t1(GCCauseString("GC", gch->gc_cause()), PrintGC && !PrintGCDetails, true, NULL); 24.8 + GCTraceTime t1(GCCauseString("GC", gch->gc_cause()), PrintGC && !PrintGCDetails, true, NULL, gc_tracer.gc_id()); 24.9 // Capture heap used before collection (for printing). 24.10 size_t gch_prev_used = gch->used(); 24.11 24.12 @@ -642,7 +642,7 @@ 24.13 rp->setup_policy(clear_all_soft_refs); 24.14 const ReferenceProcessorStats& stats = 24.15 rp->process_discovered_references(&is_alive, &keep_alive, &evacuate_followers, 24.16 - NULL, _gc_timer); 24.17 + NULL, _gc_timer, gc_tracer.gc_id()); 24.18 gc_tracer.report_gc_reference_stats(stats); 24.19 24.20 if (!_promotion_failed) {
25.1 --- a/src/share/vm/memory/genCollectedHeap.cpp Wed Jun 25 15:51:15 2014 -0700 25.2 +++ b/src/share/vm/memory/genCollectedHeap.cpp Thu Jun 19 13:31:14 2014 +0200 25.3 @@ -28,6 +28,7 @@ 25.4 #include "classfile/vmSymbols.hpp" 25.5 #include "code/icBuffer.hpp" 25.6 #include "gc_implementation/shared/collectorCounters.hpp" 25.7 +#include "gc_implementation/shared/gcTrace.hpp" 25.8 #include "gc_implementation/shared/gcTraceTime.hpp" 25.9 #include "gc_implementation/shared/vmGCOperations.hpp" 25.10 #include "gc_interface/collectedHeap.inline.hpp" 25.11 @@ -385,7 +386,9 @@ 25.12 const char* gc_cause_prefix = complete ? "Full GC" : "GC"; 25.13 gclog_or_tty->date_stamp(PrintGC && PrintGCDateStamps); 25.14 TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty); 25.15 - GCTraceTime t(GCCauseString(gc_cause_prefix, gc_cause()), PrintGCDetails, false, NULL); 25.16 + // The PrintGCDetails logging starts before we have incremented the GC id. We will do that later 25.17 + // so we can assume here that the next GC id is what we want. 25.18 + GCTraceTime t(GCCauseString(gc_cause_prefix, gc_cause()), PrintGCDetails, false, NULL, GCId::peek()); 25.19 25.20 gc_prologue(complete); 25.21 increment_total_collections(complete); 25.22 @@ -418,7 +421,9 @@ 25.23 } 25.24 // Timer for individual generations. Last argument is false: no CR 25.25 // FIXME: We should try to start the timing earlier to cover more of the GC pause 25.26 - GCTraceTime t1(_gens[i]->short_name(), PrintGCDetails, false, NULL); 25.27 + // The PrintGCDetails logging starts before we have incremented the GC id. We will do that later 25.28 + // so we can assume here that the next GC id is what we want. 25.29 + GCTraceTime t1(_gens[i]->short_name(), PrintGCDetails, false, NULL, GCId::peek()); 25.30 TraceCollectorStats tcs(_gens[i]->counters()); 25.31 TraceMemoryManagerStats tmms(_gens[i]->kind(),gc_cause()); 25.32
26.1 --- a/src/share/vm/memory/genMarkSweep.cpp Wed Jun 25 15:51:15 2014 -0700 26.2 +++ b/src/share/vm/memory/genMarkSweep.cpp Thu Jun 19 13:31:14 2014 +0200 26.3 @@ -69,7 +69,7 @@ 26.4 _ref_processor = rp; 26.5 rp->setup_policy(clear_all_softrefs); 26.6 26.7 - GCTraceTime t1(GCCauseString("Full GC", gch->gc_cause()), PrintGC && !PrintGCDetails, true, NULL); 26.8 + GCTraceTime t1(GCCauseString("Full GC", gch->gc_cause()), PrintGC && !PrintGCDetails, true, NULL, _gc_tracer->gc_id()); 26.9 26.10 gch->trace_heap_before_gc(_gc_tracer); 26.11 26.12 @@ -193,7 +193,7 @@ 26.13 void GenMarkSweep::mark_sweep_phase1(int level, 26.14 bool clear_all_softrefs) { 26.15 // Recursively traverse all live objects and mark them 26.16 - GCTraceTime tm("phase 1", PrintGC && Verbose, true, _gc_timer); 26.17 + GCTraceTime tm("phase 1", PrintGC && Verbose, true, _gc_timer, _gc_tracer->gc_id()); 26.18 trace(" 1"); 26.19 26.20 GenCollectedHeap* gch = GenCollectedHeap::heap(); 26.21 @@ -222,7 +222,7 @@ 26.22 ref_processor()->setup_policy(clear_all_softrefs); 26.23 const ReferenceProcessorStats& stats = 26.24 ref_processor()->process_discovered_references( 26.25 - &is_alive, &keep_alive, &follow_stack_closure, NULL, _gc_timer); 26.26 + &is_alive, &keep_alive, &follow_stack_closure, NULL, _gc_timer, _gc_tracer->gc_id()); 26.27 gc_tracer()->report_gc_reference_stats(stats); 26.28 } 26.29 26.30 @@ -264,7 +264,7 @@ 26.31 26.32 GenCollectedHeap* gch = GenCollectedHeap::heap(); 26.33 26.34 - GCTraceTime tm("phase 2", PrintGC && Verbose, true, _gc_timer); 26.35 + GCTraceTime tm("phase 2", PrintGC && Verbose, true, _gc_timer, _gc_tracer->gc_id()); 26.36 trace("2"); 26.37 26.38 gch->prepare_for_compaction(); 26.39 @@ -281,7 +281,7 @@ 26.40 GenCollectedHeap* gch = GenCollectedHeap::heap(); 26.41 26.42 // Adjust the pointers to reflect the new locations 26.43 - GCTraceTime tm("phase 3", PrintGC && Verbose, true, _gc_timer); 26.44 + GCTraceTime tm("phase 3", PrintGC && Verbose, true, _gc_timer, _gc_tracer->gc_id()); 26.45 trace("3"); 26.46 26.47 // Need new claim bits for the pointer adjustment tracing. 26.48 @@ -336,7 +336,7 @@ 26.49 // to use a higher index (saved from phase2) when verifying perm_gen. 26.50 GenCollectedHeap* gch = GenCollectedHeap::heap(); 26.51 26.52 - GCTraceTime tm("phase 4", PrintGC && Verbose, true, _gc_timer); 26.53 + GCTraceTime tm("phase 4", PrintGC && Verbose, true, _gc_timer, _gc_tracer->gc_id()); 26.54 trace("4"); 26.55 26.56 GenCompactClosure blk;
27.1 --- a/src/share/vm/memory/referenceProcessor.cpp Wed Jun 25 15:51:15 2014 -0700 27.2 +++ b/src/share/vm/memory/referenceProcessor.cpp Thu Jun 19 13:31:14 2014 +0200 27.3 @@ -190,7 +190,8 @@ 27.4 OopClosure* keep_alive, 27.5 VoidClosure* complete_gc, 27.6 AbstractRefProcTaskExecutor* task_executor, 27.7 - GCTimer* gc_timer) { 27.8 + GCTimer* gc_timer, 27.9 + GCId gc_id) { 27.10 NOT_PRODUCT(verify_ok_to_handle_reflists()); 27.11 27.12 assert(!enqueuing_is_done(), "If here enqueuing should not be complete"); 27.13 @@ -212,7 +213,7 @@ 27.14 // Soft references 27.15 size_t soft_count = 0; 27.16 { 27.17 - GCTraceTime tt("SoftReference", trace_time, false, gc_timer); 27.18 + GCTraceTime tt("SoftReference", trace_time, false, gc_timer, gc_id); 27.19 soft_count = 27.20 process_discovered_reflist(_discoveredSoftRefs, _current_soft_ref_policy, true, 27.21 is_alive, keep_alive, complete_gc, task_executor); 27.22 @@ -223,7 +224,7 @@ 27.23 // Weak references 27.24 size_t weak_count = 0; 27.25 { 27.26 - GCTraceTime tt("WeakReference", trace_time, false, gc_timer); 27.27 + GCTraceTime tt("WeakReference", trace_time, false, gc_timer, gc_id); 27.28 weak_count = 27.29 process_discovered_reflist(_discoveredWeakRefs, NULL, true, 27.30 is_alive, keep_alive, complete_gc, task_executor); 27.31 @@ -232,7 +233,7 @@ 27.32 // Final references 27.33 size_t final_count = 0; 27.34 { 27.35 - GCTraceTime tt("FinalReference", trace_time, false, gc_timer); 27.36 + GCTraceTime tt("FinalReference", trace_time, false, gc_timer, gc_id); 27.37 final_count = 27.38 process_discovered_reflist(_discoveredFinalRefs, NULL, false, 27.39 is_alive, keep_alive, complete_gc, task_executor); 27.40 @@ -241,7 +242,7 @@ 27.41 // Phantom references 27.42 size_t phantom_count = 0; 27.43 { 27.44 - GCTraceTime tt("PhantomReference", trace_time, false, gc_timer); 27.45 + GCTraceTime tt("PhantomReference", trace_time, false, gc_timer, gc_id); 27.46 phantom_count = 27.47 process_discovered_reflist(_discoveredPhantomRefs, NULL, false, 27.48 is_alive, keep_alive, complete_gc, task_executor); 27.49 @@ -253,7 +254,7 @@ 27.50 // thus use JNI weak references to circumvent the phantom references and 27.51 // resurrect a "post-mortem" object. 27.52 { 27.53 - GCTraceTime tt("JNI Weak Reference", trace_time, false, gc_timer); 27.54 + GCTraceTime tt("JNI Weak Reference", trace_time, false, gc_timer, gc_id); 27.55 if (task_executor != NULL) { 27.56 task_executor->set_single_threaded_mode(); 27.57 } 27.58 @@ -1251,14 +1252,15 @@ 27.59 OopClosure* keep_alive, 27.60 VoidClosure* complete_gc, 27.61 YieldClosure* yield, 27.62 - GCTimer* gc_timer) { 27.63 + GCTimer* gc_timer, 27.64 + GCId gc_id) { 27.65 27.66 NOT_PRODUCT(verify_ok_to_handle_reflists()); 27.67 27.68 // Soft references 27.69 { 27.70 GCTraceTime tt("Preclean SoftReferences", PrintGCDetails && PrintReferenceGC, 27.71 - false, gc_timer); 27.72 + false, gc_timer, gc_id); 27.73 for (uint i = 0; i < _max_num_q; i++) { 27.74 if (yield->should_return()) { 27.75 return; 27.76 @@ -1271,7 +1273,7 @@ 27.77 // Weak references 27.78 { 27.79 GCTraceTime tt("Preclean WeakReferences", PrintGCDetails && PrintReferenceGC, 27.80 - false, gc_timer); 27.81 + false, gc_timer, gc_id); 27.82 for (uint i = 0; i < _max_num_q; i++) { 27.83 if (yield->should_return()) { 27.84 return; 27.85 @@ -1284,7 +1286,7 @@ 27.86 // Final references 27.87 { 27.88 GCTraceTime tt("Preclean FinalReferences", PrintGCDetails && PrintReferenceGC, 27.89 - false, gc_timer); 27.90 + false, gc_timer, gc_id); 27.91 for (uint i = 0; i < _max_num_q; i++) { 27.92 if (yield->should_return()) { 27.93 return; 27.94 @@ -1297,7 +1299,7 @@ 27.95 // Phantom references 27.96 { 27.97 GCTraceTime tt("Preclean PhantomReferences", PrintGCDetails && PrintReferenceGC, 27.98 - false, gc_timer); 27.99 + false, gc_timer, gc_id); 27.100 for (uint i = 0; i < _max_num_q; i++) { 27.101 if (yield->should_return()) { 27.102 return;
28.1 --- a/src/share/vm/memory/referenceProcessor.hpp Wed Jun 25 15:51:15 2014 -0700 28.2 +++ b/src/share/vm/memory/referenceProcessor.hpp Thu Jun 19 13:31:14 2014 +0200 28.3 @@ -25,6 +25,7 @@ 28.4 #ifndef SHARE_VM_MEMORY_REFERENCEPROCESSOR_HPP 28.5 #define SHARE_VM_MEMORY_REFERENCEPROCESSOR_HPP 28.6 28.7 +#include "gc_implementation/shared/gcTrace.hpp" 28.8 #include "memory/referencePolicy.hpp" 28.9 #include "memory/referenceProcessorStats.hpp" 28.10 #include "memory/referenceType.hpp" 28.11 @@ -349,7 +350,8 @@ 28.12 OopClosure* keep_alive, 28.13 VoidClosure* complete_gc, 28.14 YieldClosure* yield, 28.15 - GCTimer* gc_timer); 28.16 + GCTimer* gc_timer, 28.17 + GCId gc_id); 28.18 28.19 // Delete entries in the discovered lists that have 28.20 // either a null referent or are not active. Such 28.21 @@ -480,7 +482,8 @@ 28.22 OopClosure* keep_alive, 28.23 VoidClosure* complete_gc, 28.24 AbstractRefProcTaskExecutor* task_executor, 28.25 - GCTimer *gc_timer); 28.26 + GCTimer *gc_timer, 28.27 + GCId gc_id); 28.28 28.29 // Enqueue references at end of GC (called by the garbage collector) 28.30 bool enqueue_discovered_references(AbstractRefProcTaskExecutor* task_executor = NULL);
29.1 --- a/src/share/vm/runtime/globals.hpp Wed Jun 25 15:51:15 2014 -0700 29.2 +++ b/src/share/vm/runtime/globals.hpp Thu Jun 19 13:31:14 2014 +0200 29.3 @@ -2287,6 +2287,9 @@ 29.4 manageable(bool, PrintGCTimeStamps, false, \ 29.5 "Print timestamps at garbage collection") \ 29.6 \ 29.7 + manageable(bool, PrintGCID, false, \ 29.8 + "Print an identifier for each garbage collection") \ 29.9 + \ 29.10 product(bool, PrintGCTaskTimeStamps, false, \ 29.11 "Print timestamps for individual gc worker thread tasks") \ 29.12 \
30.1 --- a/src/share/vm/utilities/ostream.cpp Wed Jun 25 15:51:15 2014 -0700 30.2 +++ b/src/share/vm/utilities/ostream.cpp Thu Jun 19 13:31:14 2014 +0200 30.3 @@ -24,6 +24,7 @@ 30.4 30.5 #include "precompiled.hpp" 30.6 #include "compiler/compileLog.hpp" 30.7 +#include "gc_implementation/shared/gcId.hpp" 30.8 #include "oops/oop.inline.hpp" 30.9 #include "runtime/arguments.hpp" 30.10 #include "utilities/defaultStream.hpp" 30.11 @@ -240,6 +241,14 @@ 30.12 return; 30.13 } 30.14 30.15 +void outputStream::gclog_stamp(const GCId& gc_id) { 30.16 + date_stamp(PrintGCDateStamps); 30.17 + stamp(PrintGCTimeStamps); 30.18 + if (PrintGCID) { 30.19 + print("#%u: ", gc_id.id()); 30.20 + } 30.21 +} 30.22 + 30.23 outputStream& outputStream::indent() { 30.24 while (_position < _indentation) sp(); 30.25 return *this;
31.1 --- a/src/share/vm/utilities/ostream.hpp Wed Jun 25 15:51:15 2014 -0700 31.2 +++ b/src/share/vm/utilities/ostream.hpp Thu Jun 19 13:31:14 2014 +0200 31.3 @@ -28,6 +28,7 @@ 31.4 #include "memory/allocation.hpp" 31.5 #include "runtime/timer.hpp" 31.6 31.7 +class GCId; 31.8 DEBUG_ONLY(class ResourceMark;) 31.9 31.10 // Output streams for printing 31.11 @@ -107,6 +108,7 @@ 31.12 void date_stamp(bool guard) { 31.13 date_stamp(guard, "", ": "); 31.14 } 31.15 + void gclog_stamp(const GCId& gc_id); 31.16 31.17 // portable printing of 64 bit integers 31.18 void print_jlong(jlong value);
32.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 32.2 +++ b/test/gc/logging/TestGCId.java Thu Jun 19 13:31:14 2014 +0200 32.3 @@ -0,0 +1,91 @@ 32.4 +/* 32.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 32.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 32.7 + * 32.8 + * This code is free software; you can redistribute it and/or modify it 32.9 + * under the terms of the GNU General Public License version 2 only, as 32.10 + * published by the Free Software Foundation. 32.11 + * 32.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 32.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 32.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 32.15 + * version 2 for more details (a copy is included in the LICENSE file that 32.16 + * accompanied this code). 32.17 + * 32.18 + * You should have received a copy of the GNU General Public License version 32.19 + * 2 along with this work; if not, write to the Free Software Foundation, 32.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 32.21 + * 32.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 32.23 + * or visit www.oracle.com if you need additional information or have any 32.24 + * questions. 32.25 + */ 32.26 + 32.27 +/* 32.28 + * @test TestGCId 32.29 + * @bug 8043607 32.30 + * @summary Ensure that the GCId is logged 32.31 + * @key gc 32.32 + * @library /testlibrary 32.33 + */ 32.34 + 32.35 +import com.oracle.java.testlibrary.ProcessTools; 32.36 +import com.oracle.java.testlibrary.OutputAnalyzer; 32.37 + 32.38 +public class TestGCId { 32.39 + public static void main(String[] args) throws Exception { 32.40 + testGCId("UseParallelGC", "PrintGC"); 32.41 + testGCId("UseParallelGC", "PrintGCDetails"); 32.42 + 32.43 + testGCId("UseG1GC", "PrintGC"); 32.44 + testGCId("UseG1GC", "PrintGCDetails"); 32.45 + 32.46 + testGCId("UseConcMarkSweepGC", "PrintGC"); 32.47 + testGCId("UseConcMarkSweepGC", "PrintGCDetails"); 32.48 + 32.49 + testGCId("UseSerialGC", "PrintGC"); 32.50 + testGCId("UseSerialGC", "PrintGCDetails"); 32.51 + } 32.52 + 32.53 + private static void verifyContainsGCIDs(OutputAnalyzer output) { 32.54 + output.shouldMatch("^#0: \\["); 32.55 + output.shouldMatch("^#1: \\["); 32.56 + output.shouldHaveExitValue(0); 32.57 + } 32.58 + 32.59 + private static void verifyContainsNoGCIDs(OutputAnalyzer output) { 32.60 + output.shouldNotMatch("^#[0-9]+: \\["); 32.61 + output.shouldHaveExitValue(0); 32.62 + } 32.63 + 32.64 + private static void testGCId(String gcFlag, String logFlag) throws Exception { 32.65 + // GCID logging enabled 32.66 + ProcessBuilder pb_enabled = 32.67 + ProcessTools.createJavaProcessBuilder("-XX:+" + gcFlag, "-XX:+" + logFlag, "-Xmx10M", "-XX:+PrintGCID", GCTest.class.getName()); 32.68 + verifyContainsGCIDs(new OutputAnalyzer(pb_enabled.start())); 32.69 + 32.70 + // GCID logging disabled 32.71 + ProcessBuilder pb_disabled = 32.72 + ProcessTools.createJavaProcessBuilder("-XX:+" + gcFlag, "-XX:+" + logFlag, "-Xmx10M", "-XX:-PrintGCID", GCTest.class.getName()); 32.73 + verifyContainsNoGCIDs(new OutputAnalyzer(pb_disabled.start())); 32.74 + 32.75 + // GCID logging default 32.76 + ProcessBuilder pb_default = 32.77 + ProcessTools.createJavaProcessBuilder("-XX:+" + gcFlag, "-XX:+" + logFlag, "-Xmx10M", GCTest.class.getName()); 32.78 + verifyContainsGCIDs(new OutputAnalyzer(pb_default.start())); 32.79 + } 32.80 + 32.81 + static class GCTest { 32.82 + private static byte[] garbage; 32.83 + public static void main(String [] args) { 32.84 + System.out.println("Creating garbage"); 32.85 + // create 128MB of garbage. This should result in at least one GC 32.86 + for (int i = 0; i < 1024; i++) { 32.87 + garbage = new byte[128 * 1024]; 32.88 + } 32.89 + // do a system gc to get one more gc 32.90 + System.gc(); 32.91 + System.out.println("Done"); 32.92 + } 32.93 + } 32.94 +}