26 #include "gc/shared/cardTableModRefBS.hpp"
27 #include "gc/shared/cardTableRS.hpp"
28 #include "gc/shared/collectedHeap.hpp"
29 #include "gc/shared/genCollectedHeap.hpp"
30 #include "gc/shared/space.inline.hpp"
31 #include "memory/allocation.inline.hpp"
32 #include "memory/virtualspace.hpp"
33 #include "oops/oop.inline.hpp"
34 #include "runtime/java.hpp"
35 #include "runtime/mutexLocker.hpp"
36 #include "runtime/orderAccess.inline.hpp"
37 #include "runtime/vmThread.hpp"
38
39 void CardTableModRefBSForCTRS::
40 non_clean_card_iterate_parallel_work(Space* sp, MemRegion mr,
41 OopsInGenClosure* cl,
42 CardTableRS* ct,
43 uint n_threads) {
44 assert(n_threads > 0, "expected n_threads > 0");
45 assert(n_threads <= ParallelGCThreads,
46 err_msg("n_threads: %u > ParallelGCThreads: %u", n_threads, ParallelGCThreads));
47
48 // Make sure the LNC array is valid for the space.
49 jbyte** lowest_non_clean;
50 uintptr_t lowest_non_clean_base_chunk_index;
51 size_t lowest_non_clean_chunk_size;
52 get_LNC_array_for_space(sp, lowest_non_clean,
53 lowest_non_clean_base_chunk_index,
54 lowest_non_clean_chunk_size);
55
56 uint n_strides = n_threads * ParGCStridesPerThread;
57 SequentialSubTasksDone* pst = sp->par_seq_tasks();
58 // Sets the condition for completion of the subtask (how many threads
59 // need to finish in order to be done).
60 pst->set_n_threads(n_threads);
61 pst->set_n_tasks(n_strides);
62
63 uint stride = 0;
64 while (!pst->is_task_claimed(/* reference */ stride)) {
65 process_stride(sp, mr, stride, n_strides,
66 cl, ct,
353 }
354 assert(0 < cur_chunk_index+1 && cur_chunk_index+1 < lowest_non_clean_chunk_size,
355 "Bounds error.");
356 // It is possible that a dirty card for the last object may have been
357 // cleared before we had a chance to examine it. In that case, the value
358 // will have been logged in the LNC for that chunk.
359 // We need to examine as many chunks to the right as this object
360 // covers. However, we need to bound this checking to the largest
361 // entry in the LNC array: this is because the heap may expand
362 // after the LNC array has been created but before we reach this point,
363 // and the last block in our chunk may have been expanded to include
364 // the expansion delta (and possibly subsequently allocated from, so
365 // it wouldn't be sufficient to check whether that last block was
366 // or was not an object at this point).
367 uintptr_t last_chunk_index_to_check = addr_to_chunk_index(last_block + last_block_size - 1)
368 - lowest_non_clean_base_chunk_index;
369 const uintptr_t last_chunk_index = addr_to_chunk_index(used.last())
370 - lowest_non_clean_base_chunk_index;
371 if (last_chunk_index_to_check > last_chunk_index) {
372 assert(last_block + last_block_size > used.end(),
373 err_msg("Inconsistency detected: last_block [" PTR_FORMAT "," PTR_FORMAT "]"
374 " does not exceed used.end() = " PTR_FORMAT ","
375 " yet last_chunk_index_to_check " INTPTR_FORMAT
376 " exceeds last_chunk_index " INTPTR_FORMAT,
377 p2i(last_block), p2i(last_block + last_block_size),
378 p2i(used.end()),
379 last_chunk_index_to_check, last_chunk_index));
380 assert(sp->used_region().end() > used.end(),
381 err_msg("Expansion did not happen: "
382 "[" PTR_FORMAT "," PTR_FORMAT ") -> [" PTR_FORMAT "," PTR_FORMAT ")",
383 p2i(sp->used_region().start()), p2i(sp->used_region().end()),
384 p2i(used.start()), p2i(used.end())));
385 NOISY(tty->print_cr(" process_chunk_boundary: heap expanded; explicitly bounding last_chunk");)
386 last_chunk_index_to_check = last_chunk_index;
387 }
388 for (uintptr_t lnc_index = cur_chunk_index + 1;
389 lnc_index <= last_chunk_index_to_check;
390 lnc_index++) {
391 jbyte* lnc_card = lowest_non_clean[lnc_index];
392 if (lnc_card != NULL) {
393 // we can stop at the first non-NULL entry we find
394 if (lnc_card <= limit_card) {
395 NOISY(tty->print_cr(" process_chunk_boundary: LNC card " PTR_FORMAT " is lower than limit_card " PTR_FORMAT,
396 " max_to_do will be lowered to " PTR_FORMAT " from " PTR_FORMAT,
397 lnc_card, limit_card, addr_for(lnc_card), max_to_do);)
398 limit_card = lnc_card;
399 max_to_do = addr_for(limit_card);
400 assert(limit_card != NULL && max_to_do != NULL, "Error");
401 }
402 // In any case, we break now
403 break;
404 } // else continue to look for a non-NULL entry if any
|
26 #include "gc/shared/cardTableModRefBS.hpp"
27 #include "gc/shared/cardTableRS.hpp"
28 #include "gc/shared/collectedHeap.hpp"
29 #include "gc/shared/genCollectedHeap.hpp"
30 #include "gc/shared/space.inline.hpp"
31 #include "memory/allocation.inline.hpp"
32 #include "memory/virtualspace.hpp"
33 #include "oops/oop.inline.hpp"
34 #include "runtime/java.hpp"
35 #include "runtime/mutexLocker.hpp"
36 #include "runtime/orderAccess.inline.hpp"
37 #include "runtime/vmThread.hpp"
38
39 void CardTableModRefBSForCTRS::
40 non_clean_card_iterate_parallel_work(Space* sp, MemRegion mr,
41 OopsInGenClosure* cl,
42 CardTableRS* ct,
43 uint n_threads) {
44 assert(n_threads > 0, "expected n_threads > 0");
45 assert(n_threads <= ParallelGCThreads,
46 "n_threads: %u > ParallelGCThreads: %u", n_threads, ParallelGCThreads);
47
48 // Make sure the LNC array is valid for the space.
49 jbyte** lowest_non_clean;
50 uintptr_t lowest_non_clean_base_chunk_index;
51 size_t lowest_non_clean_chunk_size;
52 get_LNC_array_for_space(sp, lowest_non_clean,
53 lowest_non_clean_base_chunk_index,
54 lowest_non_clean_chunk_size);
55
56 uint n_strides = n_threads * ParGCStridesPerThread;
57 SequentialSubTasksDone* pst = sp->par_seq_tasks();
58 // Sets the condition for completion of the subtask (how many threads
59 // need to finish in order to be done).
60 pst->set_n_threads(n_threads);
61 pst->set_n_tasks(n_strides);
62
63 uint stride = 0;
64 while (!pst->is_task_claimed(/* reference */ stride)) {
65 process_stride(sp, mr, stride, n_strides,
66 cl, ct,
353 }
354 assert(0 < cur_chunk_index+1 && cur_chunk_index+1 < lowest_non_clean_chunk_size,
355 "Bounds error.");
356 // It is possible that a dirty card for the last object may have been
357 // cleared before we had a chance to examine it. In that case, the value
358 // will have been logged in the LNC for that chunk.
359 // We need to examine as many chunks to the right as this object
360 // covers. However, we need to bound this checking to the largest
361 // entry in the LNC array: this is because the heap may expand
362 // after the LNC array has been created but before we reach this point,
363 // and the last block in our chunk may have been expanded to include
364 // the expansion delta (and possibly subsequently allocated from, so
365 // it wouldn't be sufficient to check whether that last block was
366 // or was not an object at this point).
367 uintptr_t last_chunk_index_to_check = addr_to_chunk_index(last_block + last_block_size - 1)
368 - lowest_non_clean_base_chunk_index;
369 const uintptr_t last_chunk_index = addr_to_chunk_index(used.last())
370 - lowest_non_clean_base_chunk_index;
371 if (last_chunk_index_to_check > last_chunk_index) {
372 assert(last_block + last_block_size > used.end(),
373 "Inconsistency detected: last_block [" PTR_FORMAT "," PTR_FORMAT "]"
374 " does not exceed used.end() = " PTR_FORMAT ","
375 " yet last_chunk_index_to_check " INTPTR_FORMAT
376 " exceeds last_chunk_index " INTPTR_FORMAT,
377 p2i(last_block), p2i(last_block + last_block_size),
378 p2i(used.end()),
379 last_chunk_index_to_check, last_chunk_index);
380 assert(sp->used_region().end() > used.end(),
381 "Expansion did not happen: "
382 "[" PTR_FORMAT "," PTR_FORMAT ") -> [" PTR_FORMAT "," PTR_FORMAT ")",
383 p2i(sp->used_region().start()), p2i(sp->used_region().end()),
384 p2i(used.start()), p2i(used.end()));
385 NOISY(tty->print_cr(" process_chunk_boundary: heap expanded; explicitly bounding last_chunk");)
386 last_chunk_index_to_check = last_chunk_index;
387 }
388 for (uintptr_t lnc_index = cur_chunk_index + 1;
389 lnc_index <= last_chunk_index_to_check;
390 lnc_index++) {
391 jbyte* lnc_card = lowest_non_clean[lnc_index];
392 if (lnc_card != NULL) {
393 // we can stop at the first non-NULL entry we find
394 if (lnc_card <= limit_card) {
395 NOISY(tty->print_cr(" process_chunk_boundary: LNC card " PTR_FORMAT " is lower than limit_card " PTR_FORMAT,
396 " max_to_do will be lowered to " PTR_FORMAT " from " PTR_FORMAT,
397 lnc_card, limit_card, addr_for(lnc_card), max_to_do);)
398 limit_card = lnc_card;
399 max_to_do = addr_for(limit_card);
400 assert(limit_card != NULL && max_to_do != NULL, "Error");
401 }
402 // In any case, we break now
403 break;
404 } // else continue to look for a non-NULL entry if any
|