diff -r 20c533b9e167 -r 77bf0d2069a3 hotspot/src/share/vm/gc/shared/gcId.cpp --- a/hotspot/src/share/vm/gc/shared/gcId.cpp Tue Sep 29 17:44:58 2015 +0200 +++ b/hotspot/src/share/vm/gc/shared/gcId.cpp Wed Sep 30 09:07:21 2015 +0200 @@ -25,18 +25,37 @@ #include "precompiled.hpp" #include "gc/shared/gcId.hpp" #include "runtime/safepoint.hpp" +#include "runtime/thread.inline.hpp" uint GCId::_next_id = 0; -const GCId GCId::create() { - return GCId(_next_id++); +NamedThread* currentNamedthread() { + assert(Thread::current()->is_Named_thread(), "This thread must be NamedThread"); + return (NamedThread*)Thread::current(); } -const GCId GCId::peek() { - return GCId(_next_id); + +const uint GCId::create() { + return _next_id++; +} + +const uint GCId::current() { + assert(currentNamedthread()->gc_id() != undefined(), "Using undefined GC id."); + return current_raw(); } -const GCId GCId::undefined() { - return GCId(UNDEFINED); + +const uint GCId::current_raw() { + return currentNamedthread()->gc_id(); +} + +GCIdMark::GCIdMark() : _gc_id(GCId::create()) { + currentNamedthread()->set_gc_id(_gc_id); } -bool GCId::is_undefined() const { - return _id == UNDEFINED; + +GCIdMark::GCIdMark(uint gc_id) : _gc_id(gc_id) { + currentNamedthread()->set_gc_id(_gc_id); } + +GCIdMark::~GCIdMark() { + currentNamedthread()->set_gc_id(GCId::undefined()); +} +