src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp

Print this page
rev 5891 : [mq]: hideDoCodeRoots


3377 
3378   void work(uint worker_id) {
3379     HandleMark hm;
3380     VerifyRegionClosure blk(true, _vo);
3381     _g1h->heap_region_par_iterate_chunked(&blk, worker_id,
3382                                           _g1h->workers()->active_workers(),
3383                                           HeapRegion::ParVerifyClaimValue);
3384     if (blk.failures()) {
3385       _failures = true;
3386     }
3387   }
3388 };
3389 
3390 void G1CollectedHeap::verify(bool silent, VerifyOption vo) {
3391   if (SafepointSynchronize::is_at_safepoint()) {
3392     assert(Thread::current()->is_VM_thread(),
3393            "Expected to be executed serially by the VM thread at this point");
3394 
3395     if (!silent) { gclog_or_tty->print("Roots "); }
3396     VerifyRootsClosure rootsCl(vo);
3397     G1VerifyCodeRootOopClosure codeRootsCl(this, &rootsCl, vo);
3398     G1VerifyCodeRootBlobClosure blobsCl(&codeRootsCl);
3399     VerifyKlassClosure klassCl(this, &rootsCl);
3400 
3401     // We apply the relevant closures to all the oops in the
3402     // system dictionary, the string table and the code cache.
3403     const int so = SO_AllClasses | SO_Strings | SO_AllCodeCache;
3404 
3405     // Need cleared claim bits for the strong roots processing
3406     ClassLoaderDataGraph::clear_claimed_marks();
3407 
3408     process_strong_roots(true,      // activate StrongRootsScope
3409                          ScanningOption(so),  // roots scanning options
3410                          &rootsCl,
3411                          &blobsCl,
3412                          &klassCl
3413                          );
3414 





3415     bool failures = rootsCl.failures() || codeRootsCl.failures();
3416 
3417     if (vo != VerifyOption_G1UseMarkWord) {
3418       // If we're verifying during a full GC then the region sets
3419       // will have been torn down at the start of the GC. Therefore
3420       // verifying the region sets will fail. So we only verify
3421       // the region sets when not in a full GC.
3422       if (!silent) { gclog_or_tty->print("HeapRegionSets "); }
3423       verify_region_sets();
3424     }
3425 
3426     if (!silent) { gclog_or_tty->print("HeapRegions "); }
3427     if (GCParallelVerificationEnabled && ParallelGCThreads > 1) {
3428       assert(check_heap_region_claim_values(HeapRegion::InitialClaimValue),
3429              "sanity check");
3430 
3431       G1ParVerifyTask task(this, vo);
3432       assert(UseDynamicNumberOfGCThreads ||
3433         workers()->active_workers() == workers()->total_workers(),
3434         "If not dynamic should be using all the workers");


5098 
5099 // *** Common G1 Evacuation Stuff
5100 
5101 // This method is run in a GC worker.
5102 
5103 void
5104 G1CollectedHeap::
5105 g1_process_strong_roots(bool is_scavenging,
5106                         ScanningOption so,
5107                         OopClosure* scan_non_heap_roots,
5108                         OopsInHeapRegionClosure* scan_rs,
5109                         G1KlassScanClosure* scan_klasses,
5110                         int worker_i) {
5111 
5112   // First scan the strong roots
5113   double ext_roots_start = os::elapsedTime();
5114   double closure_app_time_sec = 0.0;
5115 
5116   BufferingOopClosure buf_scan_non_heap_roots(scan_non_heap_roots);
5117 
5118   CodeBlobToOopClosure scan_code_roots(&buf_scan_non_heap_roots, true /* do_marking */);
5119 
5120   process_strong_roots(false, // no scoping; this is parallel code
5121                        so,
5122                        &buf_scan_non_heap_roots,
5123                        &scan_code_roots,
5124                        scan_klasses
5125                        );
5126 
5127   // Now the CM ref_processor roots.
5128   if (!_process_strong_tasks->is_task_claimed(G1H_PS_refProcessor_oops_do)) {
5129     // We need to treat the discovered reference lists of the
5130     // concurrent mark ref processor as roots and keep entries
5131     // (which are added by the marking threads) on them live
5132     // until they can be processed at the end of marking.
5133     ref_processor_cm()->weak_oops_do(&buf_scan_non_heap_roots);
5134   }
5135 
5136   // Finish up any enqueued closure apps (attributed as object copy time).
5137   buf_scan_non_heap_roots.done();
5138 
5139   double obj_copy_time_sec = buf_scan_non_heap_roots.closure_app_seconds();
5140 
5141   g1_policy()->phase_times()->record_obj_copy_time(worker_i, obj_copy_time_sec * 1000.0);
5142 
5143   double ext_root_time_ms =


5161   g1_policy()->phase_times()->record_satb_filtering_time(worker_i, satb_filtering_ms);
5162 
5163   // If this is an initial mark pause, and we're not scanning
5164   // the entire code cache, we need to mark the oops in the
5165   // strong code root lists for the regions that are not in
5166   // the collection set.
5167   // Note all threads participate in this set of root tasks.
5168   double mark_strong_code_roots_ms = 0.0;
5169   if (g1_policy()->during_initial_mark_pause() && !(so & SO_AllCodeCache)) {
5170     double mark_strong_roots_start = os::elapsedTime();
5171     mark_strong_code_roots(worker_i);
5172     mark_strong_code_roots_ms = (os::elapsedTime() - mark_strong_roots_start) * 1000.0;
5173   }
5174   g1_policy()->phase_times()->record_strong_code_root_mark_time(worker_i, mark_strong_code_roots_ms);
5175 
5176   // Now scan the complement of the collection set.
5177   CodeBlobToOopClosure eager_scan_code_roots(scan_non_heap_roots, true /* do_marking */);
5178   g1_rem_set()->oops_into_collection_set_do(scan_rs, &eager_scan_code_roots, worker_i);
5179 
5180   _process_strong_tasks->all_tasks_completed();
5181 }
5182 
5183 void
5184 G1CollectedHeap::g1_process_weak_roots(OopClosure* root_closure) {
5185   CodeBlobToOopClosure roots_in_blobs(root_closure, /*do_marking=*/ false);
5186   SharedHeap::process_weak_roots(root_closure, &roots_in_blobs);
5187 }
5188 
5189 class G1StringSymbolTableUnlinkTask : public AbstractGangTask {
5190 private:
5191   BoolObjectClosure* _is_alive;
5192   int _initial_string_table_size;
5193   int _initial_symbol_table_size;
5194 
5195   bool  _process_strings;
5196   int _strings_processed;
5197   int _strings_removed;
5198 
5199   bool  _process_symbols;
5200   int _symbols_processed;
5201   int _symbols_removed;
5202 
5203   bool _do_in_parallel;
5204 public:
5205   G1StringSymbolTableUnlinkTask(BoolObjectClosure* is_alive, bool process_strings, bool process_symbols) :
5206     AbstractGangTask("Par String/Symbol table unlink"), _is_alive(is_alive),




3377 
3378   void work(uint worker_id) {
3379     HandleMark hm;
3380     VerifyRegionClosure blk(true, _vo);
3381     _g1h->heap_region_par_iterate_chunked(&blk, worker_id,
3382                                           _g1h->workers()->active_workers(),
3383                                           HeapRegion::ParVerifyClaimValue);
3384     if (blk.failures()) {
3385       _failures = true;
3386     }
3387   }
3388 };
3389 
3390 void G1CollectedHeap::verify(bool silent, VerifyOption vo) {
3391   if (SafepointSynchronize::is_at_safepoint()) {
3392     assert(Thread::current()->is_VM_thread(),
3393            "Expected to be executed serially by the VM thread at this point");
3394 
3395     if (!silent) { gclog_or_tty->print("Roots "); }
3396     VerifyRootsClosure rootsCl(vo);


3397     VerifyKlassClosure klassCl(this, &rootsCl);
3398 
3399     // We apply the relevant closures to all the oops in the
3400     // system dictionary, the string table and the code cache.
3401     const int so = SO_AllClasses | SO_Strings | SO_AllCodeCache;
3402 
3403     // Need cleared claim bits for the strong roots processing
3404     ClassLoaderDataGraph::clear_claimed_marks();
3405 
3406     process_strong_roots(true,      // activate StrongRootsScope
3407                          ScanningOption(so),  // roots scanning options
3408                          &rootsCl,

3409                          &klassCl
3410                          );
3411 
3412     // Verify nmethods.
3413     G1VerifyCodeRootOopClosure codeRootsCl(this, &rootsCl, vo);
3414     G1VerifyCodeRootBlobClosure blobsCl(&codeRootsCl);
3415     CodeCache::blobs_do(&blobsCl);
3416 
3417     bool failures = rootsCl.failures() || codeRootsCl.failures();
3418 
3419     if (vo != VerifyOption_G1UseMarkWord) {
3420       // If we're verifying during a full GC then the region sets
3421       // will have been torn down at the start of the GC. Therefore
3422       // verifying the region sets will fail. So we only verify
3423       // the region sets when not in a full GC.
3424       if (!silent) { gclog_or_tty->print("HeapRegionSets "); }
3425       verify_region_sets();
3426     }
3427 
3428     if (!silent) { gclog_or_tty->print("HeapRegions "); }
3429     if (GCParallelVerificationEnabled && ParallelGCThreads > 1) {
3430       assert(check_heap_region_claim_values(HeapRegion::InitialClaimValue),
3431              "sanity check");
3432 
3433       G1ParVerifyTask task(this, vo);
3434       assert(UseDynamicNumberOfGCThreads ||
3435         workers()->active_workers() == workers()->total_workers(),
3436         "If not dynamic should be using all the workers");


5100 
5101 // *** Common G1 Evacuation Stuff
5102 
5103 // This method is run in a GC worker.
5104 
5105 void
5106 G1CollectedHeap::
5107 g1_process_strong_roots(bool is_scavenging,
5108                         ScanningOption so,
5109                         OopClosure* scan_non_heap_roots,
5110                         OopsInHeapRegionClosure* scan_rs,
5111                         G1KlassScanClosure* scan_klasses,
5112                         int worker_i) {
5113 
5114   // First scan the strong roots
5115   double ext_roots_start = os::elapsedTime();
5116   double closure_app_time_sec = 0.0;
5117 
5118   BufferingOopClosure buf_scan_non_heap_roots(scan_non_heap_roots);
5119 


5120   process_strong_roots(false, // no scoping; this is parallel code
5121                        so,
5122                        &buf_scan_non_heap_roots,

5123                        scan_klasses
5124                        );
5125 
5126   // Now the CM ref_processor roots.
5127   if (!_process_strong_tasks->is_task_claimed(G1H_PS_refProcessor_oops_do)) {
5128     // We need to treat the discovered reference lists of the
5129     // concurrent mark ref processor as roots and keep entries
5130     // (which are added by the marking threads) on them live
5131     // until they can be processed at the end of marking.
5132     ref_processor_cm()->weak_oops_do(&buf_scan_non_heap_roots);
5133   }
5134 
5135   // Finish up any enqueued closure apps (attributed as object copy time).
5136   buf_scan_non_heap_roots.done();
5137 
5138   double obj_copy_time_sec = buf_scan_non_heap_roots.closure_app_seconds();
5139 
5140   g1_policy()->phase_times()->record_obj_copy_time(worker_i, obj_copy_time_sec * 1000.0);
5141 
5142   double ext_root_time_ms =


5160   g1_policy()->phase_times()->record_satb_filtering_time(worker_i, satb_filtering_ms);
5161 
5162   // If this is an initial mark pause, and we're not scanning
5163   // the entire code cache, we need to mark the oops in the
5164   // strong code root lists for the regions that are not in
5165   // the collection set.
5166   // Note all threads participate in this set of root tasks.
5167   double mark_strong_code_roots_ms = 0.0;
5168   if (g1_policy()->during_initial_mark_pause() && !(so & SO_AllCodeCache)) {
5169     double mark_strong_roots_start = os::elapsedTime();
5170     mark_strong_code_roots(worker_i);
5171     mark_strong_code_roots_ms = (os::elapsedTime() - mark_strong_roots_start) * 1000.0;
5172   }
5173   g1_policy()->phase_times()->record_strong_code_root_mark_time(worker_i, mark_strong_code_roots_ms);
5174 
5175   // Now scan the complement of the collection set.
5176   CodeBlobToOopClosure eager_scan_code_roots(scan_non_heap_roots, true /* do_marking */);
5177   g1_rem_set()->oops_into_collection_set_do(scan_rs, &eager_scan_code_roots, worker_i);
5178 
5179   _process_strong_tasks->all_tasks_completed();






5180 }
5181 
5182 class G1StringSymbolTableUnlinkTask : public AbstractGangTask {
5183 private:
5184   BoolObjectClosure* _is_alive;
5185   int _initial_string_table_size;
5186   int _initial_symbol_table_size;
5187 
5188   bool  _process_strings;
5189   int _strings_processed;
5190   int _strings_removed;
5191 
5192   bool  _process_symbols;
5193   int _symbols_processed;
5194   int _symbols_removed;
5195 
5196   bool _do_in_parallel;
5197 public:
5198   G1StringSymbolTableUnlinkTask(BoolObjectClosure* is_alive, bool process_strings, bool process_symbols) :
5199     AbstractGangTask("Par String/Symbol table unlink"), _is_alive(is_alive),