hotspot/src/share/vm/gc/shared/preservedMarks.hpp
changeset 39228 32ce84798166
parent 38081 a3bcb7197d45
equal deleted inserted replaced
39227:59ace61f7436 39228:32ce84798166
    28 #include "memory/allocation.hpp"
    28 #include "memory/allocation.hpp"
    29 #include "memory/padded.hpp"
    29 #include "memory/padded.hpp"
    30 #include "oops/oop.hpp"
    30 #include "oops/oop.hpp"
    31 #include "utilities/stack.hpp"
    31 #include "utilities/stack.hpp"
    32 
    32 
    33 class GCTaskManager;
    33 class PreservedMarksSet;
    34 class WorkGang;
    34 class WorkGang;
    35 
    35 
    36 class PreservedMarks VALUE_OBJ_CLASS_SPEC {
    36 class PreservedMarks VALUE_OBJ_CLASS_SPEC {
    37 private:
    37 private:
    38   class OopAndMarkOop {
    38   class OopAndMarkOop {
    59   inline void push_if_necessary(oop obj, markOop m);
    59   inline void push_if_necessary(oop obj, markOop m);
    60   // Iterate over the stack, restore all preserved marks, and
    60   // Iterate over the stack, restore all preserved marks, and
    61   // reclaim the memory taken up by the stack segments.
    61   // reclaim the memory taken up by the stack segments.
    62   void restore();
    62   void restore();
    63 
    63 
       
    64   void restore_and_increment(volatile size_t* const _total_size_addr);
    64   inline static void init_forwarded_mark(oop obj);
    65   inline static void init_forwarded_mark(oop obj);
    65 
    66 
    66   // Assert the stack is empty and has no cached segments.
    67   // Assert the stack is empty and has no cached segments.
    67   void assert_empty() PRODUCT_RETURN;
    68   void assert_empty() PRODUCT_RETURN;
    68 
    69 
    71 };
    72 };
    72 
    73 
    73 class RemoveForwardedPointerClosure: public ObjectClosure {
    74 class RemoveForwardedPointerClosure: public ObjectClosure {
    74 public:
    75 public:
    75   virtual void do_object(oop obj);
    76   virtual void do_object(oop obj);
       
    77 };
       
    78 
       
    79 class RestorePreservedMarksTaskExecutor {
       
    80 public:
       
    81   void virtual restore(PreservedMarksSet* preserved_marks_set,
       
    82                        volatile size_t* total_size_addr) = 0;
       
    83 };
       
    84 
       
    85 class SharedRestorePreservedMarksTaskExecutor : public RestorePreservedMarksTaskExecutor {
       
    86 private:
       
    87     WorkGang* _workers;
       
    88 
       
    89 public:
       
    90     SharedRestorePreservedMarksTaskExecutor(WorkGang* workers) : _workers(workers) { }
       
    91 
       
    92     void restore(PreservedMarksSet* preserved_marks_set,
       
    93                  volatile size_t* total_size_addr);
       
    94 
    76 };
    95 };
    77 
    96 
    78 class PreservedMarksSet : public CHeapObj<mtGC> {
    97 class PreservedMarksSet : public CHeapObj<mtGC> {
    79 private:
    98 private:
    80   // true -> _stacks will be allocated in the C heap
    99   // true -> _stacks will be allocated in the C heap
    89   // Stack array (typically, one stack per GC worker) of length _num.
   108   // Stack array (typically, one stack per GC worker) of length _num.
    90   // This should be != NULL if the stacks have been initialized,
   109   // This should be != NULL if the stacks have been initialized,
    91   // or == NULL if they have not.
   110   // or == NULL if they have not.
    92   Padded<PreservedMarks>* _stacks;
   111   Padded<PreservedMarks>* _stacks;
    93 
   112 
    94   // Internal version of restore() that uses a WorkGang for parallelism.
       
    95   void restore_internal(WorkGang* workers, volatile size_t* total_size_addr);
       
    96 
       
    97   // Internal version of restore() that uses a GCTaskManager for parallelism.
       
    98   void restore_internal(GCTaskManager* gc_task_manager,
       
    99                         volatile size_t* total_size_addr);
       
   100 
       
   101 public:
   113 public:
   102   uint num() const { return _num; }
   114   uint num() const { return _num; }
   103 
   115 
   104   // Return the i'th stack.
   116   // Return the i'th stack.
   105   PreservedMarks* get(uint i = 0) const {
   117   PreservedMarks* get(uint i = 0) const {
   109   }
   121   }
   110 
   122 
   111   // Allocate stack array.
   123   // Allocate stack array.
   112   void init(uint num);
   124   void init(uint num);
   113 
   125 
   114   // Itrerate over all stacks, restore all presered marks, and reclaim
   126   // Iterate over all stacks, restore all preserved marks, and reclaim
   115   // the memory taken up by the stack segments. If the executor is
   127   // the memory taken up by the stack segments.
   116   // NULL, restoration will be done serially. If the executor is not
   128   // Supported executors: SharedRestorePreservedMarksTaskExecutor (Serial, CMS, G1),
   117   // NULL, restoration could be done in parallel (when it makes
   129   // PSRestorePreservedMarksTaskExecutor (PS).
   118   // sense). Supported executors: WorkGang (Serial, CMS, G1),
   130   inline void restore(RestorePreservedMarksTaskExecutor* executor);
   119   // GCTaskManager (PS).
       
   120   template <class E>
       
   121   inline void restore(E* executor);
       
   122 
   131 
   123   // Reclaim stack array.
   132   // Reclaim stack array.
   124   void reclaim();
   133   void reclaim();
   125 
   134 
   126   // Assert all the stacks are empty and have no cached segments.
   135   // Assert all the stacks are empty and have no cached segments.