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 #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/g1ThreadLocalData.hpp"
30 #include "gc/g1/heapRegionRemSet.hpp"
31 #include "gc/shared/suspendibleThreadSet.hpp"
32 #include "gc/shared/workgroup.hpp"
33 #include "runtime/atomic.hpp"
34 #include "runtime/mutexLocker.hpp"
35 #include "runtime/safepoint.hpp"
36 #include "runtime/thread.inline.hpp"
37 #include "runtime/threadSMR.hpp"
38
39 // Closure used for updating remembered sets and recording references that
40 // point into the collection set while the mutator is running.
41 // Assumed to be only executed concurrently with the mutator. Yields via
42 // SuspendibleThreadSet after every card.
43 class G1RefineCardConcurrentlyClosure: public CardTableEntryClosure {
44 public:
45 bool do_card_ptr(jbyte* card_ptr, uint worker_i) {
46 G1CollectedHeap::heap()->g1_rem_set()->refine_card_concurrently(card_ptr, worker_i);
47
48 if (SuspendibleThreadSet::should_yield()) {
49 // Caller will actually yield.
50 return false;
51 }
52 // Otherwise, we finished successfully; return true.
53 return true;
313 clear();
314 // Since abandon is done only at safepoints, we can safely manipulate
315 // these queues.
316 for (JavaThreadIteratorWithHandle jtiwh; JavaThread *t = jtiwh.next(); ) {
317 G1ThreadLocalData::dirty_card_queue(t).reset();
318 }
319 shared_dirty_card_queue()->reset();
320 }
321
322 void DirtyCardQueueSet::concatenate_log(DirtyCardQueue& dcq) {
323 if (!dcq.is_empty()) {
324 dcq.flush();
325 }
326 }
327
328 void DirtyCardQueueSet::concatenate_logs() {
329 // Iterate over all the threads, if we find a partial log add it to
330 // the global list of logs. Temporarily turn off the limit on the number
331 // of outstanding buffers.
332 assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint.");
333 size_t save_max_completed_buffers = _max_completed_buffers;
334 _max_completed_buffers = _max_completed_buffers_unlimited;
335 for (JavaThreadIteratorWithHandle jtiwh; JavaThread *t = jtiwh.next(); ) {
336 concatenate_log(G1ThreadLocalData::dirty_card_queue(t));
337 }
338 concatenate_log(_shared_dirty_card_queue);
339 // Restore the completed buffer limit.
340 _max_completed_buffers = save_max_completed_buffers;
341 }
|
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 #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/g1ThreadLocalData.hpp"
30 #include "gc/g1/heapRegionRemSet.hpp"
31 #include "gc/shared/suspendibleThreadSet.hpp"
32 #include "gc/shared/workgroup.hpp"
33 #include "runtime/atomic.hpp"
34 #include "runtime/flags/flagSetting.hpp"
35 #include "runtime/mutexLocker.hpp"
36 #include "runtime/safepoint.hpp"
37 #include "runtime/thread.inline.hpp"
38 #include "runtime/threadSMR.hpp"
39
40 // Closure used for updating remembered sets and recording references that
41 // point into the collection set while the mutator is running.
42 // Assumed to be only executed concurrently with the mutator. Yields via
43 // SuspendibleThreadSet after every card.
44 class G1RefineCardConcurrentlyClosure: public CardTableEntryClosure {
45 public:
46 bool do_card_ptr(jbyte* card_ptr, uint worker_i) {
47 G1CollectedHeap::heap()->g1_rem_set()->refine_card_concurrently(card_ptr, worker_i);
48
49 if (SuspendibleThreadSet::should_yield()) {
50 // Caller will actually yield.
51 return false;
52 }
53 // Otherwise, we finished successfully; return true.
54 return true;
314 clear();
315 // Since abandon is done only at safepoints, we can safely manipulate
316 // these queues.
317 for (JavaThreadIteratorWithHandle jtiwh; JavaThread *t = jtiwh.next(); ) {
318 G1ThreadLocalData::dirty_card_queue(t).reset();
319 }
320 shared_dirty_card_queue()->reset();
321 }
322
323 void DirtyCardQueueSet::concatenate_log(DirtyCardQueue& dcq) {
324 if (!dcq.is_empty()) {
325 dcq.flush();
326 }
327 }
328
329 void DirtyCardQueueSet::concatenate_logs() {
330 // Iterate over all the threads, if we find a partial log add it to
331 // the global list of logs. Temporarily turn off the limit on the number
332 // of outstanding buffers.
333 assert(SafepointSynchronize::is_at_safepoint(), "Must be at safepoint.");
334 SizeTFlagSetting local_max(_max_completed_buffers,
335 MaxCompletedBuffersUnlimited);
336 for (JavaThreadIteratorWithHandle jtiwh; JavaThread *t = jtiwh.next(); ) {
337 concatenate_log(G1ThreadLocalData::dirty_card_queue(t));
338 }
339 concatenate_log(_shared_dirty_card_queue);
340 }
|