< prev index next >

src/hotspot/share/gc/g1/dirtyCardQueue.hpp

Print this page
rev 53150 : [mq]: use_semaphore
rev 53151 : [mq]: tschatzl_review


  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_G1_DIRTYCARDQUEUE_HPP
  26 #define SHARE_VM_GC_G1_DIRTYCARDQUEUE_HPP
  27 
  28 #include "gc/shared/ptrQueue.hpp"
  29 #include "memory/allocation.hpp"
  30 
  31 class FreeIdSet;
  32 class DirtyCardQueueSet;

  33 class JavaThread;
  34 class Monitor;
  35 
  36 // A closure class for processing card table entries.  Note that we don't
  37 // require these closure objects to be stack-allocated.
  38 class CardTableEntryClosure: public CHeapObj<mtGC> {
  39 public:
  40   // Process the card whose card table entry is "card_ptr".  If returns
  41   // "false", terminate the iteration early.
  42   virtual bool do_card_ptr(jbyte* card_ptr, uint worker_i) = 0;
  43 };
  44 
  45 // A ptrQueue whose elements are "oops", pointers to object heads.
  46 class DirtyCardQueue: public PtrQueue {
  47 public:
  48   DirtyCardQueue(DirtyCardQueueSet* qset, bool permanent = false);
  49 
  50   // Flush before destroying; queue may be used to capture pending work while
  51   // doing something else, with auto-flush on completion.
  52   ~DirtyCardQueue();


  86 
  87   // If there are more than stop_at completed buffers, pop one, apply
  88   // the specified closure to its active elements, and return true.
  89   // Otherwise return false.
  90   //
  91   // A completely processed buffer is freed.  However, if a closure
  92   // invocation returns false, processing is stopped and the partially
  93   // processed buffer (with its index updated to exclude the processed
  94   // elements, e.g. up to the element for which the closure returned
  95   // false) is returned to the completed buffer set.
  96   //
  97   // If during_pause is true, stop_at must be zero, and the closure
  98   // must never return false.
  99   bool apply_closure_to_completed_buffer(CardTableEntryClosure* cl,
 100                                          uint worker_i,
 101                                          size_t stop_at,
 102                                          bool during_pause);
 103 
 104   bool mut_process_buffer(BufferNode* node);
 105 
 106   // Protected by the _cbl_mon.
 107   FreeIdSet* _free_ids;
 108 
 109   // The number of completed buffers processed by mutator and rs thread,
 110   // respectively.
 111   jint _processed_buffers_mut;
 112   jint _processed_buffers_rs_thread;
 113 
 114   // Current buffer node used for parallel iteration.
 115   BufferNode* volatile _cur_par_buffer_node;
 116 
 117   void concatenate_log(DirtyCardQueue& dcq);
 118 
 119 public:
 120   DirtyCardQueueSet(bool notify_when_complete = true);

 121 
 122   void initialize(Monitor* cbl_mon,
 123                   BufferNode::Allocator* allocator,
 124                   Mutex* lock,
 125                   bool init_free_ids = false);
 126 
 127   // The number of parallel ids that can be claimed to allow collector or
 128   // mutator threads to do card-processing work.
 129   static uint num_par_ids();
 130 
 131   static void handle_zero_index_for_thread(JavaThread* t);
 132 
 133   // Apply G1RefineCardConcurrentlyClosure to completed buffers until there are stop_at
 134   // completed buffers remaining.
 135   bool refine_completed_buffer_concurrently(uint worker_i, size_t stop_at);
 136 
 137   // Apply the given closure to all completed buffers. The given closure's do_card_ptr
 138   // must never return false. Must only be called during GC.
 139   bool apply_closure_during_gc(CardTableEntryClosure* cl, uint worker_i);
 140 




  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_G1_DIRTYCARDQUEUE_HPP
  26 #define SHARE_VM_GC_G1_DIRTYCARDQUEUE_HPP
  27 
  28 #include "gc/shared/ptrQueue.hpp"
  29 #include "memory/allocation.hpp"
  30 

  31 class DirtyCardQueueSet;
  32 class G1FreeIdSet;
  33 class JavaThread;
  34 class Monitor;
  35 
  36 // A closure class for processing card table entries.  Note that we don't
  37 // require these closure objects to be stack-allocated.
  38 class CardTableEntryClosure: public CHeapObj<mtGC> {
  39 public:
  40   // Process the card whose card table entry is "card_ptr".  If returns
  41   // "false", terminate the iteration early.
  42   virtual bool do_card_ptr(jbyte* card_ptr, uint worker_i) = 0;
  43 };
  44 
  45 // A ptrQueue whose elements are "oops", pointers to object heads.
  46 class DirtyCardQueue: public PtrQueue {
  47 public:
  48   DirtyCardQueue(DirtyCardQueueSet* qset, bool permanent = false);
  49 
  50   // Flush before destroying; queue may be used to capture pending work while
  51   // doing something else, with auto-flush on completion.
  52   ~DirtyCardQueue();


  86 
  87   // If there are more than stop_at completed buffers, pop one, apply
  88   // the specified closure to its active elements, and return true.
  89   // Otherwise return false.
  90   //
  91   // A completely processed buffer is freed.  However, if a closure
  92   // invocation returns false, processing is stopped and the partially
  93   // processed buffer (with its index updated to exclude the processed
  94   // elements, e.g. up to the element for which the closure returned
  95   // false) is returned to the completed buffer set.
  96   //
  97   // If during_pause is true, stop_at must be zero, and the closure
  98   // must never return false.
  99   bool apply_closure_to_completed_buffer(CardTableEntryClosure* cl,
 100                                          uint worker_i,
 101                                          size_t stop_at,
 102                                          bool during_pause);
 103 
 104   bool mut_process_buffer(BufferNode* node);
 105 
 106   G1FreeIdSet* _free_ids;

 107 
 108   // The number of completed buffers processed by mutator and rs thread,
 109   // respectively.
 110   jint _processed_buffers_mut;
 111   jint _processed_buffers_rs_thread;
 112 
 113   // Current buffer node used for parallel iteration.
 114   BufferNode* volatile _cur_par_buffer_node;
 115 
 116   void concatenate_log(DirtyCardQueue& dcq);
 117 
 118 public:
 119   DirtyCardQueueSet(bool notify_when_complete = true);
 120   ~DirtyCardQueueSet();
 121 
 122   void initialize(Monitor* cbl_mon,
 123                   BufferNode::Allocator* allocator,
 124                   Mutex* lock,
 125                   bool init_free_ids = false);
 126 
 127   // The number of parallel ids that can be claimed to allow collector or
 128   // mutator threads to do card-processing work.
 129   static uint num_par_ids();
 130 
 131   static void handle_zero_index_for_thread(JavaThread* t);
 132 
 133   // Apply G1RefineCardConcurrentlyClosure to completed buffers until there are stop_at
 134   // completed buffers remaining.
 135   bool refine_completed_buffer_concurrently(uint worker_i, size_t stop_at);
 136 
 137   // Apply the given closure to all completed buffers. The given closure's do_card_ptr
 138   // must never return false. Must only be called during GC.
 139   bool apply_closure_during_gc(CardTableEntryClosure* cl, uint worker_i);
 140 


< prev index next >