< prev index next >

src/share/vm/gc/shared/gcId.cpp

Print this page

        

@@ -22,40 +22,30 @@
  *
  */
 
 #include "precompiled.hpp"
 #include "gc/shared/gcId.hpp"
-#include "runtime/safepoint.hpp"
-#include "runtime/thread.inline.hpp"
 
 uint GCId::_next_id = 0;
-
-NamedThread* currentNamedthread() {
-  assert(Thread::current()->is_Named_thread(), "This thread must be NamedThread");
-  return (NamedThread*)Thread::current();
-}
+uint GCId::_current_id = UNDEFINED;
 
 const uint GCId::create() {
   return _next_id++;
 }
 
 const uint GCId::current() {
-  assert(currentNamedthread()->gc_id() != undefined(), "Using undefined GC id.");
-  return current_raw();
-}
-
-const uint GCId::current_raw() {
-  return currentNamedthread()->gc_id();
-}
-
-GCIdMark::GCIdMark() : _gc_id(GCId::create()) {
-  currentNamedthread()->set_gc_id(_gc_id);
+  assert(_current_id != UNDEFINED, "Using undefined GC ID");
+  return _current_id;
 }
 
-GCIdMark::GCIdMark(uint gc_id) : _gc_id(gc_id) {
-  currentNamedthread()->set_gc_id(_gc_id);
+GCIdMark::GCIdMark() {
+  _previous_gc_id = GCId::_current_id;
+  uint gc_id = GCId::create();
+  GCId::set_current(gc_id);
+  DEBUG_ONLY(_gc_id = gc_id;)
 }
 
 GCIdMark::~GCIdMark() {
-  currentNamedthread()->set_gc_id(GCId::undefined());
+  assert(_gc_id == GCId::_current_id, err_msg("GCIdMarks for %u and %u overlap.", _gc_id, GCId::_current_id));
+  GCId::set_current(_previous_gc_id);
 }
 
< prev index next >