8081682: AbstractWorkGang::_terminate is never used
authorstefank
Wed, 03 Jun 2015 11:46:07 +0200
changeset 31030 811c2501a5a6
parent 31028 8c5b4d489c41
child 31031 d0b85f02898f
8081682: AbstractWorkGang::_terminate is never used Reviewed-by: kbarrett, pliden, brutisso
hotspot/src/share/vm/gc/cms/yieldingWorkgroup.cpp
hotspot/src/share/vm/gc/cms/yieldingWorkgroup.hpp
hotspot/src/share/vm/gc/shared/workgroup.cpp
hotspot/src/share/vm/gc/shared/workgroup.hpp
--- a/hotspot/src/share/vm/gc/cms/yieldingWorkgroup.cpp	Fri May 29 10:44:32 2015 -0400
+++ b/hotspot/src/share/vm/gc/cms/yieldingWorkgroup.cpp	Wed Jun 03 11:46:07 2015 +0200
@@ -43,7 +43,7 @@
 }
 
 // Run a task; returns when the task is done, or the workers yield,
-// or the task is aborted, or the work gang is terminated via stop().
+// or the task is aborted.
 // A task that has been yielded can be continued via this interface
 // by using the same task repeatedly as the argument to the call.
 // It is expected that the YieldingFlexibleGangTask carries the appropriate
@@ -297,16 +297,9 @@
   WorkData data;
   int id;
   while (true) {
-    // Check if there is work to do or if we have been asked
-    // to terminate
+    // Check if there is work to do.
     gang()->internal_worker_poll(&data);
-    if (data.terminate()) {
-      // We have been asked to terminate.
-      assert(gang()->task() == NULL, "No task binding");
-      // set_status(TERMINATED);
-      return;
-    } else if (data.task() != NULL &&
-               data.sequence_number() != previous_sequence_number) {
+    if (data.task() != NULL && data.sequence_number() != previous_sequence_number) {
       // There is work to be done.
       // First check if we need to become active or if there
       // are already the requisite number of workers
--- a/hotspot/src/share/vm/gc/cms/yieldingWorkgroup.hpp	Fri May 29 10:44:32 2015 -0400
+++ b/hotspot/src/share/vm/gc/cms/yieldingWorkgroup.hpp	Wed Jun 03 11:46:07 2015 +0200
@@ -176,7 +176,7 @@
   GangWorker* allocate_worker(uint which);
 
   // Run a task; returns when the task is done, or the workers yield,
-  // or the task is aborted, or the work gang is terminated via stop().
+  // or the task is aborted.
   // A task that has been yielded can be continued via this same interface
   // by using the same task repeatedly as the argument to the call.
   // It is expected that the YieldingFlexibleGangTask carries the appropriate
--- a/hotspot/src/share/vm/gc/shared/workgroup.cpp	Fri May 29 10:44:32 2015 -0400
+++ b/hotspot/src/share/vm/gc/shared/workgroup.cpp	Wed Jun 03 11:46:07 2015 +0200
@@ -47,7 +47,6 @@
                          /* allow_vm_block */ are_GC_task_threads,
                                               Monitor::_safepoint_check_sometimes);
   assert(monitor() != NULL, "Failed to allocate monitor");
-  _terminate = false;
   _task = NULL;
   _sequence_number = 0;
   _started_workers = 0;
@@ -106,18 +105,6 @@
   return true;
 }
 
-AbstractWorkGang::~AbstractWorkGang() {
-  if (TraceWorkGang) {
-    tty->print_cr("Destructing work gang %s", name());
-  }
-  stop();   // stop all the workers
-  for (uint worker = 0; worker < total_workers(); worker += 1) {
-    delete gang_worker(worker);
-  }
-  delete gang_workers();
-  delete monitor();
-}
-
 GangWorker* AbstractWorkGang::gang_worker(uint i) const {
   // Array index bounds checking.
   GangWorker* result = NULL;
@@ -175,28 +162,9 @@
   WorkGang::run_task(task, (uint) active_workers());
 }
 
-void AbstractWorkGang::stop() {
-  // Tell all workers to terminate, then wait for them to become inactive.
-  MutexLockerEx ml(monitor(), Mutex::_no_safepoint_check_flag);
-  if (TraceWorkGang) {
-    tty->print_cr("Stopping work gang %s task %s", name(), task()->name());
-  }
-  _task = NULL;
-  _terminate = true;
-  monitor()->notify_all();
-  while (finished_workers() < active_workers()) {
-    if (TraceWorkGang) {
-      tty->print_cr("Waiting in work gang %s: %u/%u finished",
-                    name(), finished_workers(), active_workers());
-    }
-    monitor()->wait(/* no_safepoint_check */ true);
-  }
-}
-
 void AbstractWorkGang::internal_worker_poll(WorkData* data) const {
   assert(monitor()->owned_by_self(), "worker_poll is an internal method");
   assert(data != NULL, "worker data is null");
-  data->set_terminate(terminate());
   data->set_task(task());
   data->set_sequence_number(sequence_number());
 }
@@ -259,7 +227,7 @@
 void GangWorker::loop() {
   int previous_sequence_number = 0;
   Monitor* gang_monitor = gang()->monitor();
-  for ( ; /* !terminate() */; ) {
+  for ( ; ; ) {
     WorkData data;
     int part;  // Initialized below.
     {
@@ -272,8 +240,6 @@
       if (TraceWorkGang) {
         tty->print("Polled outside for work in gang %s worker %u",
                    gang()->name(), id());
-        tty->print("  terminate: %s",
-                   data.terminate() ? "true" : "false");
         tty->print("  sequence: %d (prev: %d)",
                    data.sequence_number(), previous_sequence_number);
         if (data.task() != NULL) {
@@ -283,13 +249,7 @@
         }
         tty->cr();
       }
-      for ( ; /* break or return */; ) {
-        // Terminate if requested.
-        if (data.terminate()) {
-          gang()->internal_note_finish();
-          gang_monitor->notify_all();
-          return;
-        }
+      for ( ; /* break */; ) {
         // Check for new work.
         if ((data.task() != NULL) &&
             (data.sequence_number() != previous_sequence_number)) {
@@ -306,8 +266,6 @@
         if (TraceWorkGang) {
           tty->print("Polled inside for work in gang %s worker %u",
                      gang()->name(), id());
-          tty->print("  terminate: %s",
-                     data.terminate() ? "true" : "false");
           tty->print("  sequence: %d (prev: %d)",
                      data.sequence_number(), previous_sequence_number);
           if (data.task() != NULL) {
--- a/hotspot/src/share/vm/gc/shared/workgroup.hpp	Fri May 29 10:44:32 2015 -0400
+++ b/hotspot/src/share/vm/gc/shared/workgroup.hpp	Wed Jun 03 11:46:07 2015 +0200
@@ -103,16 +103,15 @@
 // An abstract class representing a gang of workers.
 // You subclass this to supply an implementation of run_task().
 class AbstractWorkGang: public CHeapObj<mtInternal> {
-  // Here's the public interface to this class.
+protected:
+  // Work gangs are never deleted, so no need to cleanup.
+  ~AbstractWorkGang() { ShouldNotReachHere(); }
 public:
-  // Constructor and destructor.
+  // Constructor.
   AbstractWorkGang(const char* name, bool are_GC_task_threads,
                    bool are_ConcurrentGC_threads);
-  ~AbstractWorkGang();
   // Run a task, returns when the task is done (or terminated).
   virtual void run_task(AbstractGangTask* task) = 0;
-  // Stop and terminate all workers.
-  virtual void stop();
   // Return true if more workers should be applied to the task.
   virtual bool needs_more_workers() const { return true; }
 public:
@@ -129,8 +128,6 @@
   Monitor*  _monitor;
   // The count of the number of workers in the gang.
   uint _total_workers;
-  // Whether the workers should terminate.
-  bool _terminate;
   // The array of worker threads for this gang.
   // This is only needed for cleaning up.
   GangWorker** _gang_workers;
@@ -153,9 +150,6 @@
   virtual uint active_workers() const {
     return _total_workers;
   }
-  bool terminate() const {
-    return _terminate;
-  }
   GangWorker** gang_workers() const {
     return _gang_workers;
   }
@@ -205,21 +199,16 @@
 class WorkData: public StackObj {
   // This would be a struct, but I want accessor methods.
 private:
-  bool              _terminate;
   AbstractGangTask* _task;
   int               _sequence_number;
 public:
   // Constructor and destructor
   WorkData() {
-    _terminate       = false;
     _task            = NULL;
     _sequence_number = 0;
   }
   ~WorkData() {
   }
-  // Accessors and modifiers
-  bool terminate()                       const { return _terminate;  }
-  void set_terminate(bool value)               { _terminate = value; }
   AbstractGangTask* task()               const { return _task; }
   void set_task(AbstractGangTask* value)       { _task = value; }
   int sequence_number()                  const { return _sequence_number; }