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 #include "precompiled.hpp"
26 #include "gc/g1/dirtyCardQueue.hpp"
27 #include "gc/g1/g1CollectedHeap.inline.hpp"
28 #include "gc/g1/g1RemSet.hpp"
29 #include "gc/g1/heapRegionRemSet.hpp"
30 #include "gc/shared/workgroup.hpp"
31 #include "runtime/atomic.hpp"
32 #include "runtime/mutexLocker.hpp"
33 #include "runtime/safepoint.hpp"
34 #include "runtime/thread.inline.hpp"
35
36 // Closure used for updating remembered sets and recording references that
37 // point into the collection set while the mutator is running.
38 // Assumed to be only executed concurrently with the mutator. Yields via
39 // SuspendibleThreadSet after every card.
40 class G1RefineCardConcurrentlyClosure: public CardTableEntryClosure {
41 public:
42 bool do_card_ptr(jbyte* card_ptr, uint worker_i) {
43 G1CollectedHeap::heap()->g1_rem_set()->refine_card_concurrently(card_ptr, worker_i);
44
45 if (SuspendibleThreadSet::should_yield()) {
46 // Caller will actually yield.
47 return false;
48 }
49 // Otherwise, we finished successfully; return true.
50 return true;
51 }
52 };
53
54 // Represents a set of free small integer ids.
302 nd->set_next(buffers_to_delete);
303 buffers_to_delete = nd;
304 }
305 _n_completed_buffers = 0;
306 _completed_buffers_tail = NULL;
307 DEBUG_ONLY(assert_completed_buffer_list_len_correct_locked());
308 }
309 while (buffers_to_delete != NULL) {
310 BufferNode* nd = buffers_to_delete;
311 buffers_to_delete = nd->next();
312 deallocate_buffer(nd);
313 }
314
315 }
316
317 void DirtyCardQueueSet::abandon_logs() {
318 assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint.");
319 clear();
320 // Since abandon is done only at safepoints, we can safely manipulate
321 // these queues.
322 for (JavaThread* t = Threads::first(); t; t = t->next()) {
323 t->dirty_card_queue().reset();
324 }
325 shared_dirty_card_queue()->reset();
326 }
327
328 void DirtyCardQueueSet::concatenate_log(DirtyCardQueue& dcq) {
329 if (!dcq.is_empty()) {
330 dcq.flush();
331 }
332 }
333
334 void DirtyCardQueueSet::concatenate_logs() {
335 // Iterate over all the threads, if we find a partial log add it to
336 // the global list of logs. Temporarily turn off the limit on the number
337 // of outstanding buffers.
338 int save_max_completed_queue = _max_completed_queue;
339 _max_completed_queue = max_jint;
340 assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint.");
341 for (JavaThread* t = Threads::first(); t; t = t->next()) {
342 concatenate_log(t->dirty_card_queue());
343 }
344 concatenate_log(_shared_dirty_card_queue);
345 // Restore the completed buffer queue limit.
346 _max_completed_queue = save_max_completed_queue;
347 }
|
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 #include "precompiled.hpp"
26 #include "gc/g1/dirtyCardQueue.hpp"
27 #include "gc/g1/g1CollectedHeap.inline.hpp"
28 #include "gc/g1/g1RemSet.hpp"
29 #include "gc/g1/heapRegionRemSet.hpp"
30 #include "gc/shared/workgroup.hpp"
31 #include "runtime/atomic.hpp"
32 #include "runtime/mutexLocker.hpp"
33 #include "runtime/safepoint.hpp"
34 #include "runtime/thread.inline.hpp"
35 #include "runtime/threadSMR.hpp"
36
37 // Closure used for updating remembered sets and recording references that
38 // point into the collection set while the mutator is running.
39 // Assumed to be only executed concurrently with the mutator. Yields via
40 // SuspendibleThreadSet after every card.
41 class G1RefineCardConcurrentlyClosure: public CardTableEntryClosure {
42 public:
43 bool do_card_ptr(jbyte* card_ptr, uint worker_i) {
44 G1CollectedHeap::heap()->g1_rem_set()->refine_card_concurrently(card_ptr, worker_i);
45
46 if (SuspendibleThreadSet::should_yield()) {
47 // Caller will actually yield.
48 return false;
49 }
50 // Otherwise, we finished successfully; return true.
51 return true;
52 }
53 };
54
55 // Represents a set of free small integer ids.
303 nd->set_next(buffers_to_delete);
304 buffers_to_delete = nd;
305 }
306 _n_completed_buffers = 0;
307 _completed_buffers_tail = NULL;
308 DEBUG_ONLY(assert_completed_buffer_list_len_correct_locked());
309 }
310 while (buffers_to_delete != NULL) {
311 BufferNode* nd = buffers_to_delete;
312 buffers_to_delete = nd->next();
313 deallocate_buffer(nd);
314 }
315
316 }
317
318 void DirtyCardQueueSet::abandon_logs() {
319 assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint.");
320 clear();
321 // Since abandon is done only at safepoints, we can safely manipulate
322 // these queues.
323 for (JavaThreadIteratorWithHandle jtiwh; JavaThread *t = jtiwh.next(); ) {
324 t->dirty_card_queue().reset();
325 }
326 shared_dirty_card_queue()->reset();
327 }
328
329 void DirtyCardQueueSet::concatenate_log(DirtyCardQueue& dcq) {
330 if (!dcq.is_empty()) {
331 dcq.flush();
332 }
333 }
334
335 void DirtyCardQueueSet::concatenate_logs() {
336 // Iterate over all the threads, if we find a partial log add it to
337 // the global list of logs. Temporarily turn off the limit on the number
338 // of outstanding buffers.
339 int save_max_completed_queue = _max_completed_queue;
340 _max_completed_queue = max_jint;
341 assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint.");
342 for (JavaThreadIteratorWithHandle jtiwh; JavaThread *t = jtiwh.next(); ) {
343 concatenate_log(t->dirty_card_queue());
344 }
345 concatenate_log(_shared_dirty_card_queue);
346 // Restore the completed buffer queue limit.
347 _max_completed_queue = save_max_completed_queue;
348 }
|