hotspot/src/share/vm/memory/sharedHeap.hpp
changeset 29802 d485440c958a
parent 29795 984c5c379c6a
child 29804 dcb9861190d2
equal deleted inserted replaced
29801:2e4a5be5a595 29802:d485440c958a
   111   static SharedHeap* _sh;
   111   static SharedHeap* _sh;
   112 
   112 
   113   // A gc policy, controls global gc resource issues
   113   // A gc policy, controls global gc resource issues
   114   CollectorPolicy *_collector_policy;
   114   CollectorPolicy *_collector_policy;
   115 
   115 
   116   // See the discussion below, in the specification of the reader function
       
   117   // for this variable.
       
   118   int _strong_roots_parity;
       
   119 
       
   120   // If we're doing parallel GC, use this gang of threads.
   116   // If we're doing parallel GC, use this gang of threads.
   121   FlexibleWorkGang* _workers;
   117   FlexibleWorkGang* _workers;
   122 
   118 
   123   // Full initialization is done in a concrete subtype's "initialize"
   119   // Full initialization is done in a concrete subtype's "initialize"
   124   // function.
   120   // function.
   154   // NULL.
   150   // NULL.
   155   virtual Space* space_containing(const void* addr) const = 0;
   151   virtual Space* space_containing(const void* addr) const = 0;
   156 
   152 
   157   bool no_gc_in_progress() { return !is_gc_active(); }
   153   bool no_gc_in_progress() { return !is_gc_active(); }
   158 
   154 
   159   // Some collectors will perform "process_strong_roots" in parallel.
   155   // Note, the below comment needs to be updated to reflect the changes
       
   156   // introduced by JDK-8076225. This should be done as part of JDK-8076289.
       
   157   //
       
   158   //Some collectors will perform "process_strong_roots" in parallel.
   160   // Such a call will involve claiming some fine-grained tasks, such as
   159   // Such a call will involve claiming some fine-grained tasks, such as
   161   // scanning of threads.  To make this process simpler, we provide the
   160   // scanning of threads.  To make this process simpler, we provide the
   162   // "strong_roots_parity()" method.  Collectors that start parallel tasks
   161   // "strong_roots_parity()" method.  Collectors that start parallel tasks
   163   // whose threads invoke "process_strong_roots" must
   162   // whose threads invoke "process_strong_roots" must
   164   // call "change_strong_roots_parity" in sequential code starting such a
   163   // call "change_strong_roots_parity" in sequential code starting such a
   180   //      call to change_strong_roots_parity, and
   179   //      call to change_strong_roots_parity, and
   181   //   c) to never return a distinguished value (zero) with which such
   180   //   c) to never return a distinguished value (zero) with which such
   182   //      task-claiming variables may be initialized, to indicate "never
   181   //      task-claiming variables may be initialized, to indicate "never
   183   //      claimed".
   182   //      claimed".
   184  public:
   183  public:
   185   int strong_roots_parity() { return _strong_roots_parity; }
       
   186 
   184 
   187   // Call these in sequential code around process_roots.
   185   // Call these in sequential code around process_roots.
   188   // strong_roots_prologue calls change_strong_roots_parity, if
   186   // strong_roots_prologue calls change_strong_roots_parity, if
   189   // parallel tasks are enabled.
   187   // parallel tasks are enabled.
   190   class StrongRootsScope : public MarkingCodeBlobClosure::MarkScope {
   188   class StrongRootsScope : public MarkingCodeBlobClosure::MarkScope {
   191     SharedHeap*   _sh;
   189     SharedHeap*   _sh;
   192 
   190 
   193    public:
   191    public:
   194     StrongRootsScope(SharedHeap* heap, bool activate = true);
   192     StrongRootsScope(SharedHeap* heap, bool activate = true);
       
   193     ~StrongRootsScope();
   195   };
   194   };
   196   friend class StrongRootsScope;
       
   197 
   195 
   198  private:
   196  private:
   199   void change_strong_roots_parity();
       
   200 
   197 
   201  public:
   198  public:
   202   FlexibleWorkGang* workers() const { return _workers; }
   199   FlexibleWorkGang* workers() const { return _workers; }
   203 
   200 
   204   // The functions below are helper functions that a subclass of
   201   // The functions below are helper functions that a subclass of