comparison src/share/vm/gc/shared/gcId.cpp @ 9396:983c56341c80

8134953: Make the GC ID available in a central place Reviewed-by: pliden, jmasa
author brutisso
date Wed, 30 Sep 2015 09:07:21 +0200
parents 92457dfb91bd
children e3b180765091
comparison
equal deleted inserted replaced
0:8ac44b736435 1:174f7a0ec694
23 */ 23 */
24 24
25 #include "precompiled.hpp" 25 #include "precompiled.hpp"
26 #include "gc/shared/gcId.hpp" 26 #include "gc/shared/gcId.hpp"
27 #include "runtime/safepoint.hpp" 27 #include "runtime/safepoint.hpp"
28 #include "runtime/thread.inline.hpp"
28 29
29 uint GCId::_next_id = 0; 30 uint GCId::_next_id = 0;
30 31
31 const GCId GCId::create() { 32 NamedThread* currentNamedthread() {
32 return GCId(_next_id++); 33 assert(Thread::current()->is_Named_thread(), "This thread must be NamedThread");
34 return (NamedThread*)Thread::current();
33 } 35 }
34 const GCId GCId::peek() { 36
35 return GCId(_next_id); 37 const uint GCId::create() {
38 return _next_id++;
36 } 39 }
37 const GCId GCId::undefined() { 40
38 return GCId(UNDEFINED); 41 const uint GCId::current() {
42 assert(currentNamedthread()->gc_id() != undefined(), "Using undefined GC id.");
43 return current_raw();
39 } 44 }
40 bool GCId::is_undefined() const { 45
41 return _id == UNDEFINED; 46 const uint GCId::current_raw() {
47 return currentNamedthread()->gc_id();
42 } 48 }
49
50 GCIdMark::GCIdMark() : _gc_id(GCId::create()) {
51 currentNamedthread()->set_gc_id(_gc_id);
52 }
53
54 GCIdMark::GCIdMark(uint gc_id) : _gc_id(gc_id) {
55 currentNamedthread()->set_gc_id(_gc_id);
56 }
57
58 GCIdMark::~GCIdMark() {
59 currentNamedthread()->set_gc_id(GCId::undefined());
60 }
61