src/hotspot/share/classfile/classLoaderData.hpp
changeset 49348 fde3feaaa4ed
parent 48884 7e17b00dc245
child 49352 0b48f0aa79ec
--- a/src/hotspot/share/classfile/classLoaderData.hpp	Tue Mar 06 08:36:44 2018 +0100
+++ b/src/hotspot/share/classfile/classLoaderData.hpp	Tue Mar 06 17:15:16 2018 -0500
@@ -83,10 +83,10 @@
   static volatile size_t  _num_instance_classes;
   static volatile size_t  _num_array_classes;
 
-  static ClassLoaderData* add(Handle class_loader, bool anonymous, TRAPS);
+  static ClassLoaderData* add(Handle class_loader, bool anonymous);
   static void post_class_unload_events();
  public:
-  static ClassLoaderData* find_or_create(Handle class_loader, TRAPS);
+  static ClassLoaderData* find_or_create(Handle class_loader);
   static void purge();
   static void clear_claimed_marks();
   // oops do
@@ -151,10 +151,9 @@
   static bool has_metaspace_oom()           { return _metaspace_oom; }
   static void set_metaspace_oom(bool value) { _metaspace_oom = value; }
 
-  static void dump_on(outputStream * const out) PRODUCT_RETURN;
-  static void dump() { dump_on(tty); }
+  static void print_on(outputStream * const out) PRODUCT_RETURN;
+  static void print() { print_on(tty); }
   static void verify();
-  static void print_creation(outputStream* out, Handle loader, ClassLoaderData* cld, TRAPS);
 
   static bool unload_list_contains(const void* x);
 
@@ -181,22 +180,8 @@
 
 class ClassLoaderData : public CHeapObj<mtClass> {
   friend class VMStructs;
+
  private:
-  class Dependencies VALUE_OBJ_CLASS_SPEC {
-    objArrayOop _list_head;
-    void locked_add(objArrayHandle last,
-                    objArrayHandle new_dependency,
-                    Thread* THREAD);
-   public:
-    Dependencies() : _list_head(NULL) {}
-    Dependencies(TRAPS) : _list_head(NULL) {
-      init(CHECK);
-    }
-    void add(Handle dependency, TRAPS);
-    void init(TRAPS);
-    void oops_do(OopClosure* f);
-  };
-
   class ChunkedHandleList VALUE_OBJ_CLASS_SPEC {
     struct Chunk : public CHeapObj<mtClass> {
       static const size_t CAPACITY = 32;
@@ -219,10 +204,10 @@
     // Only one thread at a time can add, guarded by ClassLoaderData::metaspace_lock().
     // However, multiple threads can execute oops_do concurrently with add.
     oop* add(oop o);
-#ifdef ASSERT
-    bool contains(oop* p);
-#endif
+    bool contains(oop p);
     void oops_do(OopClosure* f);
+
+    int count() const;
   };
 
   friend class ClassLoaderDataGraph;
@@ -237,8 +222,6 @@
 
   oop _class_loader;          // oop used to uniquely identify a class loader
                               // class loader or a canonical class path
-  Dependencies _dependencies; // holds dependencies from this class loader
-                              // data to others.
 
   Metaspace * volatile _metaspace;  // Meta-space where meta-data defined by the
                                     // classes in the class loader are allocated.
@@ -261,6 +244,8 @@
   ChunkedHandleList _handles; // Handles to constant pool arrays, Modules, etc, which
                               // have the same life cycle of the corresponding ClassLoader.
 
+  NOT_PRODUCT(volatile int _dependency_count;)  // number of class loader dependencies
+
   Klass* volatile _klasses;              // The classes defined by the class loader.
   PackageEntryTable* volatile _packages; // The packages defined by the class loader.
   ModuleEntryTable*  volatile _modules;  // The modules defined by the class loader.
@@ -289,7 +274,7 @@
   void set_next(ClassLoaderData* next) { _next = next; }
   ClassLoaderData* next() const        { return _next; }
 
-  ClassLoaderData(Handle h_class_loader, bool is_anonymous, Dependencies dependencies);
+  ClassLoaderData(Handle h_class_loader, bool is_anonymous);
   ~ClassLoaderData();
 
   // The CLD are not placed in the Heap, so the Card Table or
@@ -341,15 +326,7 @@
 
   bool is_anonymous() const { return _is_anonymous; }
 
-  static void init_null_class_loader_data() {
-    assert(_the_null_class_loader_data == NULL, "cannot initialize twice");
-    assert(ClassLoaderDataGraph::_head == NULL, "cannot initialize twice");
-
-    // We explicitly initialize the Dependencies object at a later phase in the initialization
-    _the_null_class_loader_data = new ClassLoaderData(Handle(), false, Dependencies());
-    ClassLoaderDataGraph::_head = _the_null_class_loader_data;
-    assert(_the_null_class_loader_data->is_the_null_class_loader_data(), "Must be");
-  }
+  static void init_null_class_loader_data();
 
   bool is_the_null_class_loader_data() const {
     return this == _the_null_class_loader_data;
@@ -397,12 +374,11 @@
   void set_jmethod_ids(JNIMethodBlock* new_block)  { _jmethod_ids = new_block; }
 
   void print()                                     { print_on(tty); }
-  void print_on(outputStream* out) const;
+  void print_on(outputStream* out) const PRODUCT_RETURN;
   void print_value()                               { print_value_on(tty); }
   void print_value_on(outputStream* out) const;
-  void dump(outputStream * const out) PRODUCT_RETURN;
   void verify();
-  const char* loader_name();
+  const char* loader_name() const;
 
   OopHandle add_handle(Handle h);
   void remove_handle(OopHandle h);
@@ -410,8 +386,7 @@
   void add_class(Klass* k, bool publicize = true);
   void remove_class(Klass* k);
   bool contains_klass(Klass* k);
-  void record_dependency(const Klass* to, TRAPS);
-  void init_dependencies(TRAPS);
+  void record_dependency(const Klass* to);
   PackageEntryTable* packages() { return _packages; }
   ModuleEntry* unnamed_module() { return _unnamed_module; }
   ModuleEntryTable* modules();
@@ -424,8 +399,7 @@
 
   static ClassLoaderData* class_loader_data(oop loader);
   static ClassLoaderData* class_loader_data_or_null(oop loader);
-  static ClassLoaderData* anonymous_class_loader_data(oop loader, TRAPS);
-  static void print_loader(ClassLoaderData *loader_data, outputStream *out);
+  static ClassLoaderData* anonymous_class_loader_data(Handle loader);
 
   TRACE_DEFINE_TRACE_ID_METHODS;
 };