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

Print this page
rev 5823 : imported patch useBufferingOopClosuresInCodeCache


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 


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;
5190 




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(&buf_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 


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     buf_scan_non_heap_roots.done();
5172   }
5173   _process_strong_tasks->all_tasks_completed();
5174 }
5175 
5176 void
5177 G1CollectedHeap::g1_process_weak_roots(OopClosure* root_closure) {
5178   CodeBlobToOopClosure roots_in_blobs(root_closure, /*do_marking=*/ false);
5179   SharedHeap::process_weak_roots(root_closure, &roots_in_blobs);
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