1 /*
2 * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
32 #include "gc/parallel/psMarkSweep.hpp"
33 #include "gc/parallel/psParallelCompact.inline.hpp"
34 #include "gc/parallel/psScavenge.inline.hpp"
35 #include "gc/parallel/psTasks.hpp"
36 #include "gc/shared/collectorPolicy.hpp"
37 #include "gc/shared/gcCause.hpp"
38 #include "gc/shared/gcHeapSummary.hpp"
39 #include "gc/shared/gcId.hpp"
40 #include "gc/shared/gcLocker.inline.hpp"
41 #include "gc/shared/gcTimer.hpp"
42 #include "gc/shared/gcTrace.hpp"
43 #include "gc/shared/gcTraceTime.inline.hpp"
44 #include "gc/shared/isGCActiveMark.hpp"
45 #include "gc/shared/referencePolicy.hpp"
46 #include "gc/shared/referenceProcessor.hpp"
47 #include "gc/shared/spaceDecorator.hpp"
48 #include "memory/resourceArea.hpp"
49 #include "logging/log.hpp"
50 #include "oops/oop.inline.hpp"
51 #include "runtime/biasedLocking.hpp"
52 #include "runtime/fprofiler.hpp"
53 #include "runtime/handles.inline.hpp"
54 #include "runtime/threadCritical.hpp"
55 #include "runtime/vmThread.hpp"
56 #include "runtime/vm_operations.hpp"
57 #include "services/memoryService.hpp"
58 #include "utilities/stack.inline.hpp"
59
60 HeapWord* PSScavenge::_to_space_top_before_gc = NULL;
61 int PSScavenge::_consecutive_skipped_scavenges = 0;
62 ReferenceProcessor* PSScavenge::_ref_processor = NULL;
63 CardTableExtension* PSScavenge::_card_table = NULL;
64 bool PSScavenge::_survivor_overflow = false;
65 uint PSScavenge::_tenuring_threshold = 0;
66 HeapWord* PSScavenge::_young_generation_boundary = NULL;
67 uintptr_t PSScavenge::_young_generation_boundary_compressed = 0;
68 elapsedTimer PSScavenge::_accumulated_time;
69 STWGCTimer PSScavenge::_gc_timer;
70 ParallelScavengeTracer PSScavenge::_gc_tracer;
71 CollectorCounters* PSScavenge::_counters = NULL;
72
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 }
403
404 gc_task_manager()->execute_and_wait(q);
|
1 /*
2 * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
32 #include "gc/parallel/psMarkSweep.hpp"
33 #include "gc/parallel/psParallelCompact.inline.hpp"
34 #include "gc/parallel/psScavenge.inline.hpp"
35 #include "gc/parallel/psTasks.hpp"
36 #include "gc/shared/collectorPolicy.hpp"
37 #include "gc/shared/gcCause.hpp"
38 #include "gc/shared/gcHeapSummary.hpp"
39 #include "gc/shared/gcId.hpp"
40 #include "gc/shared/gcLocker.inline.hpp"
41 #include "gc/shared/gcTimer.hpp"
42 #include "gc/shared/gcTrace.hpp"
43 #include "gc/shared/gcTraceTime.inline.hpp"
44 #include "gc/shared/isGCActiveMark.hpp"
45 #include "gc/shared/referencePolicy.hpp"
46 #include "gc/shared/referenceProcessor.hpp"
47 #include "gc/shared/spaceDecorator.hpp"
48 #include "memory/resourceArea.hpp"
49 #include "logging/log.hpp"
50 #include "oops/oop.inline.hpp"
51 #include "runtime/biasedLocking.hpp"
52 #include "runtime/handles.inline.hpp"
53 #include "runtime/threadCritical.hpp"
54 #include "runtime/vmThread.hpp"
55 #include "runtime/vm_operations.hpp"
56 #include "services/memoryService.hpp"
57 #include "utilities/stack.inline.hpp"
58
59 HeapWord* PSScavenge::_to_space_top_before_gc = NULL;
60 int PSScavenge::_consecutive_skipped_scavenges = 0;
61 ReferenceProcessor* PSScavenge::_ref_processor = NULL;
62 CardTableExtension* PSScavenge::_card_table = NULL;
63 bool PSScavenge::_survivor_overflow = false;
64 uint PSScavenge::_tenuring_threshold = 0;
65 HeapWord* PSScavenge::_young_generation_boundary = NULL;
66 uintptr_t PSScavenge::_young_generation_boundary_compressed = 0;
67 elapsedTimer PSScavenge::_accumulated_time;
68 STWGCTimer PSScavenge::_gc_timer;
69 ParallelScavengeTracer PSScavenge::_gc_tracer;
70 CollectorCounters* PSScavenge::_counters = NULL;
71
363 {
364 GCTraceTime(Debug, gc, phases) tm("Scavenge", &_gc_timer);
365 ParallelScavengeHeap::ParStrongRootsScope psrs;
366
367 GCTaskQueue* q = GCTaskQueue::create();
368
369 if (!old_gen->object_space()->is_empty()) {
370 // There are only old-to-young pointers if there are objects
371 // in the old gen.
372 uint stripe_total = active_workers;
373 for(uint i=0; i < stripe_total; i++) {
374 q->enqueue(new OldToYoungRootsTask(old_gen, old_top, i, stripe_total));
375 }
376 }
377
378 q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::universe));
379 q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::jni_handles));
380 // We scan the thread roots in parallel
381 Threads::create_thread_roots_tasks(q);
382 q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::object_synchronizer));
383 q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::management));
384 q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::system_dictionary));
385 q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::class_loader_data));
386 q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::jvmti));
387 q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::code_cache));
388
389 ParallelTaskTerminator terminator(
390 active_workers,
391 (TaskQueueSetSuper*) promotion_manager->stack_array_depth());
392 // If active_workers can exceed 1, add a StrealTask.
393 // PSPromotionManager::drain_stacks_depth() does not fully drain its
394 // stacks and expects a StealTask to complete the draining if
395 // ParallelGCThreads is > 1.
396 if (gc_task_manager()->workers() > 1) {
397 for (uint j = 0; j < active_workers; j++) {
398 q->enqueue(new StealTask(&terminator));
399 }
400 }
401
402 gc_task_manager()->execute_and_wait(q);
|