< prev index next >

src/hotspot/share/gc/shared/satbMarkQueue.hpp

Print this page
rev 53864 : imported patch queue_access
rev 53867 : imported patch remove_shared_satb
rev 53868 : imported patch remove_shared_satb_lock


  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_GC_SHARED_SATBMARKQUEUE_HPP
  26 #define SHARE_GC_SHARED_SATBMARKQUEUE_HPP
  27 
  28 #include "gc/shared/ptrQueue.hpp"
  29 #include "memory/allocation.hpp"
  30 
  31 class JavaThread;
  32 class Monitor;
  33 class SATBMarkQueueSet;
  34 
  35 // Base class for processing the contents of a SATB buffer.
  36 class SATBBufferClosure : public StackObj {
  37 protected:
  38   ~SATBBufferClosure() { }
  39 
  40 public:
  41   // Process the SATB entries in the designated buffer range.
  42   virtual void do_buffer(void** buffer, size_t size) = 0;
  43 };
  44 
  45 // A PtrQueue whose elements are (possibly stale) pointers to object heads.
  46 class SATBMarkQueue: public PtrQueue {
  47   friend class SATBMarkQueueSet;
  48 
  49 private:
  50   // Filter out unwanted entries from the buffer.
  51   inline void filter();


  75 
  76   // Compiler support.
  77   static ByteSize byte_offset_of_index() {
  78     return PtrQueue::byte_offset_of_index<SATBMarkQueue>();
  79   }
  80   using PtrQueue::byte_width_of_index;
  81 
  82   static ByteSize byte_offset_of_buf() {
  83     return PtrQueue::byte_offset_of_buf<SATBMarkQueue>();
  84   }
  85   using PtrQueue::byte_width_of_buf;
  86 
  87   static ByteSize byte_offset_of_active() {
  88     return PtrQueue::byte_offset_of_active<SATBMarkQueue>();
  89   }
  90   using PtrQueue::byte_width_of_active;
  91 
  92 };
  93 
  94 class SATBMarkQueueSet: public PtrQueueSet {
  95   SATBMarkQueue _shared_satb_queue;
  96   size_t _buffer_enqueue_threshold;
  97 
  98 #ifdef ASSERT
  99   void dump_active_states(bool expected_active);
 100   void verify_active_states(bool expected_active);
 101 #endif // ASSERT
 102 
 103 protected:
 104   SATBMarkQueueSet();
 105   ~SATBMarkQueueSet() {}
 106 
 107   template<typename Filter>
 108   void apply_filter(Filter filter, SATBMarkQueue* queue) {
 109     queue->apply_filter(filter);
 110   }
 111 
 112   void initialize(Monitor* cbl_mon,
 113                   BufferNode::Allocator* allocator,
 114                   size_t process_completed_buffers_threshold,
 115                   uint buffer_enqueue_threshold_percentage,
 116                   Mutex* lock);
 117 
 118 public:
 119   virtual SATBMarkQueue& satb_queue_for_thread(JavaThread* const t) const = 0;
 120 
 121   // Apply "set_active(active)" to all SATB queues in the set. It should be
 122   // called only with the world stopped. The method will assert that the
 123   // SATB queues of all threads it visits, as well as the SATB queue
 124   // set itself, has an active value same as expected_active.
 125   void set_active_all_threads(bool active, bool expected_active);
 126 
 127   size_t buffer_enqueue_threshold() const { return _buffer_enqueue_threshold; }
 128   virtual void filter(SATBMarkQueue* queue) = 0;
 129 
 130   // Filter all the currently-active SATB buffers.
 131   void filter_thread_buffers();
 132 
 133   // If there exists some completed buffer, pop and process it, and
 134   // return true.  Otherwise return false.  Processing a buffer
 135   // consists of applying the closure to the active range of the
 136   // buffer; the leading entries may be excluded due to filtering.
 137   bool apply_closure_to_completed_buffer(SATBBufferClosure* cl);
 138 
 139 #ifndef PRODUCT
 140   // Helpful for debugging
 141   void print_all(const char* msg);
 142 #endif // PRODUCT
 143 
 144   SATBMarkQueue* shared_satb_queue() { return &_shared_satb_queue; }
 145 
 146   // If a marking is being abandoned, reset any unprocessed log buffers.
 147   void abandon_partial_marking();
 148 };
 149 
 150 inline void SATBMarkQueue::filter() {
 151   static_cast<SATBMarkQueueSet*>(qset())->filter(this);
 152 }
 153 
 154 // Removes entries from the buffer that are no longer needed, as
 155 // determined by filter. If e is a void* entry in the buffer,
 156 // filter_out(e) must be a valid expression whose value is convertible
 157 // to bool. Entries are removed (filtered out) if the result is true,
 158 // retained if false.
 159 template<typename Filter>
 160 inline void SATBMarkQueue::apply_filter(Filter filter_out) {
 161   void** buf = this->_buf;
 162 
 163   if (buf == NULL) {
 164     // nothing to do




  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_GC_SHARED_SATBMARKQUEUE_HPP
  26 #define SHARE_GC_SHARED_SATBMARKQUEUE_HPP
  27 
  28 #include "gc/shared/ptrQueue.hpp"
  29 #include "memory/allocation.hpp"
  30 
  31 class Thread;
  32 class Monitor;
  33 class SATBMarkQueueSet;
  34 
  35 // Base class for processing the contents of a SATB buffer.
  36 class SATBBufferClosure : public StackObj {
  37 protected:
  38   ~SATBBufferClosure() { }
  39 
  40 public:
  41   // Process the SATB entries in the designated buffer range.
  42   virtual void do_buffer(void** buffer, size_t size) = 0;
  43 };
  44 
  45 // A PtrQueue whose elements are (possibly stale) pointers to object heads.
  46 class SATBMarkQueue: public PtrQueue {
  47   friend class SATBMarkQueueSet;
  48 
  49 private:
  50   // Filter out unwanted entries from the buffer.
  51   inline void filter();


  75 
  76   // Compiler support.
  77   static ByteSize byte_offset_of_index() {
  78     return PtrQueue::byte_offset_of_index<SATBMarkQueue>();
  79   }
  80   using PtrQueue::byte_width_of_index;
  81 
  82   static ByteSize byte_offset_of_buf() {
  83     return PtrQueue::byte_offset_of_buf<SATBMarkQueue>();
  84   }
  85   using PtrQueue::byte_width_of_buf;
  86 
  87   static ByteSize byte_offset_of_active() {
  88     return PtrQueue::byte_offset_of_active<SATBMarkQueue>();
  89   }
  90   using PtrQueue::byte_width_of_active;
  91 
  92 };
  93 
  94 class SATBMarkQueueSet: public PtrQueueSet {

  95   size_t _buffer_enqueue_threshold;
  96 
  97 #ifdef ASSERT
  98   void dump_active_states(bool expected_active);
  99   void verify_active_states(bool expected_active);
 100 #endif // ASSERT
 101 
 102 protected:
 103   SATBMarkQueueSet();
 104   ~SATBMarkQueueSet() {}
 105 
 106   template<typename Filter>
 107   void apply_filter(Filter filter, SATBMarkQueue* queue) {
 108     queue->apply_filter(filter);
 109   }
 110 
 111   void initialize(Monitor* cbl_mon,
 112                   BufferNode::Allocator* allocator,
 113                   size_t process_completed_buffers_threshold,
 114                   uint buffer_enqueue_threshold_percentage);

 115 
 116 public:
 117   virtual SATBMarkQueue& satb_queue_for_thread(Thread* const t) const = 0;
 118 
 119   // Apply "set_active(active)" to all SATB queues in the set. It should be
 120   // called only with the world stopped. The method will assert that the
 121   // SATB queues of all threads it visits, as well as the SATB queue
 122   // set itself, has an active value same as expected_active.
 123   void set_active_all_threads(bool active, bool expected_active);
 124 
 125   size_t buffer_enqueue_threshold() const { return _buffer_enqueue_threshold; }
 126   virtual void filter(SATBMarkQueue* queue) = 0;
 127 
 128   // Filter all the currently-active SATB buffers.
 129   void filter_thread_buffers();
 130 
 131   // If there exists some completed buffer, pop and process it, and
 132   // return true.  Otherwise return false.  Processing a buffer
 133   // consists of applying the closure to the active range of the
 134   // buffer; the leading entries may be excluded due to filtering.
 135   bool apply_closure_to_completed_buffer(SATBBufferClosure* cl);
 136 
 137 #ifndef PRODUCT
 138   // Helpful for debugging
 139   void print_all(const char* msg);
 140 #endif // PRODUCT


 141 
 142   // If a marking is being abandoned, reset any unprocessed log buffers.
 143   void abandon_partial_marking();
 144 };
 145 
 146 inline void SATBMarkQueue::filter() {
 147   static_cast<SATBMarkQueueSet*>(qset())->filter(this);
 148 }
 149 
 150 // Removes entries from the buffer that are no longer needed, as
 151 // determined by filter. If e is a void* entry in the buffer,
 152 // filter_out(e) must be a valid expression whose value is convertible
 153 // to bool. Entries are removed (filtered out) if the result is true,
 154 // retained if false.
 155 template<typename Filter>
 156 inline void SATBMarkQueue::apply_filter(Filter filter_out) {
 157   void** buf = this->_buf;
 158 
 159   if (buf == NULL) {
 160     // nothing to do


< prev index next >