changeset 52520:c3066f7465fa

8213307: G1 should clean up RMT with ClassUnloadingWithConcurrentMark Summary: Re-enable cleanup of the ResolvedMethodTable after changes in JDK-8206423. Reviewed-by: shade, coleenp
author tschatzl
date Tue, 13 Nov 2018 11:45:16 +0100
parents 34510f65fb58
children 768b1c612100
files src/hotspot/share/classfile/classLoaderDataGraph.cpp src/hotspot/share/classfile/classLoaderDataGraph.hpp src/hotspot/share/classfile/systemDictionary.cpp src/hotspot/share/classfile/systemDictionary.hpp src/hotspot/share/gc/g1/g1ConcurrentMark.cpp test/hotspot/jtreg/runtime/MemberName/MemberNameLeak.java
diffstat 6 files changed, 21 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/classfile/classLoaderDataGraph.cpp	Tue Nov 13 11:34:54 2018 +0100
+++ b/src/hotspot/share/classfile/classLoaderDataGraph.cpp	Tue Nov 13 11:45:16 2018 +0100
@@ -496,11 +496,11 @@
 
 // Move class loader data from main list to the unloaded list for unloading
 // and deallocation later.
-bool ClassLoaderDataGraph::do_unloading(bool do_cleaning) {
+bool ClassLoaderDataGraph::do_unloading() {
   assert_locked_or_safepoint(ClassLoaderDataGraph_lock);
 
   // Indicate whether safepoint cleanup is needed.
-  _safepoint_cleanup_needed |= do_cleaning;
+  _safepoint_cleanup_needed = true;
 
   ClassLoaderData* data = _head;
   ClassLoaderData* prev = NULL;
--- a/src/hotspot/share/classfile/classLoaderDataGraph.hpp	Tue Nov 13 11:34:54 2018 +0100
+++ b/src/hotspot/share/classfile/classLoaderDataGraph.hpp	Tue Nov 13 11:45:16 2018 +0100
@@ -88,7 +88,7 @@
   static void loaded_classes_do(KlassClosure* klass_closure);
   static void unlocked_loaded_classes_do(KlassClosure* klass_closure);
   static void classes_unloading_do(void f(Klass* const));
-  static bool do_unloading(bool do_cleaning);
+  static bool do_unloading();
 
   // Expose state to avoid logging overhead in safepoint cleanup tasks.
   static inline bool should_clean_metaspaces_and_reset();
--- a/src/hotspot/share/classfile/systemDictionary.cpp	Tue Nov 13 11:34:54 2018 +0100
+++ b/src/hotspot/share/classfile/systemDictionary.cpp	Tue Nov 13 11:45:16 2018 +0100
@@ -1845,15 +1845,14 @@
 
 // Assumes classes in the SystemDictionary are only unloaded at a safepoint
 // Note: anonymous classes are not in the SD.
-bool SystemDictionary::do_unloading(GCTimer* gc_timer,
-                                    bool do_cleaning) {
+bool SystemDictionary::do_unloading(GCTimer* gc_timer) {
 
   bool unloading_occurred;
   {
     GCTraceTime(Debug, gc, phases) t("ClassLoaderData", gc_timer);
 
     // First, mark for unload all ClassLoaderData referencing a dead class loader.
-    unloading_occurred = ClassLoaderDataGraph::do_unloading(do_cleaning);
+    unloading_occurred = ClassLoaderDataGraph::do_unloading();
     if (unloading_occurred) {
       JFR_ONLY(Jfr::on_unloading_classes();)
       ClassLoaderDataGraph::clean_module_and_package_info();
@@ -1883,7 +1882,7 @@
     _pd_cache_table->trigger_cleanup();
   }
 
-  if (do_cleaning) {
+  {
     GCTraceTime(Debug, gc, phases) t("ResolvedMethodTable", gc_timer);
     ResolvedMethodTable::trigger_cleanup();
   }
--- a/src/hotspot/share/classfile/systemDictionary.hpp	Tue Nov 13 11:34:54 2018 +0100
+++ b/src/hotspot/share/classfile/systemDictionary.hpp	Tue Nov 13 11:45:16 2018 +0100
@@ -347,8 +347,7 @@
 
   // Unload (that is, break root links to) all unmarked classes and
   // loaders.  Returns "true" iff something was unloaded.
-  static bool do_unloading(GCTimer* gc_timer,
-                           bool do_cleaning = true);
+  static bool do_unloading(GCTimer* gc_timer);
 
   // Used by DumpSharedSpaces only to remove classes that failed verification
   static void remove_classes_in_error_state();
--- a/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp	Tue Nov 13 11:34:54 2018 +0100
+++ b/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp	Tue Nov 13 11:45:16 2018 +0100
@@ -1655,7 +1655,7 @@
   // Unload Klasses, String, Code Cache, etc.
   if (ClassUnloadingWithConcurrentMark) {
     GCTraceTime(Debug, gc, phases) debug("Class Unloading", _gc_timer_cm);
-    bool purged_classes = SystemDictionary::do_unloading(_gc_timer_cm, false /* Defer cleaning */);
+    bool purged_classes = SystemDictionary::do_unloading(_gc_timer_cm);
     _g1h->complete_cleaning(&g1_is_alive, purged_classes);
   } else {
     GCTraceTime(Debug, gc, phases) debug("Cleanup", _gc_timer_cm);
--- a/test/hotspot/jtreg/runtime/MemberName/MemberNameLeak.java	Tue Nov 13 11:34:54 2018 +0100
+++ b/test/hotspot/jtreg/runtime/MemberName/MemberNameLeak.java	Tue Nov 13 11:45:16 2018 +0100
@@ -23,8 +23,9 @@
 
 /*
  * @test
- * @bug 8174749
+ * @bug 8174749 8213307
  * @summary MemberNameTable should reuse entries
+ * @requires vm.gc == "null"
  * @library /test/lib
  * @build sun.hotspot.WhiteBox
  * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
@@ -71,13 +72,16 @@
       }
     }
 
-    public static void test(String gc) throws Throwable {
+    public static void test(String gc, boolean doConcurrent) throws Throwable {
         // Run this Leak class with logging
         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
                                       "-Xlog:membername+table=trace",
                                       "-XX:+UnlockDiagnosticVMOptions",
                                       "-XX:+WhiteBoxAPI",
                                       "-Xbootclasspath/a:.",
+                                      doConcurrent ? "-XX:+ExplicitGCInvokesConcurrent" : "-XX:-ExplicitGCInvokesConcurrent",
+                                      "-XX:+ClassUnloading",
+                                      "-XX:+ClassUnloadingWithConcurrentMark",
                                       gc, Leak.class.getName());
         OutputAnalyzer output = new OutputAnalyzer(pb.start());
         output.shouldContain("ResolvedMethod entry added for MemberNameLeak$Leak.callMe()V");
@@ -87,11 +91,14 @@
     }
 
     public static void main(java.lang.String[] unused) throws Throwable {
-        test("-XX:+UseG1GC");
-        test("-XX:+UseParallelGC");
-        test("-XX:+UseSerialGC");
+        test("-XX:+UseG1GC", false);
+        test("-XX:+UseG1GC", true);
+
+        test("-XX:+UseParallelGC", false);
+        test("-XX:+UseSerialGC", false);
         if (!Compiler.isGraalEnabled()) { // Graal does not support CMS
-            test("-XX:+UseConcMarkSweepGC");
+            test("-XX:+UseConcMarkSweepGC", false);
+            test("-XX:+UseConcMarkSweepGC", true);
         }
     }
 }