224 PSGCAdaptivePolicyCounters* const counters = heap->gc_policy_counters();
225 const int ffs_val = need_full_gc ? full_follows_scavenge : not_skipped;
226 counters->update_full_follows_scavenge(ffs_val);
227 }
228
229 if (need_full_gc) {
230 GCCauseSetter gccs(heap, GCCause::_adaptive_size_policy);
231 CollectorPolicy* cp = heap->collector_policy();
232 const bool clear_all_softrefs = cp->should_clear_all_soft_refs();
233
234 if (UseParallelOldGC) {
235 full_gc_done = PSParallelCompact::invoke_no_policy(clear_all_softrefs);
236 } else {
237 full_gc_done = PSMarkSweep::invoke_no_policy(clear_all_softrefs);
238 }
239 }
240
241 return full_gc_done;
242 }
243
244 // This method contains no policy. You should probably
245 // be calling invoke() instead.
246 bool PSScavenge::invoke_no_policy() {
247 assert(SafepointSynchronize::is_at_safepoint(), "should be at safepoint");
248 assert(Thread::current() == (Thread*)VMThread::vm_thread(), "should be in vm thread");
249
250 _gc_timer.register_gc_start();
251
252 TimeStamp scavenge_entry;
253 TimeStamp scavenge_midpoint;
254 TimeStamp scavenge_exit;
255
256 scavenge_entry.update();
257
258 if (GCLocker::check_active_before_gc()) {
259 return false;
260 }
261
262 ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
263 GCCause::Cause gc_cause = heap->gc_cause();
362 // We'll use the promotion manager again later.
363 PSPromotionManager* promotion_manager = PSPromotionManager::vm_thread_promotion_manager();
364 {
365 GCTraceTime(Debug, gc, phases) tm("Scavenge", &_gc_timer);
366 ParallelScavengeHeap::ParStrongRootsScope psrs;
367
368 GCTaskQueue* q = GCTaskQueue::create();
369
370 if (!old_gen->object_space()->is_empty()) {
371 // There are only old-to-young pointers if there are objects
372 // in the old gen.
373 uint stripe_total = active_workers;
374 for(uint i=0; i < stripe_total; i++) {
375 q->enqueue(new OldToYoungRootsTask(old_gen, old_top, i, stripe_total));
376 }
377 }
378
379 q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::universe));
380 q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::jni_handles));
381 // We scan the thread roots in parallel
382 Threads::create_thread_roots_tasks(q);
383 q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::object_synchronizer));
384 q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::flat_profiler));
385 q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::management));
386 q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::system_dictionary));
387 q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::class_loader_data));
388 q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::jvmti));
389 q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::code_cache));
390
391 ParallelTaskTerminator terminator(
392 active_workers,
393 (TaskQueueSetSuper*) promotion_manager->stack_array_depth());
394 // If active_workers can exceed 1, add a StrealTask.
395 // PSPromotionManager::drain_stacks_depth() does not fully drain its
396 // stacks and expects a StealTask to complete the draining if
397 // ParallelGCThreads is > 1.
398 if (gc_task_manager()->workers() > 1) {
399 for (uint j = 0; j < active_workers; j++) {
400 q->enqueue(new StealTask(&terminator));
401 }
402 }
|
224 PSGCAdaptivePolicyCounters* const counters = heap->gc_policy_counters();
225 const int ffs_val = need_full_gc ? full_follows_scavenge : not_skipped;
226 counters->update_full_follows_scavenge(ffs_val);
227 }
228
229 if (need_full_gc) {
230 GCCauseSetter gccs(heap, GCCause::_adaptive_size_policy);
231 CollectorPolicy* cp = heap->collector_policy();
232 const bool clear_all_softrefs = cp->should_clear_all_soft_refs();
233
234 if (UseParallelOldGC) {
235 full_gc_done = PSParallelCompact::invoke_no_policy(clear_all_softrefs);
236 } else {
237 full_gc_done = PSMarkSweep::invoke_no_policy(clear_all_softrefs);
238 }
239 }
240
241 return full_gc_done;
242 }
243
244 class CreateThreadRootsTasksClosure : public ThreadClosure {
245
246 private:
247 GCTaskQueue* _queue;
248
249 public:
250
251 CreateThreadRootsTasksClosure(GCTaskQueue* q) : _queue(q) {
252 }
253
254 void do_thread(Thread* thread) {
255 if (thread->is_Java_thread()) {
256 _queue->enqueue(new ThreadRootsTask((JavaThread*) thread));
257 } else if (thread->is_VM_thread()) {
258 _queue->enqueue(new ThreadRootsTask((VMThread*) thread));
259 }
260 }
261
262 };
263
264 // This method contains no policy. You should probably
265 // be calling invoke() instead.
266 bool PSScavenge::invoke_no_policy() {
267 assert(SafepointSynchronize::is_at_safepoint(), "should be at safepoint");
268 assert(Thread::current() == (Thread*)VMThread::vm_thread(), "should be in vm thread");
269
270 _gc_timer.register_gc_start();
271
272 TimeStamp scavenge_entry;
273 TimeStamp scavenge_midpoint;
274 TimeStamp scavenge_exit;
275
276 scavenge_entry.update();
277
278 if (GCLocker::check_active_before_gc()) {
279 return false;
280 }
281
282 ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
283 GCCause::Cause gc_cause = heap->gc_cause();
382 // We'll use the promotion manager again later.
383 PSPromotionManager* promotion_manager = PSPromotionManager::vm_thread_promotion_manager();
384 {
385 GCTraceTime(Debug, gc, phases) tm("Scavenge", &_gc_timer);
386 ParallelScavengeHeap::ParStrongRootsScope psrs;
387
388 GCTaskQueue* q = GCTaskQueue::create();
389
390 if (!old_gen->object_space()->is_empty()) {
391 // There are only old-to-young pointers if there are objects
392 // in the old gen.
393 uint stripe_total = active_workers;
394 for(uint i=0; i < stripe_total; i++) {
395 q->enqueue(new OldToYoungRootsTask(old_gen, old_top, i, stripe_total));
396 }
397 }
398
399 q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::universe));
400 q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::jni_handles));
401 // We scan the thread roots in parallel
402 CreateThreadRootsTasksClosure cl(q);
403 Threads::threads_do(&cl);
404 q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::object_synchronizer));
405 q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::flat_profiler));
406 q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::management));
407 q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::system_dictionary));
408 q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::class_loader_data));
409 q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::jvmti));
410 q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::code_cache));
411
412 ParallelTaskTerminator terminator(
413 active_workers,
414 (TaskQueueSetSuper*) promotion_manager->stack_array_depth());
415 // If active_workers can exceed 1, add a StrealTask.
416 // PSPromotionManager::drain_stacks_depth() does not fully drain its
417 // stacks and expects a StealTask to complete the draining if
418 // ParallelGCThreads is > 1.
419 if (gc_task_manager()->workers() > 1) {
420 for (uint j = 0; j < active_workers; j++) {
421 q->enqueue(new StealTask(&terminator));
422 }
423 }
|