< prev index next >

src/hotspot/share/gc/parallel/psScavenge.cpp

Print this page

 83 ParallelScavengeTracer        PSScavenge::_gc_tracer;
 84 CollectorCounters*            PSScavenge::_counters = NULL;
 85 
 86 static void scavenge_roots_work(ParallelRootType::Value root_type, uint worker_id) {
 87   assert(ParallelScavengeHeap::heap()->is_gc_active(), "called outside gc");
 88 
 89   PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(worker_id);
 90   PSScavengeRootsClosure roots_closure(pm);
 91   PSPromoteRootsClosure  roots_to_old_closure(pm);
 92 
 93   switch (root_type) {
 94     case ParallelRootType::class_loader_data:
 95       {
 96         PSScavengeCLDClosure cld_closure(pm);
 97         ClassLoaderDataGraph::cld_do(&cld_closure);
 98       }
 99       break;
100 
101     case ParallelRootType::code_cache:
102       {
103         MarkingCodeBlobClosure code_closure(&roots_to_old_closure, CodeBlobToOopClosure::FixRelocations);
104         ScavengableNMethods::nmethods_do(&code_closure);
105       }
106       break;
107 
108     case ParallelRootType::sentinel:
109     DEBUG_ONLY(default:) // DEBUG_ONLY hack will create compile error on release builds (-Wswitch) and runtime check on debug builds
110       fatal("Bad enumeration value: %u", root_type);
111       break;
112   }
113 
114   // Do the real work
115   pm->drain_stacks(false);
116 }
117 
118 static void steal_work(TaskTerminator& terminator, uint worker_id) {
119   assert(ParallelScavengeHeap::heap()->is_gc_active(), "called outside gc");
120 
121   PSPromotionManager* pm =
122     PSPromotionManager::gc_thread_promotion_manager(worker_id);
123   pm->drain_stacks(true);

251   if (need_full_gc) {
252     GCCauseSetter gccs(heap, GCCause::_adaptive_size_policy);
253     SoftRefPolicy* srp = heap->soft_ref_policy();
254     const bool clear_all_softrefs = srp->should_clear_all_soft_refs();
255 
256     full_gc_done = PSParallelCompact::invoke_no_policy(clear_all_softrefs);
257   }
258 
259   return full_gc_done;
260 }
261 
262 class PSThreadRootsTaskClosure : public ThreadClosure {
263   uint _worker_id;
264 public:
265   PSThreadRootsTaskClosure(uint worker_id) : _worker_id(worker_id) { }
266   virtual void do_thread(Thread* thread) {
267     assert(ParallelScavengeHeap::heap()->is_gc_active(), "called outside gc");
268 
269     PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(_worker_id);
270     PSScavengeRootsClosure roots_closure(pm);
271     MarkingCodeBlobClosure roots_in_blobs(&roots_closure, CodeBlobToOopClosure::FixRelocations);
272 
273     thread->oops_do(&roots_closure, &roots_in_blobs);
274 
275     // Do the real work
276     pm->drain_stacks(false);
277   }
278 };
279 
280 class ScavengeRootsTask : public AbstractGangTask {
281   StrongRootsScope _strong_roots_scope; // needed for Threads::possibly_parallel_threads_do
282   OopStorageSetStrongParState<false /* concurrent */, false /* is_const */> _oop_storage_strong_par_state;
283   SequentialSubTasksDone _subtasks;
284   PSOldGen* _old_gen;
285   HeapWord* _gen_top;
286   uint _active_workers;
287   bool _is_empty;
288   TaskTerminator _terminator;
289 
290 public:
291   ScavengeRootsTask(PSOldGen* old_gen,

 83 ParallelScavengeTracer        PSScavenge::_gc_tracer;
 84 CollectorCounters*            PSScavenge::_counters = NULL;
 85 
 86 static void scavenge_roots_work(ParallelRootType::Value root_type, uint worker_id) {
 87   assert(ParallelScavengeHeap::heap()->is_gc_active(), "called outside gc");
 88 
 89   PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(worker_id);
 90   PSScavengeRootsClosure roots_closure(pm);
 91   PSPromoteRootsClosure  roots_to_old_closure(pm);
 92 
 93   switch (root_type) {
 94     case ParallelRootType::class_loader_data:
 95       {
 96         PSScavengeCLDClosure cld_closure(pm);
 97         ClassLoaderDataGraph::cld_do(&cld_closure);
 98       }
 99       break;
100 
101     case ParallelRootType::code_cache:
102       {
103         MarkingCodeBlobClosure code_closure(&roots_to_old_closure, CodeBlobToOopClosure::FixRelocations, true /* keepalive nmethods */);
104         ScavengableNMethods::nmethods_do(&code_closure);
105       }
106       break;
107 
108     case ParallelRootType::sentinel:
109     DEBUG_ONLY(default:) // DEBUG_ONLY hack will create compile error on release builds (-Wswitch) and runtime check on debug builds
110       fatal("Bad enumeration value: %u", root_type);
111       break;
112   }
113 
114   // Do the real work
115   pm->drain_stacks(false);
116 }
117 
118 static void steal_work(TaskTerminator& terminator, uint worker_id) {
119   assert(ParallelScavengeHeap::heap()->is_gc_active(), "called outside gc");
120 
121   PSPromotionManager* pm =
122     PSPromotionManager::gc_thread_promotion_manager(worker_id);
123   pm->drain_stacks(true);

251   if (need_full_gc) {
252     GCCauseSetter gccs(heap, GCCause::_adaptive_size_policy);
253     SoftRefPolicy* srp = heap->soft_ref_policy();
254     const bool clear_all_softrefs = srp->should_clear_all_soft_refs();
255 
256     full_gc_done = PSParallelCompact::invoke_no_policy(clear_all_softrefs);
257   }
258 
259   return full_gc_done;
260 }
261 
262 class PSThreadRootsTaskClosure : public ThreadClosure {
263   uint _worker_id;
264 public:
265   PSThreadRootsTaskClosure(uint worker_id) : _worker_id(worker_id) { }
266   virtual void do_thread(Thread* thread) {
267     assert(ParallelScavengeHeap::heap()->is_gc_active(), "called outside gc");
268 
269     PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(_worker_id);
270     PSScavengeRootsClosure roots_closure(pm);
271     MarkingCodeBlobClosure roots_in_blobs(&roots_closure, CodeBlobToOopClosure::FixRelocations, true /* keepalive nmethods */);
272 
273     thread->oops_do(&roots_closure, &roots_in_blobs);
274 
275     // Do the real work
276     pm->drain_stacks(false);
277   }
278 };
279 
280 class ScavengeRootsTask : public AbstractGangTask {
281   StrongRootsScope _strong_roots_scope; // needed for Threads::possibly_parallel_threads_do
282   OopStorageSetStrongParState<false /* concurrent */, false /* is_const */> _oop_storage_strong_par_state;
283   SequentialSubTasksDone _subtasks;
284   PSOldGen* _old_gen;
285   HeapWord* _gen_top;
286   uint _active_workers;
287   bool _is_empty;
288   TaskTerminator _terminator;
289 
290 public:
291   ScavengeRootsTask(PSOldGen* old_gen,
< prev index next >