changeset 54052:632c4baddbb8

8215220: Simplify Shenandoah task termination in aborted paths Reviewed-by: shade
author zgu
date Wed, 12 Dec 2018 13:50:57 -0500
parents 339d2fbe8675
children 9f13f8aad8dc
files src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.cpp src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.hpp src/hotspot/share/gc/shenandoah/shenandoahTraversalGC.cpp
diffstat 4 files changed, 10 insertions(+), 47 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp	Thu Dec 13 14:36:54 2018 +0100
+++ b/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp	Wed Dec 12 13:50:57 2018 -0500
@@ -939,9 +939,6 @@
   q = queues->claim_next();
   while (q != NULL) {
     if (CANCELLABLE && heap->check_cancelled_gc_and_yield()) {
-      ShenandoahCancelledTerminatorTerminator tt;
-      ShenandoahSuspendibleThreadSetLeaver stsl(ShenandoahSuspendibleWorkers);
-      while (!terminator->offer_termination(&tt));
       return;
     }
 
@@ -965,9 +962,6 @@
    */
   while (true) {
     if (CANCELLABLE && heap->check_cancelled_gc_and_yield()) {
-      ShenandoahCancelledTerminatorTerminator tt;
-      ShenandoahSuspendibleThreadSetLeaver stsl(ShenandoahSuspendibleWorkers);
-      while (!terminator->offer_termination(&tt));
       return;
     }
 
@@ -991,7 +985,8 @@
       // Need to leave the STS here otherwise it might block safepoints.
       ShenandoahSuspendibleThreadSetLeaver stsl(CANCELLABLE && ShenandoahSuspendibleWorkers);
       ShenandoahTerminationTimingsTracker term_tracker(worker_id);
-      if (terminator->offer_termination()) return;
+      ShenandoahTerminatorTerminator tt(heap);
+      if (terminator->offer_termination(&tt)) return;
     }
   }
 }
--- a/src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.cpp	Thu Dec 13 14:36:54 2018 +0100
+++ b/src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.cpp	Wed Dec 12 13:50:57 2018 -0500
@@ -49,28 +49,8 @@
   return true;
 }
 
-class ShenandoahOWSTTerminator: public OWSTTaskTerminator {
-public:
-  ShenandoahOWSTTerminator(uint n_threads, TaskQueueSetSuper* queue_set) :
-    OWSTTaskTerminator(n_threads, queue_set){ }
-
-protected:
-  bool exit_termination(size_t tasks, TerminatorTerminator* terminator);
-};
-
-bool ShenandoahOWSTTerminator::exit_termination(size_t tasks, TerminatorTerminator* terminator) {
-  ShenandoahTerminatorTerminator* t = (ShenandoahTerminatorTerminator*)terminator;
-  bool force = (t != NULL) && t->should_force_termination();
-  if (force) {
-    // Force termination : continue termination, even there are remaining tasks.
-    return false;
-  } else {
-    return OWSTTaskTerminator::exit_termination(tasks, terminator);
-  }
-}
-
 ShenandoahTaskTerminator::ShenandoahTaskTerminator(uint n_threads, TaskQueueSetSuper* queue_set) :
-  _terminator(new ShenandoahOWSTTerminator(n_threads, queue_set)) { }
+  _terminator(new OWSTTaskTerminator(n_threads, queue_set)) { }
 
 ShenandoahTaskTerminator::~ShenandoahTaskTerminator() {
   assert(_terminator != NULL, "Invariant");
--- a/src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.hpp	Thu Dec 13 14:36:54 2018 +0100
+++ b/src/hotspot/share/gc/shenandoah/shenandoahTaskqueue.hpp	Wed Dec 12 13:50:57 2018 -0500
@@ -306,18 +306,12 @@
 };
 
 class ShenandoahTerminatorTerminator : public TerminatorTerminator {
+private:
+  ShenandoahHeap* _heap;
 public:
+  ShenandoahTerminatorTerminator(ShenandoahHeap* const heap) : _heap(heap) { }
   // return true, terminates immediately, even if there's remaining work left
-  virtual bool should_force_termination() { return false; }
-};
-
-class ShenandoahCancelledTerminatorTerminator : public ShenandoahTerminatorTerminator {
-  virtual bool should_exit_termination() {
-    return false;
-  }
-  virtual bool should_force_termination() {
-    return true;
-  }
+  virtual bool should_exit_termination() { return _heap->cancelled_gc(); }
 };
 
 class ShenandoahTaskTerminator : public StackObj {
--- a/src/hotspot/share/gc/shenandoah/shenandoahTraversalGC.cpp	Thu Dec 13 14:36:54 2018 +0100
+++ b/src/hotspot/share/gc/shenandoah/shenandoahTraversalGC.cpp	Wed Dec 12 13:50:57 2018 -0500
@@ -498,10 +498,6 @@
   q = queues->claim_next();
   while (q != NULL) {
     if (_heap->check_cancelled_gc_and_yield(sts_yield)) {
-      ShenandoahCancelledTerminatorTerminator tt;
-      ShenandoahEvacOOMScopeLeaver oom_scope_leaver;
-      ShenandoahSuspendibleThreadSetLeaver stsl(sts_yield && ShenandoahSuspendibleWorkers);
-      while (!terminator->offer_termination(&tt));
       return;
     }
 
@@ -547,17 +543,15 @@
       ShenandoahEvacOOMScopeLeaver oom_scope_leaver;
       ShenandoahSuspendibleThreadSetLeaver stsl(sts_yield && ShenandoahSuspendibleWorkers);
       ShenandoahTerminationTimingsTracker term_tracker(worker_id);
-      if (terminator->offer_termination()) return;
+      ShenandoahTerminatorTerminator tt(_heap);
+
+      if (terminator->offer_termination(&tt)) return;
     }
   }
 }
 
 bool ShenandoahTraversalGC::check_and_handle_cancelled_gc(ShenandoahTaskTerminator* terminator, bool sts_yield) {
   if (_heap->cancelled_gc()) {
-    ShenandoahCancelledTerminatorTerminator tt;
-    ShenandoahEvacOOMScopeLeaver oom_scope_leaver;
-    ShenandoahSuspendibleThreadSetLeaver stsl(sts_yield && ShenandoahSuspendibleWorkers);
-    while (! terminator->offer_termination(&tt));
     return true;
   }
   return false;