< prev index next >
src/share/vm/gc/shared/gcId.cpp
Print this page
*** 24,33 ****
--- 24,34 ----
#include "precompiled.hpp"
#include "gc/shared/gcId.hpp"
#include "runtime/safepoint.hpp"
#include "runtime/thread.inline.hpp"
+ #include "runtime/threadLocalStorage.hpp"
uint GCId::_next_id = 0;
NamedThread* currentNamedthread() {
assert(Thread::current()->is_Named_thread(), "This thread must be NamedThread");
*** 45,54 ****
--- 46,68 ----
const uint GCId::current_raw() {
return currentNamedthread()->gc_id();
}
+ size_t GCId::print_prefix(char* buf, size_t len) {
+ Thread* thread = ThreadLocalStorage::thread();
+ if (thread != NULL && 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);
}
GCIdMark::GCIdMark(uint gc_id) : _gc_id(gc_id) {
< prev index next >