changeset 59234:4aedf0253cda

8241934: Simplify parse_stream() and remove has_class_mirror_holder_cld() Summary: Added paramter to register_loader() which allowed removing of has_class_mirror_holder_cld() Reviewed-by: coleenp, lfoltan
author hseigel
date Mon, 11 May 2020 15:00:16 +0000
parents a662625813af
children 11289e751d9f
files src/hotspot/share/classfile/classLoaderData.cpp src/hotspot/share/classfile/classLoaderData.hpp src/hotspot/share/classfile/classLoaderDataGraph.hpp src/hotspot/share/classfile/systemDictionary.cpp src/hotspot/share/classfile/systemDictionary.hpp
diffstat 5 files changed, 20 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/classfile/classLoaderData.cpp	Mon May 11 12:57:39 2020 +0200
+++ b/src/hotspot/share/classfile/classLoaderData.cpp	Mon May 11 15:00:16 2020 +0000
@@ -877,12 +877,6 @@
   }
 }
 
-// These CLDs are to contain non-strong hidden classes or unsafe anonymous classes used for JSR292
-ClassLoaderData* ClassLoaderData::has_class_mirror_holder_cld(Handle loader) {
-  // Add a new class loader data to the graph.
-  return ClassLoaderDataGraph::add(loader, true);
-}
-
 // Caller needs ResourceMark
 // If the class loader's _name has not been explicitly set, the class loader's
 // qualified class name is returned.
--- a/src/hotspot/share/classfile/classLoaderData.hpp	Mon May 11 12:57:39 2020 +0200
+++ b/src/hotspot/share/classfile/classLoaderData.hpp	Mon May 11 15:00:16 2020 +0000
@@ -316,7 +316,6 @@
 
   static ClassLoaderData* class_loader_data(oop loader);
   static ClassLoaderData* class_loader_data_or_null(oop loader);
-  static ClassLoaderData* has_class_mirror_holder_cld(Handle loader);
 
   // Returns Klass* of associated class loader, or NULL if associated loader is 'bootstrap'.
   // Also works if unloading.
--- a/src/hotspot/share/classfile/classLoaderDataGraph.hpp	Mon May 11 12:57:39 2020 +0200
+++ b/src/hotspot/share/classfile/classLoaderDataGraph.hpp	Mon May 11 15:00:16 2020 +0000
@@ -57,10 +57,10 @@
   static volatile size_t  _num_array_classes;
 
   static ClassLoaderData* add_to_graph(Handle class_loader, bool has_class_mirror_holder);
-  static ClassLoaderData* add(Handle class_loader, bool has_class_mirror_holder);
 
  public:
   static ClassLoaderData* find_or_create(Handle class_loader);
+  static ClassLoaderData* add(Handle class_loader, bool has_class_mirror_holder);
   static void clean_module_and_package_info();
   static void purge();
   static void clear_claimed_marks();
--- a/src/hotspot/share/classfile/systemDictionary.cpp	Mon May 11 12:57:39 2020 +0200
+++ b/src/hotspot/share/classfile/systemDictionary.cpp	Mon May 11 15:00:16 2020 +0000
@@ -182,9 +182,14 @@
   _java_platform_loader = (oop)result.get_jobject();
 }
 
-ClassLoaderData* SystemDictionary::register_loader(Handle class_loader) {
-  if (class_loader.is_null()) return ClassLoaderData::the_null_class_loader_data();
-  return ClassLoaderDataGraph::find_or_create(class_loader);
+ClassLoaderData* SystemDictionary::register_loader(Handle class_loader, bool create_mirror_cld) {
+  if (create_mirror_cld) {
+    // Add a new class loader data to the graph.
+    return ClassLoaderDataGraph::add(class_loader, true);
+  } else {
+    return (class_loader() == NULL) ? ClassLoaderData::the_null_class_loader_data() :
+                                      ClassLoaderDataGraph::find_or_create(class_loader);
+  }
 }
 
 // ----------------------------------------------------------------------------
@@ -1031,27 +1036,19 @@
                                               TRAPS) {
 
   EventClassLoad class_load_start_event;
-
   ClassLoaderData* loader_data;
-
   bool is_unsafe_anon_class = cl_info.unsafe_anonymous_host() != NULL;
 
-  if (is_unsafe_anon_class) {
-    // - for unsafe anonymous class: create a new CLD whith a class holder that uses
-    //                               the same class loader as the unsafe_anonymous_host.
-    guarantee(cl_info.unsafe_anonymous_host()->class_loader() == class_loader(),
-              "should be the same");
-    loader_data = ClassLoaderData::has_class_mirror_holder_cld(class_loader);
-  } else if (cl_info.is_hidden()) {
-    // - for hidden classes that are not strong: create a new CLD that has a class holder and
-    //                                           whose loader is the Lookup class' loader.
-    // - for hidden class: add the class to the Lookup class' loader's CLD.
-    if (!cl_info.is_strong_hidden()) {
-      loader_data = ClassLoaderData::has_class_mirror_holder_cld(class_loader);
-    } else {
-      // This hidden class goes into the regular CLD pool for this loader.
-      loader_data = register_loader(class_loader);
-    }
+  // - for unsafe anonymous class: create a new CLD whith a class holder that uses
+  //                               the same class loader as the unsafe_anonymous_host.
+  // - for hidden classes that are not strong: create a new CLD that has a class holder and
+  //                                           whose loader is the Lookup class's loader.
+  // - for hidden class: add the class to the Lookup class's loader's CLD.
+  if (is_unsafe_anon_class || cl_info.is_hidden()) {
+    guarantee(!is_unsafe_anon_class || cl_info.unsafe_anonymous_host()->class_loader() == class_loader(),
+              "should be NULL or the same");
+    bool create_mirror_cld = is_unsafe_anon_class || !cl_info.is_strong_hidden();
+    loader_data = register_loader(class_loader, create_mirror_cld);
   } else {
     loader_data = ClassLoaderData::class_loader_data(class_loader());
   }
--- a/src/hotspot/share/classfile/systemDictionary.hpp	Mon May 11 12:57:39 2020 +0200
+++ b/src/hotspot/share/classfile/systemDictionary.hpp	Mon May 11 15:00:16 2020 +0000
@@ -482,7 +482,7 @@
   static void compute_java_loaders(TRAPS);
 
   // Register a new class loader
-  static ClassLoaderData* register_loader(Handle class_loader);
+  static ClassLoaderData* register_loader(Handle class_loader, bool create_mirror_cld = false);
 protected:
   // Mirrors for primitive classes (created eagerly)
   static oop check_mirror(oop m) {