src/hotspot/share/gc/shared/weakProcessor.hpp
changeset 51546 b9f6a4427da9
parent 47676 b1c020fc35a3
child 53244 9807daeb47c4
--- a/src/hotspot/share/gc/shared/weakProcessor.hpp	Wed Aug 22 09:33:18 2018 -0700
+++ b/src/hotspot/share/gc/shared/weakProcessor.hpp	Tue Aug 28 12:57:40 2018 -0400
@@ -25,8 +25,12 @@
 #ifndef SHARE_VM_GC_SHARED_WEAKPROCESSOR_HPP
 #define SHARE_VM_GC_SHARED_WEAKPROCESSOR_HPP
 
+#include "gc/shared/oopStorageParState.hpp"
+#include "gc/shared/workgroup.hpp"
 #include "memory/allocation.hpp"
-#include "memory/iterator.hpp"
+
+class WeakProcessorPhaseTimes;
+class WorkGang;
 
 // Helper class to aid in root scanning and cleaning of weak oops in the VM.
 //
@@ -41,6 +45,51 @@
 
   // Visit all oop*s and apply the given closure.
   static void oops_do(OopClosure* closure);
+
+  // Parallel version.  Uses ergo_workers(), active workers, and
+  // phase_time's max_threads to determine the number of threads to use.
+  // IsAlive must be derived from BoolObjectClosure.
+  // KeepAlive must be derived from OopClosure.
+  template<typename IsAlive, typename KeepAlive>
+  static void weak_oops_do(WorkGang* workers,
+                           IsAlive* is_alive,
+                           KeepAlive* keep_alive,
+                           WeakProcessorPhaseTimes* phase_times);
+
+  // Convenience parallel version.  Uses ergo_workers() and active workers
+  // to determine the number of threads to run.  Implicitly logs phase times.
+  // IsAlive must be derived from BoolObjectClosure.
+  // KeepAlive must be derived from OopClosure.
+  template<typename IsAlive, typename KeepAlive>
+  static void weak_oops_do(WorkGang* workers,
+                           IsAlive* is_alive,
+                           KeepAlive* keep_alive,
+                           uint indent_log);
+
+  static uint ergo_workers(uint max_workers);
+  class Task;
+
+private:
+  class GangTask;
+};
+
+class WeakProcessor::Task {
+  typedef OopStorage::ParState<false, false> StorageState;
+
+  WeakProcessorPhaseTimes* _phase_times;
+  uint _nworkers;
+  SubTasksDone _serial_phases_done;
+  StorageState* _storage_states;
+
+  void initialize();
+
+public:
+  Task(uint nworkers);          // No time tracking.
+  Task(WeakProcessorPhaseTimes* phase_times, uint nworkers);
+  ~Task();
+
+  template<typename IsAlive, typename KeepAlive>
+  void work(uint worker_id, IsAlive* is_alive, KeepAlive* keep_alive);
 };
 
 #endif // SHARE_VM_GC_SHARED_WEAKPROCESSOR_HPP