< prev index next >

src/share/vm/gc/shared/genCollectedHeap.cpp

Print this page
rev 11983 : 8166276: Refactor gen_process_roots to allow simpler fix for 8165949
Reviewed-by:
Contributed-by: jesper.wilhelmsson@oracle.com


 627     if (so & SO_ScavengeCodeCache) {
 628       assert(code_roots != NULL, "must supply closure for code cache");
 629 
 630       // We only visit parts of the CodeCache when scavenging.
 631       CodeCache::scavenge_root_nmethods_do(code_roots);
 632     }
 633     if (so & SO_AllCodeCache) {
 634       assert(code_roots != NULL, "must supply closure for code cache");
 635 
 636       // CMSCollector uses this to do intermediate-strength collections.
 637       // We scan the entire code cache, since CodeCache::do_unloading is not called.
 638       CodeCache::blobs_do(code_roots);
 639     }
 640     // Verify that the code cache contents are not subject to
 641     // movement by a scavenging collection.
 642     DEBUG_ONLY(CodeBlobToOopClosure assert_code_is_non_scavengable(&assert_is_non_scavengable_closure, !CodeBlobToOopClosure::FixRelocations));
 643     DEBUG_ONLY(CodeCache::asserted_non_scavengable_nmethods_do(&assert_code_is_non_scavengable));
 644   }
 645 }
 646 
 647 void GenCollectedHeap::gen_process_roots(StrongRootsScope* scope,
 648                                          GenerationType type,





















 649                                          bool young_gen_as_roots,
 650                                          ScanningOption so,
 651                                          bool only_strong_roots,
 652                                          OopsInGenClosure* not_older_gens,
 653                                          OopsInGenClosure* older_gens,
 654                                          CLDClosure* cld_closure) {
 655   const bool is_adjust_phase = !only_strong_roots && !young_gen_as_roots;
 656 
 657   bool is_moving_collection = false;
 658   if (type == YoungGen || is_adjust_phase) {
 659     // young collections are always moving
 660     is_moving_collection = true;
 661   }
 662 
 663   MarkingCodeBlobClosure mark_code_closure(not_older_gens, is_moving_collection);
 664   OopsInGenClosure* weak_roots = only_strong_roots ? NULL : not_older_gens;
 665   CLDClosure* weak_cld_closure = only_strong_roots ? NULL : cld_closure;
 666 
 667   process_roots(scope, so,
 668                 not_older_gens, weak_roots,
 669                 cld_closure, weak_cld_closure,
 670                 &mark_code_closure);
 671 
 672   if (young_gen_as_roots) {
 673     if (!_process_strong_tasks->is_task_claimed(GCH_PS_younger_gens)) {
 674       if (type == OldGen) {
 675         not_older_gens->set_generation(_young_gen);
 676         _young_gen->oop_iterate(not_older_gens);
 677       }
 678       not_older_gens->reset_generation();
 679     }
 680   }
 681   // When collection is parallel, all threads get to cooperate to do
 682   // old generation scanning.
 683   if (type == YoungGen) {
 684     older_gens->set_generation(_old_gen);
 685     rem_set()->younger_refs_iterate(_old_gen, older_gens, scope->n_threads());
 686     older_gens->reset_generation();
 687   }
 688 
 689   _process_strong_tasks->all_tasks_completed(scope->n_threads());
 690 }
 691 
 692 void GenCollectedHeap::gen_process_weak_roots(OopClosure* root_closure) {
 693   JNIHandles::weak_oops_do(root_closure);
 694   _young_gen->ref_processor()->weak_oops_do(root_closure);
 695   _old_gen->ref_processor()->weak_oops_do(root_closure);
 696 }
 697 
 698 #define GCH_SINCE_SAVE_MARKS_ITERATE_DEFN(OopClosureType, nv_suffix)    \
 699 void GenCollectedHeap::                                                 \
 700 oop_since_save_marks_iterate(GenerationType gen,                        \
 701                              OopClosureType* cur,                       \
 702                              OopClosureType* older) {                   \
 703   if (gen == YoungGen) {                              \
 704     _young_gen->oop_since_save_marks_iterate##nv_suffix(cur);           \
 705     _old_gen->oop_since_save_marks_iterate##nv_suffix(older);           \
 706   } else {                                                              \




 627     if (so & SO_ScavengeCodeCache) {
 628       assert(code_roots != NULL, "must supply closure for code cache");
 629 
 630       // We only visit parts of the CodeCache when scavenging.
 631       CodeCache::scavenge_root_nmethods_do(code_roots);
 632     }
 633     if (so & SO_AllCodeCache) {
 634       assert(code_roots != NULL, "must supply closure for code cache");
 635 
 636       // CMSCollector uses this to do intermediate-strength collections.
 637       // We scan the entire code cache, since CodeCache::do_unloading is not called.
 638       CodeCache::blobs_do(code_roots);
 639     }
 640     // Verify that the code cache contents are not subject to
 641     // movement by a scavenging collection.
 642     DEBUG_ONLY(CodeBlobToOopClosure assert_code_is_non_scavengable(&assert_is_non_scavengable_closure, !CodeBlobToOopClosure::FixRelocations));
 643     DEBUG_ONLY(CodeCache::asserted_non_scavengable_nmethods_do(&assert_code_is_non_scavengable));
 644   }
 645 }
 646 
 647 void GenCollectedHeap::young_process_roots(StrongRootsScope* scope,
 648                                            OopsInGenClosure* root_closure,
 649                                            OopsInGenClosure* old_gen_closure,
 650                                            CLDClosure* cld_closure) {
 651   MarkingCodeBlobClosure mark_code_closure(root_closure, CodeBlobToOopClosure::FixRelocations);
 652 
 653   process_roots(scope, SO_ScavengeCodeCache, root_closure, root_closure,
 654                 cld_closure, cld_closure, &mark_code_closure);
 655 
 656   if (!_process_strong_tasks->is_task_claimed(GCH_PS_younger_gens)) {
 657     root_closure->reset_generation();
 658   }
 659 
 660   // When collection is parallel, all threads get to cooperate to do
 661   // old generation scanning.
 662   old_gen_closure->set_generation(_old_gen);
 663   rem_set()->younger_refs_iterate(_old_gen, old_gen_closure, scope->n_threads());
 664   old_gen_closure->reset_generation();
 665 
 666   _process_strong_tasks->all_tasks_completed(scope->n_threads());
 667 }
 668 
 669 void GenCollectedHeap::old_process_roots(StrongRootsScope* scope,
 670                                          bool young_gen_as_roots,
 671                                          ScanningOption so,
 672                                          bool only_strong_roots,
 673                                          OopsInGenClosure* root_closure,

 674                                          CLDClosure* cld_closure) {
 675   const bool is_moving_collection = !only_strong_roots && !young_gen_as_roots;






 676 
 677   MarkingCodeBlobClosure mark_code_closure(root_closure, is_moving_collection);
 678   OopsInGenClosure* weak_roots = only_strong_roots ? NULL : root_closure;
 679   CLDClosure* weak_cld_closure = only_strong_roots ? NULL : cld_closure;
 680 
 681   process_roots(scope, so, root_closure, weak_roots, cld_closure, weak_cld_closure, &mark_code_closure);



 682 
 683   if (young_gen_as_roots &&
 684       !_process_strong_tasks->is_task_claimed(GCH_PS_younger_gens)) {
 685     root_closure->set_generation(_young_gen);
 686     _young_gen->oop_iterate(root_closure);
 687     root_closure->reset_generation();










 688   }
 689 
 690   _process_strong_tasks->all_tasks_completed(scope->n_threads());
 691 }
 692 
 693 void GenCollectedHeap::gen_process_weak_roots(OopClosure* root_closure) {
 694   JNIHandles::weak_oops_do(root_closure);
 695   _young_gen->ref_processor()->weak_oops_do(root_closure);
 696   _old_gen->ref_processor()->weak_oops_do(root_closure);
 697 }
 698 
 699 #define GCH_SINCE_SAVE_MARKS_ITERATE_DEFN(OopClosureType, nv_suffix)    \
 700 void GenCollectedHeap::                                                 \
 701 oop_since_save_marks_iterate(GenerationType gen,                        \
 702                              OopClosureType* cur,                       \
 703                              OopClosureType* older) {                   \
 704   if (gen == YoungGen) {                              \
 705     _young_gen->oop_since_save_marks_iterate##nv_suffix(cur);           \
 706     _old_gen->oop_since_save_marks_iterate##nv_suffix(older);           \
 707   } else {                                                              \


< prev index next >