changeset 59303:edb6ac24115b

8244953: Shenandoah: gc/shenandoah/TestStringInternCleanup fails with broken string table root Reviewed-by: shade
author zgu
date Fri, 15 May 2020 10:43:20 -0400
parents fa5a0fb28d3d
children df9b06a8a184
files src/hotspot/share/gc/shenandoah/shenandoahClosures.hpp src/hotspot/share/gc/shenandoah/shenandoahClosures.inline.hpp src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.cpp src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.hpp src/hotspot/share/gc/shenandoah/shenandoahUnload.cpp
diffstat 6 files changed, 35 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/gc/shenandoah/shenandoahClosures.hpp	Fri May 15 14:46:17 2020 +0100
+++ b/src/hotspot/share/gc/shenandoah/shenandoahClosures.hpp	Fri May 15 10:43:20 2020 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019, Red Hat, Inc. All rights reserved.
+ * Copyright (c) 2019, 2020, Red Hat, Inc. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
 
 #include "memory/iterator.hpp"
 #include "oops/accessDecorators.hpp"
+#include "runtime/handshake.hpp"
 
 class ShenandoahHeap;
 class ShenandoahMarkingContext;
@@ -102,6 +103,12 @@
   inline void do_code_blob(CodeBlob* cb);
 };
 
+class ShenandoahRendezvousClosure : public HandshakeClosure {
+public:
+  inline ShenandoahRendezvousClosure();
+  inline void do_thread(Thread* thread);
+};
+
 #ifdef ASSERT
 class ShenandoahAssertNotForwardedClosure : public OopClosure {
 private:
--- a/src/hotspot/share/gc/shenandoah/shenandoahClosures.inline.hpp	Fri May 15 14:46:17 2020 +0100
+++ b/src/hotspot/share/gc/shenandoah/shenandoahClosures.inline.hpp	Fri May 15 10:43:20 2020 -0400
@@ -158,6 +158,13 @@
   }
 }
 
+ShenandoahRendezvousClosure::ShenandoahRendezvousClosure() :
+  HandshakeClosure("ShenandoahRendezvous") {
+}
+
+void ShenandoahRendezvousClosure::do_thread(Thread* thread) {
+}
+
 #ifdef ASSERT
 template <class T>
 void ShenandoahAssertNotForwardedClosure::do_oop_work(T* p) {
--- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp	Fri May 15 14:46:17 2020 +0100
+++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp	Fri May 15 10:43:20 2020 -0400
@@ -1830,11 +1830,21 @@
 
 void ShenandoahHeap::op_weak_roots() {
   if (is_concurrent_weak_root_in_progress()) {
-    // Concurrent weak root processing
-    ShenandoahConcurrentWeakRootsEvacUpdateTask task(ShenandoahPhaseTimings::conc_weak_roots);
-    workers()->run_task(&task);
-    if (!ShenandoahConcurrentRoots::should_do_concurrent_class_unloading()) {
-      set_concurrent_weak_root_in_progress(false);
+    {
+      // Concurrent weak root processing
+      ShenandoahGCWorkerPhase worker_phase(ShenandoahPhaseTimings::conc_weak_roots_work);
+      ShenandoahConcurrentWeakRootsEvacUpdateTask task(ShenandoahPhaseTimings::conc_weak_roots_work);
+      workers()->run_task(&task);
+      if (!ShenandoahConcurrentRoots::should_do_concurrent_class_unloading()) {
+        set_concurrent_weak_root_in_progress(false);
+      }
+    }
+
+    // Perform handshake to flush out dead oops
+    {
+      ShenandoahTimingsTracker t(ShenandoahPhaseTimings::conc_weak_roots_rendezvous);
+      ShenandoahRendezvousClosure cl;
+      Handshake::execute(&cl);
     }
   }
 }
@@ -2866,8 +2876,6 @@
   ShenandoahConcurrentPhase gc_phase(msg, ShenandoahPhaseTimings::conc_weak_roots);
   EventMark em("%s", msg);
 
-  ShenandoahGCWorkerPhase worker_phase(ShenandoahPhaseTimings::conc_weak_roots);
-
   ShenandoahWorkerScope scope(workers(),
                               ShenandoahWorkerPolicy::calc_workers_for_conc_root_processing(),
                               "concurrent weak root");
--- a/src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.cpp	Fri May 15 14:46:17 2020 +0100
+++ b/src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.cpp	Fri May 15 10:43:20 2020 -0400
@@ -107,7 +107,7 @@
     case purge_class_unload:
     case purge_weak_par:
     case heap_iteration_roots:
-    case conc_weak_roots:
+    case conc_weak_roots_work:
     case conc_strong_roots:
       return true;
     default:
--- a/src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.hpp	Fri May 15 14:46:17 2020 +0100
+++ b/src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.hpp	Fri May 15 10:43:20 2020 -0400
@@ -91,7 +91,9 @@
   SHENANDOAH_PAR_PHASE_DO(evac_,                    "    E: ", f)                      \
                                                                                        \
   f(conc_weak_roots,                                "Concurrent Weak Roots")           \
-  SHENANDOAH_PAR_PHASE_DO(conc_weak_roots_,         "  CWR: ", f)                      \
+  f(conc_weak_roots_work,                           "  Roots")                         \
+  SHENANDOAH_PAR_PHASE_DO(conc_weak_roots_work_,    "    CWR: ", f)                    \
+  f(conc_weak_roots_rendezvous,                     "  Rendezvous")                    \
   f(conc_cleanup_early,                             "Concurrent Cleanup")              \
   f(conc_class_unload,                              "Concurrent Class Unloading")      \
   f(conc_class_unload_unlink,                       "  Unlink Stale")                  \
--- a/src/hotspot/share/gc/shenandoah/shenandoahUnload.cpp	Fri May 15 14:46:17 2020 +0100
+++ b/src/hotspot/share/gc/shenandoah/shenandoahUnload.cpp	Fri May 15 10:43:20 2020 -0400
@@ -136,12 +136,6 @@
   DependencyContext::cleaning_start();
 }
 
-class ShenandoahUnloadRendezvousClosure : public HandshakeClosure {
-public:
-  ShenandoahUnloadRendezvousClosure() : HandshakeClosure("ShenandoahUnloadRendezvous") {}
-  void do_thread(Thread* thread) {}
-};
-
 void ShenandoahUnload::unload() {
   ShenandoahHeap* heap = ShenandoahHeap::heap();
   assert(ShenandoahConcurrentRoots::can_do_concurrent_class_unloading(), "Filtered by caller");
@@ -175,7 +169,7 @@
   // Make sure stale metadata and nmethods are no longer observable
   {
     ShenandoahTimingsTracker t(ShenandoahPhaseTimings::conc_class_unload_rendezvous);
-    ShenandoahUnloadRendezvousClosure cl;
+    ShenandoahRendezvousClosure cl;
     Handshake::execute(&cl);
   }