< prev index next >

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

Print this page
rev 50373 : 8195097: Make it possible to process StringTable outside safepoint
Reviewed-by:
rev 50375 : [mq]: 8195097-stringtable-v2


  27 #include "classfile/symbolTable.hpp"
  28 #include "classfile/stringTable.hpp"
  29 #include "classfile/systemDictionary.hpp"
  30 #include "classfile/vmSymbols.hpp"
  31 #include "code/codeCache.hpp"
  32 #include "code/icBuffer.hpp"
  33 #include "gc/serial/defNewGeneration.hpp"
  34 #include "gc/shared/adaptiveSizePolicy.hpp"
  35 #include "gc/shared/cardTableBarrierSet.hpp"
  36 #include "gc/shared/cardTableRS.hpp"
  37 #include "gc/shared/collectedHeap.inline.hpp"
  38 #include "gc/shared/collectorCounters.hpp"
  39 #include "gc/shared/gcId.hpp"
  40 #include "gc/shared/gcLocker.hpp"
  41 #include "gc/shared/gcPolicyCounters.hpp"
  42 #include "gc/shared/gcTrace.hpp"
  43 #include "gc/shared/gcTraceTime.inline.hpp"
  44 #include "gc/shared/genCollectedHeap.hpp"
  45 #include "gc/shared/genOopClosures.inline.hpp"
  46 #include "gc/shared/generationSpec.hpp"

  47 #include "gc/shared/space.hpp"
  48 #include "gc/shared/strongRootsScope.hpp"
  49 #include "gc/shared/vmGCOperations.hpp"
  50 #include "gc/shared/weakProcessor.hpp"
  51 #include "gc/shared/workgroup.hpp"
  52 #include "memory/filemap.hpp"
  53 #include "memory/metaspaceCounters.hpp"
  54 #include "memory/resourceArea.hpp"
  55 #include "oops/oop.inline.hpp"
  56 #include "runtime/biasedLocking.hpp"
  57 #include "runtime/flags/flagSetting.hpp"
  58 #include "runtime/handles.hpp"
  59 #include "runtime/handles.inline.hpp"
  60 #include "runtime/java.hpp"
  61 #include "runtime/vmThread.hpp"
  62 #include "services/management.hpp"
  63 #include "services/memoryService.hpp"
  64 #include "utilities/debug.hpp"
  65 #include "utilities/formatBuffer.hpp"
  66 #include "utilities/macros.hpp"


 834       assert(code_roots != NULL, "must supply closure for code cache");
 835 
 836       // We only visit parts of the CodeCache when scavenging.
 837       CodeCache::scavenge_root_nmethods_do(code_roots);
 838     }
 839     if (so & SO_AllCodeCache) {
 840       assert(code_roots != NULL, "must supply closure for code cache");
 841 
 842       // CMSCollector uses this to do intermediate-strength collections.
 843       // We scan the entire code cache, since CodeCache::do_unloading is not called.
 844       CodeCache::blobs_do(code_roots);
 845     }
 846     // Verify that the code cache contents are not subject to
 847     // movement by a scavenging collection.
 848     DEBUG_ONLY(CodeBlobToOopClosure assert_code_is_non_scavengable(&assert_is_non_scavengable_closure, !CodeBlobToOopClosure::FixRelocations));
 849     DEBUG_ONLY(CodeCache::asserted_non_scavengable_nmethods_do(&assert_code_is_non_scavengable));
 850   }
 851 }
 852 
 853 void GenCollectedHeap::process_string_table_roots(StrongRootsScope* scope,
 854                                                   OopClosure* root_closure) {

 855   assert(root_closure != NULL, "Must be set");
 856   // All threads execute the following. A specific chunk of buckets
 857   // from the StringTable are the individual tasks.




 858   if (scope->n_threads() > 1) {
 859     StringTable::possibly_parallel_oops_do(root_closure);
 860   } else {
 861     StringTable::oops_do(root_closure);
 862   }
 863 }
 864 
 865 void GenCollectedHeap::young_process_roots(StrongRootsScope* scope,
 866                                            OopsInGenClosure* root_closure,
 867                                            OopsInGenClosure* old_gen_closure,
 868                                            CLDClosure* cld_closure) {

 869   MarkingCodeBlobClosure mark_code_closure(root_closure, CodeBlobToOopClosure::FixRelocations);
 870 
 871   process_roots(scope, SO_ScavengeCodeCache, root_closure,
 872                 cld_closure, cld_closure, &mark_code_closure);
 873   process_string_table_roots(scope, root_closure);
 874 
 875   if (!_process_strong_tasks->is_task_claimed(GCH_PS_younger_gens)) {
 876     root_closure->reset_generation();
 877   }
 878 
 879   // When collection is parallel, all threads get to cooperate to do
 880   // old generation scanning.
 881   old_gen_closure->set_generation(_old_gen);
 882   rem_set()->younger_refs_iterate(_old_gen, old_gen_closure, scope->n_threads());
 883   old_gen_closure->reset_generation();
 884 
 885   _process_strong_tasks->all_tasks_completed(scope->n_threads());
 886 }
 887 
 888 void GenCollectedHeap::full_process_roots(StrongRootsScope* scope,
 889                                           bool is_adjust_phase,
 890                                           ScanningOption so,
 891                                           bool only_strong_roots,
 892                                           OopsInGenClosure* root_closure,
 893                                           CLDClosure* cld_closure) {

 894   MarkingCodeBlobClosure mark_code_closure(root_closure, is_adjust_phase);
 895   CLDClosure* weak_cld_closure = only_strong_roots ? NULL : cld_closure;
 896 
 897   process_roots(scope, so, root_closure, cld_closure, weak_cld_closure, &mark_code_closure);
 898   if (is_adjust_phase) {
 899     // We never treat the string table as roots during marking
 900     // for the full gc, so we only need to process it during
 901     // the adjust phase.
 902     process_string_table_roots(scope, root_closure);
 903   }
 904 
 905   _process_strong_tasks->all_tasks_completed(scope->n_threads());
 906 }
 907 
 908 void GenCollectedHeap::gen_process_weak_roots(OopClosure* root_closure) {
 909   WeakProcessor::oops_do(root_closure);
 910   _young_gen->ref_processor()->weak_oops_do(root_closure);
 911   _old_gen->ref_processor()->weak_oops_do(root_closure);
 912 }
 913 
 914 bool GenCollectedHeap::no_allocs_since_save_marks() {
 915   return _young_gen->no_allocs_since_save_marks() &&
 916          _old_gen->no_allocs_since_save_marks();
 917 }
 918 
 919 bool GenCollectedHeap::supports_inline_contig_alloc() const {
 920   return _young_gen->supports_inline_contig_alloc();
 921 }
 922 




  27 #include "classfile/symbolTable.hpp"
  28 #include "classfile/stringTable.hpp"
  29 #include "classfile/systemDictionary.hpp"
  30 #include "classfile/vmSymbols.hpp"
  31 #include "code/codeCache.hpp"
  32 #include "code/icBuffer.hpp"
  33 #include "gc/serial/defNewGeneration.hpp"
  34 #include "gc/shared/adaptiveSizePolicy.hpp"
  35 #include "gc/shared/cardTableBarrierSet.hpp"
  36 #include "gc/shared/cardTableRS.hpp"
  37 #include "gc/shared/collectedHeap.inline.hpp"
  38 #include "gc/shared/collectorCounters.hpp"
  39 #include "gc/shared/gcId.hpp"
  40 #include "gc/shared/gcLocker.hpp"
  41 #include "gc/shared/gcPolicyCounters.hpp"
  42 #include "gc/shared/gcTrace.hpp"
  43 #include "gc/shared/gcTraceTime.inline.hpp"
  44 #include "gc/shared/genCollectedHeap.hpp"
  45 #include "gc/shared/genOopClosures.inline.hpp"
  46 #include "gc/shared/generationSpec.hpp"
  47 #include "gc/shared/oopStorageParState.inline.hpp"
  48 #include "gc/shared/space.hpp"
  49 #include "gc/shared/strongRootsScope.hpp"
  50 #include "gc/shared/vmGCOperations.hpp"
  51 #include "gc/shared/weakProcessor.hpp"
  52 #include "gc/shared/workgroup.hpp"
  53 #include "memory/filemap.hpp"
  54 #include "memory/metaspaceCounters.hpp"
  55 #include "memory/resourceArea.hpp"
  56 #include "oops/oop.inline.hpp"
  57 #include "runtime/biasedLocking.hpp"
  58 #include "runtime/flags/flagSetting.hpp"
  59 #include "runtime/handles.hpp"
  60 #include "runtime/handles.inline.hpp"
  61 #include "runtime/java.hpp"
  62 #include "runtime/vmThread.hpp"
  63 #include "services/management.hpp"
  64 #include "services/memoryService.hpp"
  65 #include "utilities/debug.hpp"
  66 #include "utilities/formatBuffer.hpp"
  67 #include "utilities/macros.hpp"


 835       assert(code_roots != NULL, "must supply closure for code cache");
 836 
 837       // We only visit parts of the CodeCache when scavenging.
 838       CodeCache::scavenge_root_nmethods_do(code_roots);
 839     }
 840     if (so & SO_AllCodeCache) {
 841       assert(code_roots != NULL, "must supply closure for code cache");
 842 
 843       // CMSCollector uses this to do intermediate-strength collections.
 844       // We scan the entire code cache, since CodeCache::do_unloading is not called.
 845       CodeCache::blobs_do(code_roots);
 846     }
 847     // Verify that the code cache contents are not subject to
 848     // movement by a scavenging collection.
 849     DEBUG_ONLY(CodeBlobToOopClosure assert_code_is_non_scavengable(&assert_is_non_scavengable_closure, !CodeBlobToOopClosure::FixRelocations));
 850     DEBUG_ONLY(CodeCache::asserted_non_scavengable_nmethods_do(&assert_code_is_non_scavengable));
 851   }
 852 }
 853 
 854 void GenCollectedHeap::process_string_table_roots(StrongRootsScope* scope,
 855                                                   OopClosure* root_closure,
 856                                                   OopStorage::ParState<false, false>* par_state_string) {
 857   assert(root_closure != NULL, "Must be set");
 858   // All threads execute the following. A specific chunk of buckets
 859   // from the StringTable are the individual tasks.
 860 
 861   // Either we should be single threaded or have a ParState
 862   assert((scope->n_threads() <= 1) || par_state_string != NULL, "Parallel but no ParState");
 863 
 864   if (scope->n_threads() > 1) {
 865     StringTable::possibly_parallel_oops_do(par_state_string, root_closure);
 866   } else {
 867     StringTable::oops_do(root_closure);
 868   }
 869 }
 870 
 871 void GenCollectedHeap::young_process_roots(StrongRootsScope* scope,
 872                                            OopsInGenClosure* root_closure,
 873                                            OopsInGenClosure* old_gen_closure,
 874                                            CLDClosure* cld_closure,
 875                                            OopStorage::ParState<false, false>* par_state_string) {
 876   MarkingCodeBlobClosure mark_code_closure(root_closure, CodeBlobToOopClosure::FixRelocations);
 877 
 878   process_roots(scope, SO_ScavengeCodeCache, root_closure,
 879                 cld_closure, cld_closure, &mark_code_closure);
 880   process_string_table_roots(scope, root_closure, par_state_string);
 881 
 882   if (!_process_strong_tasks->is_task_claimed(GCH_PS_younger_gens)) {
 883     root_closure->reset_generation();
 884   }
 885 
 886   // When collection is parallel, all threads get to cooperate to do
 887   // old generation scanning.
 888   old_gen_closure->set_generation(_old_gen);
 889   rem_set()->younger_refs_iterate(_old_gen, old_gen_closure, scope->n_threads());
 890   old_gen_closure->reset_generation();
 891 
 892   _process_strong_tasks->all_tasks_completed(scope->n_threads());
 893 }
 894 
 895 void GenCollectedHeap::full_process_roots(StrongRootsScope* scope,
 896                                           bool is_adjust_phase,
 897                                           ScanningOption so,
 898                                           bool only_strong_roots,
 899                                           OopsInGenClosure* root_closure,
 900                                           CLDClosure* cld_closure,
 901                                           OopStorage::ParState<false, false>* par_state_string) {
 902   MarkingCodeBlobClosure mark_code_closure(root_closure, is_adjust_phase);
 903   CLDClosure* weak_cld_closure = only_strong_roots ? NULL : cld_closure;
 904 
 905   process_roots(scope, so, root_closure, cld_closure, weak_cld_closure, &mark_code_closure);
 906   if (is_adjust_phase) {
 907     // We never treat the string table as roots during marking
 908     // for the full gc, so we only need to process it during
 909     // the adjust phase.
 910     process_string_table_roots(scope, root_closure, par_state_string);
 911   }
 912 
 913   _process_strong_tasks->all_tasks_completed(scope->n_threads());
 914 }
 915 
 916 void GenCollectedHeap::gen_process_weak_roots(OopClosure* root_closure) {
 917   WeakProcessor::oops_do(root_closure);
 918   _young_gen->ref_processor()->weak_oops_do(root_closure);
 919   _old_gen->ref_processor()->weak_oops_do(root_closure);
 920 }
 921 
 922 bool GenCollectedHeap::no_allocs_since_save_marks() {
 923   return _young_gen->no_allocs_since_save_marks() &&
 924          _old_gen->no_allocs_since_save_marks();
 925 }
 926 
 927 bool GenCollectedHeap::supports_inline_contig_alloc() const {
 928   return _young_gen->supports_inline_contig_alloc();
 929 }
 930 


< prev index next >