< prev index next >

src/hotspot/share/classfile/classLoaderDataGraph.cpp

Print this page




 292 
 293 LockedClassesDo::LockedClassesDo() : _function(NULL) {
 294   // callers provide their own do_klass
 295   ClassLoaderDataGraph_lock->lock();
 296 }
 297 
 298 LockedClassesDo::~LockedClassesDo() { ClassLoaderDataGraph_lock->unlock(); }
 299 
 300 
 301 // Iterating over the CLDG needs to be locked because
 302 // unloading can remove entries concurrently soon.
 303 class ClassLoaderDataGraphIterator : public StackObj {
 304   ClassLoaderData* _next;
 305   HandleMark       _hm;  // clean up handles when this is done.
 306   Handle           _holder;
 307   Thread*          _thread;
 308   NoSafepointVerifier _nsv; // No safepoints allowed in this scope
 309                             // unless verifying at a safepoint.
 310 
 311 public:
 312   ClassLoaderDataGraphIterator() : _next(ClassLoaderDataGraph::_head),
 313      _nsv(true, !SafepointSynchronize::is_at_safepoint()) {
 314     _thread = Thread::current();
 315     assert_locked_or_safepoint(ClassLoaderDataGraph_lock);
 316   }
 317 
 318   ClassLoaderData* get_next() {
 319     ClassLoaderData* cld = _next;
 320     // Skip already unloaded CLD for concurrent unloading.
 321     while (cld != NULL && !cld->is_alive()) {
 322       cld = cld->next();
 323     }
 324     if (cld != NULL) {
 325       // Keep cld that is being returned alive.
 326       _holder = Handle(_thread, cld->holder_phantom());
 327       _next = cld->next();
 328     } else {
 329       _next = NULL;
 330     }
 331     return cld;
 332   }
 333 };




 292 
 293 LockedClassesDo::LockedClassesDo() : _function(NULL) {
 294   // callers provide their own do_klass
 295   ClassLoaderDataGraph_lock->lock();
 296 }
 297 
 298 LockedClassesDo::~LockedClassesDo() { ClassLoaderDataGraph_lock->unlock(); }
 299 
 300 
 301 // Iterating over the CLDG needs to be locked because
 302 // unloading can remove entries concurrently soon.
 303 class ClassLoaderDataGraphIterator : public StackObj {
 304   ClassLoaderData* _next;
 305   HandleMark       _hm;  // clean up handles when this is done.
 306   Handle           _holder;
 307   Thread*          _thread;
 308   NoSafepointVerifier _nsv; // No safepoints allowed in this scope
 309                             // unless verifying at a safepoint.
 310 
 311 public:
 312   ClassLoaderDataGraphIterator() : _next(ClassLoaderDataGraph::_head) {

 313     _thread = Thread::current();
 314     assert_locked_or_safepoint(ClassLoaderDataGraph_lock);
 315   }
 316 
 317   ClassLoaderData* get_next() {
 318     ClassLoaderData* cld = _next;
 319     // Skip already unloaded CLD for concurrent unloading.
 320     while (cld != NULL && !cld->is_alive()) {
 321       cld = cld->next();
 322     }
 323     if (cld != NULL) {
 324       // Keep cld that is being returned alive.
 325       _holder = Handle(_thread, cld->holder_phantom());
 326       _next = cld->next();
 327     } else {
 328       _next = NULL;
 329     }
 330     return cld;
 331   }
 332 };


< prev index next >