hotspot/src/share/vm/classfile/classLoaderData.cpp
changeset 38014 8731fa11f766
parent 37415 35df58edb348
child 38151 fffedc5e5cf8
equal deleted inserted replaced
38013:89b93eb018fb 38014:8731fa11f766
    82   _class_loader(h_class_loader()),
    82   _class_loader(h_class_loader()),
    83   _is_anonymous(is_anonymous),
    83   _is_anonymous(is_anonymous),
    84   // An anonymous class loader data doesn't have anything to keep
    84   // An anonymous class loader data doesn't have anything to keep
    85   // it from being unloaded during parsing of the anonymous class.
    85   // it from being unloaded during parsing of the anonymous class.
    86   // The null-class-loader should always be kept alive.
    86   // The null-class-loader should always be kept alive.
    87   _keep_alive(is_anonymous || h_class_loader.is_null()),
    87   _keep_alive((is_anonymous || h_class_loader.is_null()) ? 1 : 0),
    88   _metaspace(NULL), _unloading(false), _klasses(NULL),
    88   _metaspace(NULL), _unloading(false), _klasses(NULL),
    89   _modules(NULL), _packages(NULL),
    89   _modules(NULL), _packages(NULL),
    90   _claimed(0), _jmethod_ids(NULL), _handles(NULL), _deallocate_list(NULL),
    90   _claimed(0), _jmethod_ids(NULL), _handles(NULL), _deallocate_list(NULL),
    91   _next(NULL), _dependencies(dependencies), _shared_class_loader_id(-1),
    91   _next(NULL), _dependencies(dependencies), _shared_class_loader_id(-1),
    92   _metaspace_lock(new Mutex(Monitor::leaf+1, "Metaspace allocation lock", true,
    92   _metaspace_lock(new Mutex(Monitor::leaf+1, "Metaspace allocation lock", true,
   110   if (_claimed == 1) {
   110   if (_claimed == 1) {
   111     return false;
   111     return false;
   112   }
   112   }
   113 
   113 
   114   return (int) Atomic::cmpxchg(1, &_claimed, 0) == 0;
   114   return (int) Atomic::cmpxchg(1, &_claimed, 0) == 0;
       
   115 }
       
   116 
       
   117 // Anonymous classes have their own ClassLoaderData that is marked to keep alive
       
   118 // while the class is being parsed, and if the class appears on the module fixup list.
       
   119 // Due to the uniqueness that no other class shares the anonymous class' name or
       
   120 // ClassLoaderData, no other non-GC thread has knowledge of the anonymous class while
       
   121 // it is being defined, therefore _keep_alive is not volatile or atomic.
       
   122 void ClassLoaderData::inc_keep_alive() {
       
   123   assert(_keep_alive >= 0, "Invalid keep alive count");
       
   124   _keep_alive++;
       
   125 }
       
   126 
       
   127 void ClassLoaderData::dec_keep_alive() {
       
   128   assert(_keep_alive > 0, "Invalid keep alive count");
       
   129   _keep_alive--;
   115 }
   130 }
   116 
   131 
   117 void ClassLoaderData::oops_do(OopClosure* f, KlassClosure* klass_closure, bool must_claim) {
   132 void ClassLoaderData::oops_do(OopClosure* f, KlassClosure* klass_closure, bool must_claim) {
   118   if (must_claim && !claim()) {
   133   if (must_claim && !claim()) {
   119     return;
   134     return;