src/hotspot/share/gc/shared/weakProcessor.hpp
changeset 51546 b9f6a4427da9
parent 47676 b1c020fc35a3
child 53244 9807daeb47c4
equal deleted inserted replaced
51545:29517169ad2d 51546:b9f6a4427da9
    23  */
    23  */
    24 
    24 
    25 #ifndef SHARE_VM_GC_SHARED_WEAKPROCESSOR_HPP
    25 #ifndef SHARE_VM_GC_SHARED_WEAKPROCESSOR_HPP
    26 #define SHARE_VM_GC_SHARED_WEAKPROCESSOR_HPP
    26 #define SHARE_VM_GC_SHARED_WEAKPROCESSOR_HPP
    27 
    27 
       
    28 #include "gc/shared/oopStorageParState.hpp"
       
    29 #include "gc/shared/workgroup.hpp"
    28 #include "memory/allocation.hpp"
    30 #include "memory/allocation.hpp"
    29 #include "memory/iterator.hpp"
    31 
       
    32 class WeakProcessorPhaseTimes;
       
    33 class WorkGang;
    30 
    34 
    31 // Helper class to aid in root scanning and cleaning of weak oops in the VM.
    35 // Helper class to aid in root scanning and cleaning of weak oops in the VM.
    32 //
    36 //
    33 // New containers of weak oops added to this class will automatically
    37 // New containers of weak oops added to this class will automatically
    34 // be cleaned by all GCs, including the young generation GCs.
    38 // be cleaned by all GCs, including the young generation GCs.
    39   // container specific cleanup of element holding the oop.
    43   // container specific cleanup of element holding the oop.
    40   static void weak_oops_do(BoolObjectClosure* is_alive, OopClosure* keep_alive);
    44   static void weak_oops_do(BoolObjectClosure* is_alive, OopClosure* keep_alive);
    41 
    45 
    42   // Visit all oop*s and apply the given closure.
    46   // Visit all oop*s and apply the given closure.
    43   static void oops_do(OopClosure* closure);
    47   static void oops_do(OopClosure* closure);
       
    48 
       
    49   // Parallel version.  Uses ergo_workers(), active workers, and
       
    50   // phase_time's max_threads to determine the number of threads to use.
       
    51   // IsAlive must be derived from BoolObjectClosure.
       
    52   // KeepAlive must be derived from OopClosure.
       
    53   template<typename IsAlive, typename KeepAlive>
       
    54   static void weak_oops_do(WorkGang* workers,
       
    55                            IsAlive* is_alive,
       
    56                            KeepAlive* keep_alive,
       
    57                            WeakProcessorPhaseTimes* phase_times);
       
    58 
       
    59   // Convenience parallel version.  Uses ergo_workers() and active workers
       
    60   // to determine the number of threads to run.  Implicitly logs phase times.
       
    61   // IsAlive must be derived from BoolObjectClosure.
       
    62   // KeepAlive must be derived from OopClosure.
       
    63   template<typename IsAlive, typename KeepAlive>
       
    64   static void weak_oops_do(WorkGang* workers,
       
    65                            IsAlive* is_alive,
       
    66                            KeepAlive* keep_alive,
       
    67                            uint indent_log);
       
    68 
       
    69   static uint ergo_workers(uint max_workers);
       
    70   class Task;
       
    71 
       
    72 private:
       
    73   class GangTask;
       
    74 };
       
    75 
       
    76 class WeakProcessor::Task {
       
    77   typedef OopStorage::ParState<false, false> StorageState;
       
    78 
       
    79   WeakProcessorPhaseTimes* _phase_times;
       
    80   uint _nworkers;
       
    81   SubTasksDone _serial_phases_done;
       
    82   StorageState* _storage_states;
       
    83 
       
    84   void initialize();
       
    85 
       
    86 public:
       
    87   Task(uint nworkers);          // No time tracking.
       
    88   Task(WeakProcessorPhaseTimes* phase_times, uint nworkers);
       
    89   ~Task();
       
    90 
       
    91   template<typename IsAlive, typename KeepAlive>
       
    92   void work(uint worker_id, IsAlive* is_alive, KeepAlive* keep_alive);
    44 };
    93 };
    45 
    94 
    46 #endif // SHARE_VM_GC_SHARED_WEAKPROCESSOR_HPP
    95 #endif // SHARE_VM_GC_SHARED_WEAKPROCESSOR_HPP