161 HeadTail take();
162 };
163
164 // The most recently created list, which might be for either the next or
165 // a previous safepoint, or might be NULL if the next list hasn't been
166 // created yet. We only need one list because of the requirement that
167 // threads calling add() must first ensure there are no paused buffers
168 // from a previous safepoint. There might be many list instances existing
169 // at the same time though; there can be many threads competing to create
170 // and install the next list, and meanwhile there can be a thread dealing
171 // with the previous list.
172 PausedList* volatile _plist;
173 DEFINE_PAD_MINUS_SIZE(1, DEFAULT_CACHE_LINE_SIZE, sizeof(PausedList*));
174
175 NONCOPYABLE(PausedBuffers);
176
177 public:
178 PausedBuffers();
179 DEBUG_ONLY(~PausedBuffers();)
180
181 // Test whether there are any paused lists.
182 // Thread-safe, but the answer may change immediately.
183 bool is_empty() const;
184
185 // Thread-safe add the buffer to paused list for next safepoint.
186 // precondition: not at safepoint.
187 // precondition: does not have paused buffers from a previous safepoint.
188 void add(BufferNode* node);
189
190 // Thread-safe take all paused buffers for previous safepoints.
191 // precondition: not at safepoint.
192 HeadTail take_previous();
193
194 // Take all the paused buffers.
195 // precondition: at safepoint.
196 HeadTail take_all();
197 };
198
199 // The primary refinement thread, for activation when the processing
200 // threshold is reached. NULL if there aren't any refinement threads.
201 G1ConcurrentRefineThread* _primary_refinement_thread;
202 DEFINE_PAD_MINUS_SIZE(1, DEFAULT_CACHE_LINE_SIZE, sizeof(G1ConcurrentRefineThread*));
203 // Upper bound on the number of cards in the completed and paused buffers.
204 volatile size_t _num_cards;
211 G1FreeIdSet _free_ids;
212
213 // Activation threshold for the primary refinement thread.
214 size_t _process_cards_threshold;
215
216 // If the queue contains more cards than configured here, the
217 // mutator must start doing some of the concurrent refinement work.
218 size_t _max_cards;
219 size_t _max_cards_padding;
220 static const size_t MaxCardsUnlimited = SIZE_MAX;
221
222 // Array of cumulative dirty cards refined by mutator threads.
223 // Array has an entry per id in _free_ids.
224 size_t* _mutator_refined_cards_counters;
225
226 // Verify _num_cards == sum of cards in the completed queue.
227 void verify_num_cards() const NOT_DEBUG_RETURN;
228
229 // Thread-safe add a buffer to paused list for next safepoint.
230 // precondition: not at safepoint.
231 // precondition: does not have paused buffers from a previous safepoint.
232 void record_paused_buffer(BufferNode* node);
233 void enqueue_paused_buffers_aux(const HeadTail& paused);
234 // Thread-safe transfer paused buffers for previous safepoints to the queue.
235 // precondition: not at safepoint.
236 void enqueue_previous_paused_buffers();
237 // Transfer all paused buffers to the queue.
238 // precondition: at safepoint.
239 void enqueue_all_paused_buffers();
240
241 void abandon_completed_buffers();
242
243 // Refine the cards in "node" from its index to buffer_size.
244 // Stops processing if SuspendibleThreadSet::should_yield() is true.
245 // Returns true if the entire buffer was processed, false if there
246 // is a pending yield request. The node's index is updated to exclude
247 // the processed elements, e.g. up to the element before processing
248 // stopped, or one past the last element if the entire buffer was
249 // processed. Increments *total_refined_cards by the number of cards
250 // processed and removed from the buffer.
251 bool refine_buffer(BufferNode* node, uint worker_id, size_t* total_refined_cards);
|
161 HeadTail take();
162 };
163
164 // The most recently created list, which might be for either the next or
165 // a previous safepoint, or might be NULL if the next list hasn't been
166 // created yet. We only need one list because of the requirement that
167 // threads calling add() must first ensure there are no paused buffers
168 // from a previous safepoint. There might be many list instances existing
169 // at the same time though; there can be many threads competing to create
170 // and install the next list, and meanwhile there can be a thread dealing
171 // with the previous list.
172 PausedList* volatile _plist;
173 DEFINE_PAD_MINUS_SIZE(1, DEFAULT_CACHE_LINE_SIZE, sizeof(PausedList*));
174
175 NONCOPYABLE(PausedBuffers);
176
177 public:
178 PausedBuffers();
179 DEBUG_ONLY(~PausedBuffers();)
180
181 // Thread-safe add the buffer to paused list for next safepoint.
182 // precondition: not at safepoint.
183 // precondition: does not have paused buffers from a previous safepoint.
184 void add(BufferNode* node);
185
186 // Thread-safe take all paused buffers for previous safepoints.
187 // precondition: not at safepoint.
188 HeadTail take_previous();
189
190 // Take all the paused buffers.
191 // precondition: at safepoint.
192 HeadTail take_all();
193 };
194
195 // The primary refinement thread, for activation when the processing
196 // threshold is reached. NULL if there aren't any refinement threads.
197 G1ConcurrentRefineThread* _primary_refinement_thread;
198 DEFINE_PAD_MINUS_SIZE(1, DEFAULT_CACHE_LINE_SIZE, sizeof(G1ConcurrentRefineThread*));
199 // Upper bound on the number of cards in the completed and paused buffers.
200 volatile size_t _num_cards;
207 G1FreeIdSet _free_ids;
208
209 // Activation threshold for the primary refinement thread.
210 size_t _process_cards_threshold;
211
212 // If the queue contains more cards than configured here, the
213 // mutator must start doing some of the concurrent refinement work.
214 size_t _max_cards;
215 size_t _max_cards_padding;
216 static const size_t MaxCardsUnlimited = SIZE_MAX;
217
218 // Array of cumulative dirty cards refined by mutator threads.
219 // Array has an entry per id in _free_ids.
220 size_t* _mutator_refined_cards_counters;
221
222 // Verify _num_cards == sum of cards in the completed queue.
223 void verify_num_cards() const NOT_DEBUG_RETURN;
224
225 // Thread-safe add a buffer to paused list for next safepoint.
226 // precondition: not at safepoint.
227 void record_paused_buffer(BufferNode* node);
228 void enqueue_paused_buffers_aux(const HeadTail& paused);
229 // Thread-safe transfer paused buffers for previous safepoints to the queue.
230 // precondition: not at safepoint.
231 void enqueue_previous_paused_buffers();
232 // Transfer all paused buffers to the queue.
233 // precondition: at safepoint.
234 void enqueue_all_paused_buffers();
235
236 void abandon_completed_buffers();
237
238 // Refine the cards in "node" from its index to buffer_size.
239 // Stops processing if SuspendibleThreadSet::should_yield() is true.
240 // Returns true if the entire buffer was processed, false if there
241 // is a pending yield request. The node's index is updated to exclude
242 // the processed elements, e.g. up to the element before processing
243 // stopped, or one past the last element if the entire buffer was
244 // processed. Increments *total_refined_cards by the number of cards
245 // processed and removed from the buffer.
246 bool refine_buffer(BufferNode* node, uint worker_id, size_t* total_refined_cards);
|