< prev index next >

src/hotspot/share/classfile/classLoaderData.cpp

Print this page




  81 #if INCLUDE_TRACE
  82 #include "trace/tracing.hpp"
  83 #endif
  84 
  85 // helper function to avoid in-line casts
  86 template <typename T> static T* load_ptr_acquire(T* volatile *p) {
  87   return static_cast<T*>(OrderAccess::load_ptr_acquire(p));
  88 }
  89 
  90 ClassLoaderData * ClassLoaderData::_the_null_class_loader_data = NULL;
  91 
  92 ClassLoaderData::ClassLoaderData(Handle h_class_loader, bool is_anonymous, Dependencies dependencies) :
  93   _class_loader(h_class_loader()),
  94   _is_anonymous(is_anonymous),
  95   // An anonymous class loader data doesn't have anything to keep
  96   // it from being unloaded during parsing of the anonymous class.
  97   // The null-class-loader should always be kept alive.
  98   _keep_alive((is_anonymous || h_class_loader.is_null()) ? 1 : 0),
  99   _metaspace(NULL), _unloading(false), _klasses(NULL),
 100   _modules(NULL), _packages(NULL),
 101   _claimed(0), _jmethod_ids(NULL), _handles(), _deallocate_list(NULL),
 102   _next(NULL), _dependencies(dependencies),
 103   _metaspace_lock(new Mutex(Monitor::leaf+1, "Metaspace allocation lock", true,
 104                             Monitor::_safepoint_check_never)) {
 105 
 106   // A ClassLoaderData created solely for an anonymous class should never have a
 107   // ModuleEntryTable or PackageEntryTable created for it. The defining package
 108   // and module for an anonymous class will be found in its host class.
 109   if (!is_anonymous) {
 110     _packages = new PackageEntryTable(PackageEntryTable::_packagetable_entry_size);
 111     if (h_class_loader.is_null()) {
 112       // Create unnamed module for boot loader
 113       _unnamed_module = ModuleEntry::create_boot_unnamed_module(this);
 114     } else {
 115       // Create unnamed module for all other loaders
 116       _unnamed_module = ModuleEntry::create_unnamed_module(this);
 117     }
 118   } else {
 119     _unnamed_module = NULL;
 120   }
 121 


 190     if (p == _target) {
 191       _found = true;
 192     }
 193   }
 194 
 195   void do_oop(narrowOop* p) {
 196     // The ChunkedHandleList should not contain any narrowOop
 197     ShouldNotReachHere();
 198   }
 199 
 200   bool found() const {
 201     return _found;
 202   }
 203 };
 204 
 205 bool ClassLoaderData::ChunkedHandleList::contains(oop* p) {
 206   VerifyContainsOopClosure cl(p);
 207   oops_do(&cl);
 208   return cl.found();
 209 }
 210 #endif
 211 
 212 bool ClassLoaderData::claim() {
 213   if (_claimed == 1) {
 214     return false;
 215   }
 216 
 217   return (int) Atomic::cmpxchg(1, &_claimed, 0) == 0;
 218 }
 219 
 220 // Anonymous classes have their own ClassLoaderData that is marked to keep alive
 221 // while the class is being parsed, and if the class appears on the module fixup list.
 222 // Due to the uniqueness that no other class shares the anonymous class' name or
 223 // ClassLoaderData, no other non-GC thread has knowledge of the anonymous class while
 224 // it is being defined, therefore _keep_alive is not volatile or atomic.
 225 void ClassLoaderData::inc_keep_alive() {
 226   if (is_anonymous()) {
 227     assert(_keep_alive >= 0, "Invalid keep alive increment count");
 228     _keep_alive++;
 229   }
 230 }
 231 
 232 void ClassLoaderData::dec_keep_alive() {
 233   if (is_anonymous()) {
 234     assert(_keep_alive > 0, "Invalid keep alive decrement count");
 235     _keep_alive--;
 236   }
 237 }
 238 
 239 void ClassLoaderData::oops_do(OopClosure* f, KlassClosure* klass_closure, bool must_claim) {
 240   if (must_claim && !claim()) {
 241     return;
 242   }
 243 





 244   f->do_oop(&_class_loader);
 245   _dependencies.oops_do(f);
 246 
 247   _handles.oops_do(f);
 248 
 249   if (klass_closure != NULL) {
 250     classes_do(klass_closure);
 251   }
 252 }
 253 
 254 void ClassLoaderData::Dependencies::oops_do(OopClosure* f) {
 255   f->do_oop((oop*)&_list_head);
 256 }
 257 
 258 void ClassLoaderData::classes_do(KlassClosure* klass_closure) {
 259   // Lock-free access requires load_ptr_acquire
 260   for (Klass* k = load_ptr_acquire(&_klasses); k != NULL; k = k->next_link()) {
 261     klass_closure->do_klass(k);
 262     assert(k != k->next_link(), "no loops!");
 263   }
 264 }
 265 
 266 void ClassLoaderData::classes_do(void f(Klass * const)) {
 267   // Lock-free access requires load_ptr_acquire
 268   for (Klass* k = load_ptr_acquire(&_klasses); k != NULL; k = k->next_link()) {
 269     f(k);
 270     assert(k != k->next_link(), "no loops!");
 271   }


 351     // If from_cld is anonymous, even if it's class_loader is a parent of 'to'
 352     // we still have to add it.  The class_loader won't keep from_cld alive.
 353     if (!from_cld->is_anonymous()) {
 354       // Check that this dependency isn't from the same or parent class_loader
 355       oop from = from_cld->class_loader();
 356 
 357       oop curr = from;
 358       while (curr != NULL) {
 359         if (curr == to) {
 360           return; // this class loader is in the parent list, no need to add it.
 361         }
 362         curr = java_lang_ClassLoader::parent(curr);
 363       }
 364     }
 365   }
 366 
 367   // It's a dependency we won't find through GC, add it. This is relatively rare
 368   // Must handle over GC point.
 369   Handle dependency(THREAD, to);
 370   from_cld->_dependencies.add(dependency, CHECK);



 371 }
 372 
 373 
 374 void ClassLoaderData::Dependencies::add(Handle dependency, TRAPS) {
 375   // Check first if this dependency is already in the list.
 376   // Save a pointer to the last to add to under the lock.
 377   objArrayOop ok = _list_head;
 378   objArrayOop last = NULL;
 379   while (ok != NULL) {
 380     last = ok;
 381     if (ok->obj_at(0) == dependency()) {
 382       // Don't need to add it
 383       return;
 384     }
 385     ok = (objArrayOop)ok->obj_at(1);
 386   }
 387 
 388   // Must handle over GC points
 389   assert (last != NULL, "dependencies should be initialized");
 390   objArrayHandle last_handle(THREAD, last);


 747           log_trace(class, loader, data)("is_anonymous: %s", class_loader()->klass()->internal_name());
 748         }
 749         metaspace = new Metaspace(_metaspace_lock, Metaspace::AnonymousMetaspaceType);
 750       } else if (class_loader()->is_a(SystemDictionary::reflect_DelegatingClassLoader_klass())) {
 751         if (class_loader() != NULL) {
 752           log_trace(class, loader, data)("is_reflection: %s", class_loader()->klass()->internal_name());
 753         }
 754         metaspace = new Metaspace(_metaspace_lock, Metaspace::ReflectionMetaspaceType);
 755       } else {
 756         metaspace = new Metaspace(_metaspace_lock, Metaspace::StandardMetaspaceType);
 757       }
 758       // Ensure _metaspace is stable, since it is examined without a lock
 759       OrderAccess::release_store_ptr(&_metaspace, metaspace);
 760     }
 761   }
 762   return metaspace;
 763 }
 764 
 765 OopHandle ClassLoaderData::add_handle(Handle h) {
 766   MutexLockerEx ml(metaspace_lock(),  Mutex::_no_safepoint_check_flag);

 767   return OopHandle(_handles.add(h()));
 768 }
 769 
 770 void ClassLoaderData::remove_handle(OopHandle h) {
 771   oop* ptr = h.ptr_raw();
 772   if (ptr != NULL) {
 773     assert(_handles.contains(ptr), "Got unexpected handle " PTR_FORMAT, p2i(ptr));
 774 #if INCLUDE_ALL_GCS
 775     // This barrier is used by G1 to remember the old oop values, so
 776     // that we don't forget any objects that were live at the snapshot at
 777     // the beginning.
 778     if (UseG1GC) {
 779       oop obj = *ptr;
 780       if (obj != NULL) {
 781         G1SATBCardTableModRefBS::enqueue(obj);
 782       }
 783     }

 784 #endif
 785     *ptr = NULL;
 786   }
 787 }
 788 
 789 void ClassLoaderData::init_handle_locked(OopHandle& dest, Handle h) {
 790   MutexLockerEx ml(metaspace_lock(),  Mutex::_no_safepoint_check_flag);
 791   if (dest.resolve() != NULL) {
 792     return;
 793   } else {
 794     dest = _handles.add(h());
 795   }
 796 }
 797 
 798 // Add this metadata pointer to be freed when it's safe.  This is only during
 799 // class unloading because Handles might point to this metadata field.
 800 void ClassLoaderData::add_to_deallocate_list(Metadata* m) {
 801   // Metadata in shared region isn't deleted.
 802   if (!m->is_shared()) {
 803     MutexLockerEx ml(metaspace_lock(),  Mutex::_no_safepoint_check_flag);


 858 #undef CLD_DUMP_KLASSES
 859 
 860 void ClassLoaderData::dump(outputStream * const out) {
 861   out->print("ClassLoaderData CLD: " PTR_FORMAT ", loader: " PTR_FORMAT ", loader_klass: " PTR_FORMAT " %s {",
 862       p2i(this), p2i((void *)class_loader()),
 863       p2i(class_loader() != NULL ? class_loader()->klass() : NULL), loader_name());
 864   if (claimed()) out->print(" claimed ");
 865   if (is_unloading()) out->print(" unloading ");
 866   out->cr();
 867   if (metaspace_or_null() != NULL) {
 868     out->print_cr("metaspace: " INTPTR_FORMAT, p2i(metaspace_or_null()));
 869     metaspace_or_null()->dump(out);
 870   } else {
 871     out->print_cr("metaspace: NULL");
 872   }
 873 
 874 #ifdef CLD_DUMP_KLASSES
 875   if (Verbose) {
 876     Klass* k = _klasses;
 877     while (k != NULL) {
 878       out->print_cr("klass " PTR_FORMAT ", %s, CT: %d, MUT: %d", k, k->name()->as_C_string(),
 879           k->has_modified_oops(), k->has_accumulated_modified_oops());
 880       assert(k != k->next_link(), "no loops!");
 881       k = k->next_link();
 882     }
 883   }
 884 #endif  // CLD_DUMP_KLASSES
 885 #undef CLD_DUMP_KLASSES
 886   if (_jmethod_ids != NULL) {
 887     Method::print_jmethod_ids(this, out);
 888   }
 889   out->print_cr("}");
 890 }
 891 #endif // PRODUCT
 892 
 893 void ClassLoaderData::verify() {
 894   assert_locked_or_safepoint(_metaspace_lock);
 895   oop cl = class_loader();
 896 
 897   guarantee(this == class_loader_data(cl) || is_anonymous(), "Must be the same");
 898   guarantee(cl != NULL || this == ClassLoaderData::the_null_class_loader_data() || is_anonymous(), "must be");
 899 


 986                             vmSymbols::toString_name(),
 987                             vmSymbols::void_string_signature(),
 988                             CHECK);
 989     assert(result.get_type() == T_OBJECT, "just checking");
 990     string = Handle(THREAD, (oop)result.get_jobject());
 991   }
 992 
 993   ResourceMark rm;
 994   out->print("create class loader data " INTPTR_FORMAT, p2i(cld));
 995   out->print(" for instance " INTPTR_FORMAT " of %s", p2i((void *)cld->class_loader()),
 996              cld->loader_name());
 997 
 998   if (string.not_null()) {
 999     out->print(": ");
1000     java_lang_String::print(string(), out);
1001   }
1002   out->cr();
1003 }
1004 
1005 
1006 void ClassLoaderDataGraph::oops_do(OopClosure* f, KlassClosure* klass_closure, bool must_claim) {
1007   for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) {
1008     cld->oops_do(f, klass_closure, must_claim);
1009   }
1010 }
1011 
1012 void ClassLoaderDataGraph::keep_alive_oops_do(OopClosure* f, KlassClosure* klass_closure, bool must_claim) {
1013   for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) {
1014     if (cld->keep_alive()) {
1015       cld->oops_do(f, klass_closure, must_claim);
1016     }
1017   }
1018 }
1019 
1020 void ClassLoaderDataGraph::always_strong_oops_do(OopClosure* f, KlassClosure* klass_closure, bool must_claim) {
1021   if (ClassUnloading) {
1022     keep_alive_oops_do(f, klass_closure, must_claim);
1023   } else {
1024     oops_do(f, klass_closure, must_claim);
1025   }
1026 }
1027 
1028 void ClassLoaderDataGraph::cld_do(CLDClosure* cl) {
1029   for (ClassLoaderData* cld = _head; cl != NULL && cld != NULL; cld = cld->next()) {
1030     cl->do_cld(cld);
1031   }
1032 }
1033 
1034 void ClassLoaderDataGraph::cld_unloading_do(CLDClosure* cl) {
1035   assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint!");
1036   // Only walk the head until any clds not purged from prior unloading
1037   // (CMS doesn't purge right away).
1038   for (ClassLoaderData* cld = _unloading; cld != _saved_unloading; cld = cld->next()) {
1039     assert(cld->is_unloading(), "invariant");
1040     cl->do_cld(cld);
1041   }
1042 }
1043 
1044 void ClassLoaderDataGraph::roots_cld_do(CLDClosure* strong, CLDClosure* weak) {




  81 #if INCLUDE_TRACE
  82 #include "trace/tracing.hpp"
  83 #endif
  84 
  85 // helper function to avoid in-line casts
  86 template <typename T> static T* load_ptr_acquire(T* volatile *p) {
  87   return static_cast<T*>(OrderAccess::load_ptr_acquire(p));
  88 }
  89 
  90 ClassLoaderData * ClassLoaderData::_the_null_class_loader_data = NULL;
  91 
  92 ClassLoaderData::ClassLoaderData(Handle h_class_loader, bool is_anonymous, Dependencies dependencies) :
  93   _class_loader(h_class_loader()),
  94   _is_anonymous(is_anonymous),
  95   // An anonymous class loader data doesn't have anything to keep
  96   // it from being unloaded during parsing of the anonymous class.
  97   // The null-class-loader should always be kept alive.
  98   _keep_alive((is_anonymous || h_class_loader.is_null()) ? 1 : 0),
  99   _metaspace(NULL), _unloading(false), _klasses(NULL),
 100   _modules(NULL), _packages(NULL),
 101   _claimed(0), _modified_oops(1), _jmethod_ids(NULL), _handles(), _deallocate_list(NULL),
 102   _next(NULL), _dependencies(dependencies),
 103   _metaspace_lock(new Mutex(Monitor::leaf+1, "Metaspace allocation lock", true,
 104                             Monitor::_safepoint_check_never)) {
 105 
 106   // A ClassLoaderData created solely for an anonymous class should never have a
 107   // ModuleEntryTable or PackageEntryTable created for it. The defining package
 108   // and module for an anonymous class will be found in its host class.
 109   if (!is_anonymous) {
 110     _packages = new PackageEntryTable(PackageEntryTable::_packagetable_entry_size);
 111     if (h_class_loader.is_null()) {
 112       // Create unnamed module for boot loader
 113       _unnamed_module = ModuleEntry::create_boot_unnamed_module(this);
 114     } else {
 115       // Create unnamed module for all other loaders
 116       _unnamed_module = ModuleEntry::create_unnamed_module(this);
 117     }
 118   } else {
 119     _unnamed_module = NULL;
 120   }
 121 


 190     if (p == _target) {
 191       _found = true;
 192     }
 193   }
 194 
 195   void do_oop(narrowOop* p) {
 196     // The ChunkedHandleList should not contain any narrowOop
 197     ShouldNotReachHere();
 198   }
 199 
 200   bool found() const {
 201     return _found;
 202   }
 203 };
 204 
 205 bool ClassLoaderData::ChunkedHandleList::contains(oop* p) {
 206   VerifyContainsOopClosure cl(p);
 207   oops_do(&cl);
 208   return cl.found();
 209 }
 210 #endif // ASSERT
 211 
 212 bool ClassLoaderData::claim() {
 213   if (_claimed == 1) {
 214     return false;
 215   }
 216 
 217   return (int) Atomic::cmpxchg(1, &_claimed, 0) == 0;
 218 }
 219 
 220 // Anonymous classes have their own ClassLoaderData that is marked to keep alive
 221 // while the class is being parsed, and if the class appears on the module fixup list.
 222 // Due to the uniqueness that no other class shares the anonymous class' name or
 223 // ClassLoaderData, no other non-GC thread has knowledge of the anonymous class while
 224 // it is being defined, therefore _keep_alive is not volatile or atomic.
 225 void ClassLoaderData::inc_keep_alive() {
 226   if (is_anonymous()) {
 227     assert(_keep_alive >= 0, "Invalid keep alive increment count");
 228     _keep_alive++;
 229   }
 230 }
 231 
 232 void ClassLoaderData::dec_keep_alive() {
 233   if (is_anonymous()) {
 234     assert(_keep_alive > 0, "Invalid keep alive decrement count");
 235     _keep_alive--;
 236   }
 237 }
 238 
 239 void ClassLoaderData::oops_do(OopClosure* f, bool must_claim, bool clear_mod_oops) {
 240   if (must_claim && !claim()) {
 241     return;
 242   }
 243 
 244   // Only clear modified_oops after the ClassLoaderData is claimed.
 245   if (clear_mod_oops) {
 246     clear_modified_oops();
 247   }
 248 
 249   f->do_oop(&_class_loader);
 250   _dependencies.oops_do(f);

 251   _handles.oops_do(f);




 252 }
 253 
 254 void ClassLoaderData::Dependencies::oops_do(OopClosure* f) {
 255   f->do_oop((oop*)&_list_head);
 256 }
 257 
 258 void ClassLoaderData::classes_do(KlassClosure* klass_closure) {
 259   // Lock-free access requires load_ptr_acquire
 260   for (Klass* k = load_ptr_acquire(&_klasses); k != NULL; k = k->next_link()) {
 261     klass_closure->do_klass(k);
 262     assert(k != k->next_link(), "no loops!");
 263   }
 264 }
 265 
 266 void ClassLoaderData::classes_do(void f(Klass * const)) {
 267   // Lock-free access requires load_ptr_acquire
 268   for (Klass* k = load_ptr_acquire(&_klasses); k != NULL; k = k->next_link()) {
 269     f(k);
 270     assert(k != k->next_link(), "no loops!");
 271   }


 351     // If from_cld is anonymous, even if it's class_loader is a parent of 'to'
 352     // we still have to add it.  The class_loader won't keep from_cld alive.
 353     if (!from_cld->is_anonymous()) {
 354       // Check that this dependency isn't from the same or parent class_loader
 355       oop from = from_cld->class_loader();
 356 
 357       oop curr = from;
 358       while (curr != NULL) {
 359         if (curr == to) {
 360           return; // this class loader is in the parent list, no need to add it.
 361         }
 362         curr = java_lang_ClassLoader::parent(curr);
 363       }
 364     }
 365   }
 366 
 367   // It's a dependency we won't find through GC, add it. This is relatively rare
 368   // Must handle over GC point.
 369   Handle dependency(THREAD, to);
 370   from_cld->_dependencies.add(dependency, CHECK);
 371 
 372   // Added a potentially young gen oop to the ClassLoaderData
 373   record_modified_oops();
 374 }
 375 
 376 
 377 void ClassLoaderData::Dependencies::add(Handle dependency, TRAPS) {
 378   // Check first if this dependency is already in the list.
 379   // Save a pointer to the last to add to under the lock.
 380   objArrayOop ok = _list_head;
 381   objArrayOop last = NULL;
 382   while (ok != NULL) {
 383     last = ok;
 384     if (ok->obj_at(0) == dependency()) {
 385       // Don't need to add it
 386       return;
 387     }
 388     ok = (objArrayOop)ok->obj_at(1);
 389   }
 390 
 391   // Must handle over GC points
 392   assert (last != NULL, "dependencies should be initialized");
 393   objArrayHandle last_handle(THREAD, last);


 750           log_trace(class, loader, data)("is_anonymous: %s", class_loader()->klass()->internal_name());
 751         }
 752         metaspace = new Metaspace(_metaspace_lock, Metaspace::AnonymousMetaspaceType);
 753       } else if (class_loader()->is_a(SystemDictionary::reflect_DelegatingClassLoader_klass())) {
 754         if (class_loader() != NULL) {
 755           log_trace(class, loader, data)("is_reflection: %s", class_loader()->klass()->internal_name());
 756         }
 757         metaspace = new Metaspace(_metaspace_lock, Metaspace::ReflectionMetaspaceType);
 758       } else {
 759         metaspace = new Metaspace(_metaspace_lock, Metaspace::StandardMetaspaceType);
 760       }
 761       // Ensure _metaspace is stable, since it is examined without a lock
 762       OrderAccess::release_store_ptr(&_metaspace, metaspace);
 763     }
 764   }
 765   return metaspace;
 766 }
 767 
 768 OopHandle ClassLoaderData::add_handle(Handle h) {
 769   MutexLockerEx ml(metaspace_lock(),  Mutex::_no_safepoint_check_flag);
 770   record_modified_oops();
 771   return OopHandle(_handles.add(h()));
 772 }
 773 
 774 void ClassLoaderData::remove_handle(OopHandle h) {
 775   oop* ptr = h.ptr_raw();
 776   if (ptr != NULL) {
 777     assert(_handles.contains(ptr), "Got unexpected handle " PTR_FORMAT, p2i(ptr));
 778 #if INCLUDE_ALL_GCS
 779     // This barrier is used by G1 to remember the old oop values, so
 780     // that we don't forget any objects that were live at the snapshot at
 781     // the beginning.
 782     if (UseG1GC) {
 783       oop obj = *ptr;
 784       if (obj != NULL) {
 785         G1SATBCardTableModRefBS::enqueue(obj);
 786       }
 787     }
 788     record_modified_oops();  // necessary?
 789 #endif
 790     *ptr = NULL;
 791   }
 792 }
 793 
 794 void ClassLoaderData::init_handle_locked(OopHandle& dest, Handle h) {
 795   MutexLockerEx ml(metaspace_lock(),  Mutex::_no_safepoint_check_flag);
 796   if (dest.resolve() != NULL) {
 797     return;
 798   } else {
 799     dest = _handles.add(h());
 800   }
 801 }
 802 
 803 // Add this metadata pointer to be freed when it's safe.  This is only during
 804 // class unloading because Handles might point to this metadata field.
 805 void ClassLoaderData::add_to_deallocate_list(Metadata* m) {
 806   // Metadata in shared region isn't deleted.
 807   if (!m->is_shared()) {
 808     MutexLockerEx ml(metaspace_lock(),  Mutex::_no_safepoint_check_flag);


 863 #undef CLD_DUMP_KLASSES
 864 
 865 void ClassLoaderData::dump(outputStream * const out) {
 866   out->print("ClassLoaderData CLD: " PTR_FORMAT ", loader: " PTR_FORMAT ", loader_klass: " PTR_FORMAT " %s {",
 867       p2i(this), p2i((void *)class_loader()),
 868       p2i(class_loader() != NULL ? class_loader()->klass() : NULL), loader_name());
 869   if (claimed()) out->print(" claimed ");
 870   if (is_unloading()) out->print(" unloading ");
 871   out->cr();
 872   if (metaspace_or_null() != NULL) {
 873     out->print_cr("metaspace: " INTPTR_FORMAT, p2i(metaspace_or_null()));
 874     metaspace_or_null()->dump(out);
 875   } else {
 876     out->print_cr("metaspace: NULL");
 877   }
 878 
 879 #ifdef CLD_DUMP_KLASSES
 880   if (Verbose) {
 881     Klass* k = _klasses;
 882     while (k != NULL) {
 883       out->print_cr("klass " PTR_FORMAT ", %s", k, k->name()->as_C_string());

 884       assert(k != k->next_link(), "no loops!");
 885       k = k->next_link();
 886     }
 887   }
 888 #endif  // CLD_DUMP_KLASSES
 889 #undef CLD_DUMP_KLASSES
 890   if (_jmethod_ids != NULL) {
 891     Method::print_jmethod_ids(this, out);
 892   }
 893   out->print_cr("}");
 894 }
 895 #endif // PRODUCT
 896 
 897 void ClassLoaderData::verify() {
 898   assert_locked_or_safepoint(_metaspace_lock);
 899   oop cl = class_loader();
 900 
 901   guarantee(this == class_loader_data(cl) || is_anonymous(), "Must be the same");
 902   guarantee(cl != NULL || this == ClassLoaderData::the_null_class_loader_data() || is_anonymous(), "must be");
 903 


 990                             vmSymbols::toString_name(),
 991                             vmSymbols::void_string_signature(),
 992                             CHECK);
 993     assert(result.get_type() == T_OBJECT, "just checking");
 994     string = Handle(THREAD, (oop)result.get_jobject());
 995   }
 996 
 997   ResourceMark rm;
 998   out->print("create class loader data " INTPTR_FORMAT, p2i(cld));
 999   out->print(" for instance " INTPTR_FORMAT " of %s", p2i((void *)cld->class_loader()),
1000              cld->loader_name());
1001 
1002   if (string.not_null()) {
1003     out->print(": ");
1004     java_lang_String::print(string(), out);
1005   }
1006   out->cr();
1007 }
1008 
1009 
1010 void ClassLoaderDataGraph::oops_do(OopClosure* f, bool must_claim) {
1011   for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) {
1012     cld->oops_do(f, must_claim);
1013   }
1014 }
1015 
1016 void ClassLoaderDataGraph::keep_alive_oops_do(OopClosure* f, bool must_claim) {
1017   for (ClassLoaderData* cld = _head; cld != NULL; cld = cld->next()) {
1018     if (cld->keep_alive()) {
1019       cld->oops_do(f, must_claim);
1020     }
1021   }
1022 }
1023 
1024 void ClassLoaderDataGraph::always_strong_oops_do(OopClosure* f, bool must_claim) {
1025   if (ClassUnloading) {
1026     keep_alive_oops_do(f, must_claim);
1027   } else {
1028     oops_do(f, must_claim);
1029   }
1030 }
1031 
1032 void ClassLoaderDataGraph::cld_do(CLDClosure* cl) {
1033   for (ClassLoaderData* cld = _head; cl != NULL && cld != NULL; cld = cld->next()) {
1034     cl->do_cld(cld);
1035   }
1036 }
1037 
1038 void ClassLoaderDataGraph::cld_unloading_do(CLDClosure* cl) {
1039   assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint!");
1040   // Only walk the head until any clds not purged from prior unloading
1041   // (CMS doesn't purge right away).
1042   for (ClassLoaderData* cld = _unloading; cld != _saved_unloading; cld = cld->next()) {
1043     assert(cld->is_unloading(), "invariant");
1044     cl->do_cld(cld);
1045   }
1046 }
1047 
1048 void ClassLoaderDataGraph::roots_cld_do(CLDClosure* strong, CLDClosure* weak) {


< prev index next >