8134953: Make the GC ID available in a central place

Reviewed-by: pliden, jmasa
This commit is contained in:
Bengt Rutisson 2015-09-30 09:07:21 +02:00
parent d516b42238
commit 003892f897
41 changed files with 253 additions and 291 deletions

View file

@ -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 GCId GCId::undefined() {
return GCId(UNDEFINED);
const uint GCId::current() {
assert(currentNamedthread()->gc_id() != undefined(), "Using undefined GC id.");
return current_raw();
}
bool GCId::is_undefined() const {
return _id == UNDEFINED;
const uint GCId::current_raw() {
return currentNamedthread()->gc_id();
}
GCIdMark::GCIdMark() : _gc_id(GCId::create()) {
currentNamedthread()->set_gc_id(_gc_id);
}
GCIdMark::GCIdMark(uint gc_id) : _gc_id(gc_id) {
currentNamedthread()->set_gc_id(_gc_id);
}
GCIdMark::~GCIdMark() {
currentNamedthread()->set_gc_id(GCId::undefined());
}