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

Print this page
rev 5823 : [mq]: useBufferingOopClosuresInCodeCache


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


5150       satb_filtering_ms = (os::elapsedTime() - satb_filter_start) * 1000.0;
5151     }
5152   }
5153   g1_policy()->phase_times()->record_satb_filtering_time(worker_i, satb_filtering_ms);
5154 
5155   // If this is an initial mark pause, and we're not scanning
5156   // the entire code cache, we need to mark the oops in the
5157   // strong code root lists for the regions that are not in
5158   // the collection set.
5159   // Note all threads participate in this set of root tasks.
5160   double mark_strong_code_roots_ms = 0.0;
5161   if (g1_policy()->during_initial_mark_pause() && !(so & SO_AllCodeCache)) {
5162     double mark_strong_roots_start = os::elapsedTime();
5163     mark_strong_code_roots(worker_i);
5164     mark_strong_code_roots_ms = (os::elapsedTime() - mark_strong_roots_start) * 1000.0;
5165   }
5166   g1_policy()->phase_times()->record_strong_code_root_mark_time(worker_i, mark_strong_code_roots_ms);
5167 
5168   // Now scan the complement of the collection set.
5169   if (scan_rs != NULL) {

5170     g1_rem_set()->oops_into_collection_set_do(scan_rs, &eager_scan_code_roots, worker_i);
5171   }
5172   _process_strong_tasks->all_tasks_completed();
5173 }
5174 
5175 void
5176 G1CollectedHeap::g1_process_weak_roots(OopClosure* root_closure) {
5177   CodeBlobToOopClosure roots_in_blobs(root_closure, /*do_marking=*/ false);
5178   SharedHeap::process_weak_roots(root_closure, &roots_in_blobs);
5179 }
5180 
5181 class G1StringSymbolTableUnlinkTask : public AbstractGangTask {
5182 private:
5183   BoolObjectClosure* _is_alive;
5184   int _initial_string_table_size;
5185   int _initial_symbol_table_size;
5186 
5187   bool  _process_strings;
5188   int _strings_processed;
5189   int _strings_removed;




5087 
5088 // *** Common G1 Evacuation Stuff
5089 
5090 // This method is run in a GC worker.
5091 
5092 void
5093 G1CollectedHeap::
5094 g1_process_strong_roots(bool is_scavenging,
5095                         ScanningOption so,
5096                         OopClosure* scan_non_heap_roots,
5097                         OopsInHeapRegionClosure* scan_rs,
5098                         G1KlassScanClosure* scan_klasses,
5099                         int worker_i) {
5100 
5101   // First scan the strong roots
5102   double ext_roots_start = os::elapsedTime();
5103   double closure_app_time_sec = 0.0;
5104 
5105   BufferingOopClosure buf_scan_non_heap_roots(scan_non_heap_roots);
5106 
5107   CodeBlobToOopClosure scan_code_roots(&buf_scan_non_heap_roots, true /* do_marking */);



5108 
5109   process_strong_roots(false, // no scoping; this is parallel code
5110                        so,
5111                        &buf_scan_non_heap_roots,
5112                        &scan_code_roots,
5113                        scan_klasses
5114                        );
5115 
5116   // Now the CM ref_processor roots.
5117   if (!_process_strong_tasks->is_task_claimed(G1H_PS_refProcessor_oops_do)) {
5118     // We need to treat the discovered reference lists of the
5119     // concurrent mark ref processor as roots and keep entries
5120     // (which are added by the marking threads) on them live
5121     // until they can be processed at the end of marking.
5122     ref_processor_cm()->weak_oops_do(&buf_scan_non_heap_roots);
5123   }
5124 
5125   // Finish up any enqueued closure apps (attributed as object copy time).
5126   buf_scan_non_heap_roots.done();
5127 
5128   double obj_copy_time_sec = buf_scan_non_heap_roots.closure_app_seconds();
5129 
5130   g1_policy()->phase_times()->record_obj_copy_time(worker_i, obj_copy_time_sec * 1000.0);
5131 
5132   double ext_root_time_ms =


5147       satb_filtering_ms = (os::elapsedTime() - satb_filter_start) * 1000.0;
5148     }
5149   }
5150   g1_policy()->phase_times()->record_satb_filtering_time(worker_i, satb_filtering_ms);
5151 
5152   // If this is an initial mark pause, and we're not scanning
5153   // the entire code cache, we need to mark the oops in the
5154   // strong code root lists for the regions that are not in
5155   // the collection set.
5156   // Note all threads participate in this set of root tasks.
5157   double mark_strong_code_roots_ms = 0.0;
5158   if (g1_policy()->during_initial_mark_pause() && !(so & SO_AllCodeCache)) {
5159     double mark_strong_roots_start = os::elapsedTime();
5160     mark_strong_code_roots(worker_i);
5161     mark_strong_code_roots_ms = (os::elapsedTime() - mark_strong_roots_start) * 1000.0;
5162   }
5163   g1_policy()->phase_times()->record_strong_code_root_mark_time(worker_i, mark_strong_code_roots_ms);
5164 
5165   // Now scan the complement of the collection set.
5166   if (scan_rs != NULL) {
5167     CodeBlobToOopClosure eager_scan_code_roots(scan_non_heap_roots, true /* do_marking */);
5168     g1_rem_set()->oops_into_collection_set_do(scan_rs, &eager_scan_code_roots, worker_i);
5169   }
5170   _process_strong_tasks->all_tasks_completed();
5171 }
5172 
5173 void
5174 G1CollectedHeap::g1_process_weak_roots(OopClosure* root_closure) {
5175   CodeBlobToOopClosure roots_in_blobs(root_closure, /*do_marking=*/ false);
5176   SharedHeap::process_weak_roots(root_closure, &roots_in_blobs);
5177 }
5178 
5179 class G1StringSymbolTableUnlinkTask : public AbstractGangTask {
5180 private:
5181   BoolObjectClosure* _is_alive;
5182   int _initial_string_table_size;
5183   int _initial_symbol_table_size;
5184 
5185   bool  _process_strings;
5186   int _strings_processed;
5187   int _strings_removed;