445 CardTableRS* ct) {
446 if (!mr.is_empty()) {
447 // Caller (process_roots()) claims that all GC threads
448 // execute this call. With UseDynamicNumberOfGCThreads now all
449 // active GC threads execute this call. The number of active GC
450 // threads needs to be passed to par_non_clean_card_iterate_work()
451 // to get proper partitioning and termination.
452 //
453 // This is an example of where n_par_threads() is used instead
454 // of workers()->active_workers(). n_par_threads can be set to 0 to
455 // turn off parallelism. For example when this code is called as
456 // part of verification and SharedHeap::process_roots() is being
457 // used, then n_par_threads() may have been set to 0. active_workers
458 // is not overloaded with the meaning that it is a switch to disable
459 // parallelism and so keeps the meaning of the number of
460 // active gc workers. If parallelism has not been shut off by
461 // setting n_par_threads to 0, then n_par_threads should be
462 // equal to active_workers. When a different mechanism for shutting
463 // off parallelism is used, then active_workers can be used in
464 // place of n_par_threads.
465 // This is an example of a path where n_par_threads is
466 // set to 0 to turn off parallelism.
467 // [7] CardTableModRefBS::non_clean_card_iterate()
468 // [8] CardTableRS::younger_refs_in_space_iterate()
469 // [9] Generation::younger_refs_in_space_iterate()
470 // [10] OneContigSpaceCardGeneration::younger_refs_iterate()
471 // [11] CompactingPermGenGen::younger_refs_iterate()
472 // [12] CardTableRS::younger_refs_iterate()
473 // [13] SharedHeap::process_strong_roots()
474 // [14] G1CollectedHeap::verify()
475 // [15] Universe::verify()
476 // [16] G1CollectedHeap::do_collection_pause_at_safepoint()
477 //
478 int n_threads = SharedHeap::heap()->n_par_threads();
479 bool is_par = n_threads > 0;
480 if (is_par) {
481 #if INCLUDE_ALL_GCS
482 assert(SharedHeap::heap()->n_par_threads() ==
483 SharedHeap::heap()->workers()->active_workers(), "Mismatch");
484 non_clean_card_iterate_parallel_work(sp, mr, cl, ct, n_threads);
485 #else // INCLUDE_ALL_GCS
486 fatal("Parallel gc not supported here.");
487 #endif // INCLUDE_ALL_GCS
488 } else {
489 // We do not call the non_clean_card_iterate_serial() version below because
490 // we want to clear the cards (which non_clean_card_iterate_serial() does not
491 // do for us): clear_cl here does the work of finding contiguous dirty ranges
492 // of cards to process and clear.
493
494 DirtyCardToOopClosure* dcto_cl = sp->new_dcto_cl(cl, precision(),
495 cl->gen_boundary());
496 ClearNoncleanCardWrapper clear_cl(dcto_cl, ct);
497
|
445 CardTableRS* ct) {
446 if (!mr.is_empty()) {
447 // Caller (process_roots()) claims that all GC threads
448 // execute this call. With UseDynamicNumberOfGCThreads now all
449 // active GC threads execute this call. The number of active GC
450 // threads needs to be passed to par_non_clean_card_iterate_work()
451 // to get proper partitioning and termination.
452 //
453 // This is an example of where n_par_threads() is used instead
454 // of workers()->active_workers(). n_par_threads can be set to 0 to
455 // turn off parallelism. For example when this code is called as
456 // part of verification and SharedHeap::process_roots() is being
457 // used, then n_par_threads() may have been set to 0. active_workers
458 // is not overloaded with the meaning that it is a switch to disable
459 // parallelism and so keeps the meaning of the number of
460 // active gc workers. If parallelism has not been shut off by
461 // setting n_par_threads to 0, then n_par_threads should be
462 // equal to active_workers. When a different mechanism for shutting
463 // off parallelism is used, then active_workers can be used in
464 // place of n_par_threads.
465 int n_threads = SharedHeap::heap()->n_par_threads();
466 bool is_par = n_threads > 0;
467 if (is_par) {
468 #if INCLUDE_ALL_GCS
469 assert(SharedHeap::heap()->n_par_threads() ==
470 SharedHeap::heap()->workers()->active_workers(), "Mismatch");
471 non_clean_card_iterate_parallel_work(sp, mr, cl, ct, n_threads);
472 #else // INCLUDE_ALL_GCS
473 fatal("Parallel gc not supported here.");
474 #endif // INCLUDE_ALL_GCS
475 } else {
476 // We do not call the non_clean_card_iterate_serial() version below because
477 // we want to clear the cards (which non_clean_card_iterate_serial() does not
478 // do for us): clear_cl here does the work of finding contiguous dirty ranges
479 // of cards to process and clear.
480
481 DirtyCardToOopClosure* dcto_cl = sp->new_dcto_cl(cl, precision(),
482 cl->gen_boundary());
483 ClearNoncleanCardWrapper clear_cl(dcto_cl, ct);
484
|