hotspot/src/share/vm/gc/shared/gcId.cpp
changeset 35061 be6025ebffea
parent 33229 51173444fdd5
child 35227 176e593eb364
--- a/hotspot/src/share/vm/gc/shared/gcId.cpp	Thu Dec 10 23:02:31 2015 +0000
+++ b/hotspot/src/share/vm/gc/shared/gcId.cpp	Thu Dec 10 14:57:55 2015 +0100
@@ -26,6 +26,7 @@
 #include "gc/shared/gcId.hpp"
 #include "runtime/safepoint.hpp"
 #include "runtime/thread.inline.hpp"
+#include "runtime/threadLocalStorage.hpp"
 
 uint GCId::_next_id = 0;
 
@@ -47,6 +48,18 @@
   return currentNamedthread()->gc_id();
 }
 
+size_t GCId::print_prefix(char* buf, size_t len) {
+  if (ThreadLocalStorage::is_initialized() && ThreadLocalStorage::thread()->is_Named_thread()) {
+    uint gc_id = current_raw();
+    if (gc_id != undefined()) {
+      int ret = jio_snprintf(buf, len, "GC(%u) ", gc_id);
+      assert(ret > 0, "Failed to print prefix. Log buffer too small?");
+      return (size_t)ret;
+    }
+  }
+  return 0;
+}
+
 GCIdMark::GCIdMark() : _gc_id(GCId::create()) {
   currentNamedthread()->set_gc_id(_gc_id);
 }