< 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
rev 11985 : 8165949: Serial and ConcMarkSweep do not unload strings when class unloading is disabled
Reviewed-by:
rev 11986 : imported patch 8165949-on-jesper-mik-rev
rev 11987 : [mq]: 8165949-on-jesper-stefank-rev


 596     JNIHandles::oops_do(strong_roots);
 597   }
 598 
 599   if (!_process_strong_tasks->is_task_claimed(GCH_PS_ObjectSynchronizer_oops_do)) {
 600     ObjectSynchronizer::oops_do(strong_roots);
 601   }
 602   if (!_process_strong_tasks->is_task_claimed(GCH_PS_FlatProfiler_oops_do)) {
 603     FlatProfiler::oops_do(strong_roots);
 604   }
 605   if (!_process_strong_tasks->is_task_claimed(GCH_PS_Management_oops_do)) {
 606     Management::oops_do(strong_roots);
 607   }
 608   if (!_process_strong_tasks->is_task_claimed(GCH_PS_jvmti_oops_do)) {
 609     JvmtiExport::oops_do(strong_roots);
 610   }
 611 
 612   if (!_process_strong_tasks->is_task_claimed(GCH_PS_SystemDictionary_oops_do)) {
 613     SystemDictionary::roots_oops_do(strong_roots, weak_roots);
 614   }
 615 
 616   // All threads execute the following. A specific chunk of buckets
 617   // from the StringTable are the individual tasks.
 618   if (weak_roots != NULL) {
 619     if (is_par) {
 620       StringTable::possibly_parallel_oops_do(weak_roots);
 621     } else {
 622       StringTable::oops_do(weak_roots);
 623     }
 624   }
 625 
 626   if (!_process_strong_tasks->is_task_claimed(GCH_PS_CodeCache_oops_do)) {
 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::cms_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   MarkingCodeBlobClosure mark_code_closure(root_closure, !CodeBlobToOopClosure::FixRelocations);
 676   OopsInGenClosure* weak_roots = only_strong_roots ? NULL : root_closure;
 677   CLDClosure* weak_cld_closure = only_strong_roots ? NULL : cld_closure;
 678 
 679   process_roots(scope, so, root_closure, weak_roots, cld_closure, weak_cld_closure, &mark_code_closure);



 680 
 681   if (young_gen_as_roots &&
 682       !_process_strong_tasks->is_task_claimed(GCH_PS_younger_gens)) {
 683     root_closure->set_generation(_young_gen);
 684     _young_gen->oop_iterate(root_closure);
 685     root_closure->reset_generation();
 686   }
 687 
 688   _process_strong_tasks->all_tasks_completed(scope->n_threads());
 689 }
 690 
 691 void GenCollectedHeap::full_process_roots(StrongRootsScope* scope,
 692                                           bool only_strong_roots,
 693                                           ScanningOption so,
 694                                           bool is_adjust_phase,


 695                                           OopsInGenClosure* root_closure,
 696                                           CLDClosure* cld_closure) {
 697   MarkingCodeBlobClosure mark_code_closure(root_closure, is_adjust_phase);
 698   OopsInGenClosure* weak_roots = is_adjust_phase ? root_closure : NULL;
 699   CLDClosure* weak_cld_closure = only_strong_roots ? NULL : cld_closure;
 700 
 701   process_roots(scope, so, root_closure, weak_roots, cld_closure, weak_cld_closure, &mark_code_closure);






 702 
 703   _process_strong_tasks->all_tasks_completed(scope->n_threads());
 704 }
 705 
 706 void GenCollectedHeap::gen_process_weak_roots(OopClosure* root_closure) {
 707   JNIHandles::weak_oops_do(root_closure);
 708   _young_gen->ref_processor()->weak_oops_do(root_closure);
 709   _old_gen->ref_processor()->weak_oops_do(root_closure);
 710 }
 711 
 712 #define GCH_SINCE_SAVE_MARKS_ITERATE_DEFN(OopClosureType, nv_suffix)    \
 713 void GenCollectedHeap::                                                 \
 714 oop_since_save_marks_iterate(GenerationType gen,                        \
 715                              OopClosureType* cur,                       \
 716                              OopClosureType* older) {                   \
 717   if (gen == YoungGen) {                              \
 718     _young_gen->oop_since_save_marks_iterate##nv_suffix(cur);           \
 719     _old_gen->oop_since_save_marks_iterate##nv_suffix(older);           \
 720   } else {                                                              \
 721     _old_gen->oop_since_save_marks_iterate##nv_suffix(cur);             \




 596     JNIHandles::oops_do(strong_roots);
 597   }
 598 
 599   if (!_process_strong_tasks->is_task_claimed(GCH_PS_ObjectSynchronizer_oops_do)) {
 600     ObjectSynchronizer::oops_do(strong_roots);
 601   }
 602   if (!_process_strong_tasks->is_task_claimed(GCH_PS_FlatProfiler_oops_do)) {
 603     FlatProfiler::oops_do(strong_roots);
 604   }
 605   if (!_process_strong_tasks->is_task_claimed(GCH_PS_Management_oops_do)) {
 606     Management::oops_do(strong_roots);
 607   }
 608   if (!_process_strong_tasks->is_task_claimed(GCH_PS_jvmti_oops_do)) {
 609     JvmtiExport::oops_do(strong_roots);
 610   }
 611 
 612   if (!_process_strong_tasks->is_task_claimed(GCH_PS_SystemDictionary_oops_do)) {
 613     SystemDictionary::roots_oops_do(strong_roots, weak_roots);
 614   }
 615 










 616   if (!_process_strong_tasks->is_task_claimed(GCH_PS_CodeCache_oops_do)) {
 617     if (so & SO_ScavengeCodeCache) {
 618       assert(code_roots != NULL, "must supply closure for code cache");
 619 
 620       // We only visit parts of the CodeCache when scavenging.
 621       CodeCache::scavenge_root_nmethods_do(code_roots);
 622     }
 623     if (so & SO_AllCodeCache) {
 624       assert(code_roots != NULL, "must supply closure for code cache");
 625 
 626       // CMSCollector uses this to do intermediate-strength collections.
 627       // We scan the entire code cache, since CodeCache::do_unloading is not called.
 628       CodeCache::blobs_do(code_roots);
 629     }
 630     // Verify that the code cache contents are not subject to
 631     // movement by a scavenging collection.
 632     DEBUG_ONLY(CodeBlobToOopClosure assert_code_is_non_scavengable(&assert_is_non_scavengable_closure, !CodeBlobToOopClosure::FixRelocations));
 633     DEBUG_ONLY(CodeCache::asserted_non_scavengable_nmethods_do(&assert_code_is_non_scavengable));
 634   }
 635 }
 636 
 637 void GenCollectedHeap::process_string_table_roots(StrongRootsScope* scope,
 638                                                   OopClosure* root_closure) {
 639   assert(root_closure != NULL, "Must be set");
 640   // All threads execute the following. A specific chunk of buckets
 641   // from the StringTable are the individual tasks.
 642   if (scope->n_threads() > 1) {
 643     StringTable::possibly_parallel_oops_do(root_closure);
 644   } else {
 645     StringTable::oops_do(root_closure);
 646   }
 647 }
 648 
 649 void GenCollectedHeap::young_process_roots(StrongRootsScope* scope,
 650                                            OopsInGenClosure* root_closure,
 651                                            OopsInGenClosure* old_gen_closure,
 652                                            CLDClosure* cld_closure) {
 653   MarkingCodeBlobClosure mark_code_closure(root_closure, CodeBlobToOopClosure::FixRelocations);
 654 
 655   process_roots(scope, SO_ScavengeCodeCache, root_closure, root_closure,
 656                 cld_closure, cld_closure, &mark_code_closure);
 657   process_string_table_roots(scope, root_closure);
 658 
 659   if (!_process_strong_tasks->is_task_claimed(GCH_PS_younger_gens)) {
 660     root_closure->reset_generation();
 661   }
 662 
 663   // When collection is parallel, all threads get to cooperate to do
 664   // old generation scanning.
 665   old_gen_closure->set_generation(_old_gen);
 666   rem_set()->younger_refs_iterate(_old_gen, old_gen_closure, scope->n_threads());
 667   old_gen_closure->reset_generation();
 668 
 669   _process_strong_tasks->all_tasks_completed(scope->n_threads());
 670 }
 671 
 672 void GenCollectedHeap::cms_process_roots(StrongRootsScope* scope,
 673                                          bool young_gen_as_roots,
 674                                          ScanningOption so,
 675                                          bool only_strong_roots,
 676                                          OopsInGenClosure* root_closure,
 677                                          CLDClosure* cld_closure) {
 678   MarkingCodeBlobClosure mark_code_closure(root_closure, !CodeBlobToOopClosure::FixRelocations);
 679   OopsInGenClosure* weak_roots = only_strong_roots ? NULL : root_closure;
 680   CLDClosure* weak_cld_closure = only_strong_roots ? NULL : cld_closure;
 681 
 682   process_roots(scope, so, root_closure, weak_roots, cld_closure, weak_cld_closure, &mark_code_closure);
 683   if (!only_strong_roots) {
 684     process_string_table_roots(scope, root_closure);
 685   }
 686 
 687   if (young_gen_as_roots &&
 688       !_process_strong_tasks->is_task_claimed(GCH_PS_younger_gens)) {
 689     root_closure->set_generation(_young_gen);
 690     _young_gen->oop_iterate(root_closure);
 691     root_closure->reset_generation();
 692   }
 693 
 694   _process_strong_tasks->all_tasks_completed(scope->n_threads());
 695 }
 696 
 697 void GenCollectedHeap::full_process_roots(StrongRootsScope* scope,


 698                                           bool is_adjust_phase,
 699                                           ScanningOption so,
 700                                           bool only_strong_roots,
 701                                           OopsInGenClosure* root_closure,
 702                                           CLDClosure* cld_closure) {
 703   MarkingCodeBlobClosure mark_code_closure(root_closure, is_adjust_phase);
 704   OopsInGenClosure* weak_roots = only_strong_roots ? NULL : root_closure;
 705   CLDClosure* weak_cld_closure = only_strong_roots ? NULL : cld_closure;
 706 
 707   process_roots(scope, so, root_closure, weak_roots, cld_closure, weak_cld_closure, &mark_code_closure);
 708   if (is_adjust_phase) {
 709     // We never treat the string table as roots during marking
 710     // for the full gc, so we only need to process it during
 711     // the adjust phase.
 712     process_string_table_roots(scope, root_closure);
 713   }
 714 
 715   _process_strong_tasks->all_tasks_completed(scope->n_threads());
 716 }
 717 
 718 void GenCollectedHeap::gen_process_weak_roots(OopClosure* root_closure) {
 719   JNIHandles::weak_oops_do(root_closure);
 720   _young_gen->ref_processor()->weak_oops_do(root_closure);
 721   _old_gen->ref_processor()->weak_oops_do(root_closure);
 722 }
 723 
 724 #define GCH_SINCE_SAVE_MARKS_ITERATE_DEFN(OopClosureType, nv_suffix)    \
 725 void GenCollectedHeap::                                                 \
 726 oop_since_save_marks_iterate(GenerationType gen,                        \
 727                              OopClosureType* cur,                       \
 728                              OopClosureType* older) {                   \
 729   if (gen == YoungGen) {                              \
 730     _young_gen->oop_since_save_marks_iterate##nv_suffix(cur);           \
 731     _old_gen->oop_since_save_marks_iterate##nv_suffix(older);           \
 732   } else {                                                              \
 733     _old_gen->oop_since_save_marks_iterate##nv_suffix(cur);             \


< prev index next >