10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 * version 2 for more details (a copy is included in the LICENSE file that
12 * accompanied this code).
13 *
14 * You should have received a copy of the GNU General Public License version
15 * 2 along with this work; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19 * or visit www.oracle.com if you need additional information or have any
20 * questions.
21 *
22 */
23
24 #include "precompiled.hpp"
25 #include "code/codeCache.hpp"
26 #include "gc/parallel/adjoiningGenerations.hpp"
27 #include "gc/parallel/adjoiningGenerationsForHeteroHeap.hpp"
28 #include "gc/parallel/adjoiningVirtualSpaces.hpp"
29 #include "gc/parallel/parallelArguments.hpp"
30 #include "gc/parallel/gcTaskManager.hpp"
31 #include "gc/parallel/objectStartArray.inline.hpp"
32 #include "gc/parallel/parallelScavengeHeap.inline.hpp"
33 #include "gc/parallel/psAdaptiveSizePolicy.hpp"
34 #include "gc/parallel/psMarkSweepProxy.hpp"
35 #include "gc/parallel/psMemoryPool.hpp"
36 #include "gc/parallel/psParallelCompact.inline.hpp"
37 #include "gc/parallel/psPromotionManager.hpp"
38 #include "gc/parallel/psScavenge.hpp"
39 #include "gc/parallel/psVMOperations.hpp"
40 #include "gc/shared/gcHeapSummary.hpp"
41 #include "gc/shared/gcLocker.hpp"
42 #include "gc/shared/gcWhen.hpp"
43 #include "gc/shared/genArguments.hpp"
44 #include "gc/shared/scavengableNMethods.hpp"
45 #include "logging/log.hpp"
46 #include "memory/metaspaceCounters.hpp"
47 #include "memory/universe.hpp"
48 #include "oops/oop.inline.hpp"
49 #include "runtime/handles.inline.hpp"
50 #include "runtime/java.hpp"
51 #include "runtime/vmThread.hpp"
52 #include "services/memoryManager.hpp"
53 #include "services/memTracker.hpp"
54 #include "utilities/macros.hpp"
55 #include "utilities/vmError.hpp"
56
57 PSYoungGen* ParallelScavengeHeap::_young_gen = NULL;
58 PSOldGen* ParallelScavengeHeap::_old_gen = NULL;
59 PSAdaptiveSizePolicy* ParallelScavengeHeap::_size_policy = NULL;
60 PSGCAdaptivePolicyCounters* ParallelScavengeHeap::_gc_policy_counters = NULL;
61 GCTaskManager* ParallelScavengeHeap::_gc_task_manager = NULL;
62
63 jint ParallelScavengeHeap::initialize() {
64 const size_t reserved_heap_size = ParallelArguments::heap_reserved_size_bytes();
65
66 ReservedSpace heap_rs = Universe::reserve_heap(reserved_heap_size, HeapAlignment);
67
68 os::trace_page_sizes("Heap",
69 MinHeapSize,
70 reserved_heap_size,
71 GenAlignment,
72 heap_rs.base(),
73 heap_rs.size());
74
75 initialize_reserved_region((HeapWord*)heap_rs.base(), (HeapWord*)(heap_rs.base() + heap_rs.size()));
76
77 PSCardTable* card_table = new PSCardTable(reserved_region());
78 card_table->initialize();
79 CardTableBarrierSet* const barrier_set = new CardTableBarrierSet(card_table);
80 barrier_set->initialize();
|
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 * version 2 for more details (a copy is included in the LICENSE file that
12 * accompanied this code).
13 *
14 * You should have received a copy of the GNU General Public License version
15 * 2 along with this work; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19 * or visit www.oracle.com if you need additional information or have any
20 * questions.
21 *
22 */
23
24 #include "precompiled.hpp"
25 #include "code/codeCache.hpp"
26 #include "gc/parallel/adjoiningGenerations.hpp"
27 #include "gc/parallel/adjoiningGenerationsForHeteroHeap.hpp"
28 #include "gc/parallel/adjoiningVirtualSpaces.hpp"
29 #include "gc/parallel/parallelArguments.hpp"
30 #include "gc/parallel/objectStartArray.inline.hpp"
31 #include "gc/parallel/parallelScavengeHeap.inline.hpp"
32 #include "gc/parallel/psAdaptiveSizePolicy.hpp"
33 #include "gc/parallel/psMarkSweepProxy.hpp"
34 #include "gc/parallel/psMemoryPool.hpp"
35 #include "gc/parallel/psParallelCompact.inline.hpp"
36 #include "gc/parallel/psPromotionManager.hpp"
37 #include "gc/parallel/psScavenge.hpp"
38 #include "gc/parallel/psVMOperations.hpp"
39 #include "gc/shared/gcHeapSummary.hpp"
40 #include "gc/shared/gcLocker.hpp"
41 #include "gc/shared/gcWhen.hpp"
42 #include "gc/shared/genArguments.hpp"
43 #include "gc/shared/scavengableNMethods.hpp"
44 #include "logging/log.hpp"
45 #include "memory/metaspaceCounters.hpp"
46 #include "memory/universe.hpp"
47 #include "oops/oop.inline.hpp"
48 #include "runtime/handles.inline.hpp"
49 #include "runtime/java.hpp"
50 #include "runtime/vmThread.hpp"
51 #include "services/memoryManager.hpp"
52 #include "services/memTracker.hpp"
53 #include "utilities/macros.hpp"
54 #include "utilities/vmError.hpp"
55
56 PSYoungGen* ParallelScavengeHeap::_young_gen = NULL;
57 PSOldGen* ParallelScavengeHeap::_old_gen = NULL;
58 PSAdaptiveSizePolicy* ParallelScavengeHeap::_size_policy = NULL;
59 PSGCAdaptivePolicyCounters* ParallelScavengeHeap::_gc_policy_counters = NULL;
60
61 jint ParallelScavengeHeap::initialize() {
62 const size_t reserved_heap_size = ParallelArguments::heap_reserved_size_bytes();
63
64 ReservedSpace heap_rs = Universe::reserve_heap(reserved_heap_size, HeapAlignment);
65
66 os::trace_page_sizes("Heap",
67 MinHeapSize,
68 reserved_heap_size,
69 GenAlignment,
70 heap_rs.base(),
71 heap_rs.size());
72
73 initialize_reserved_region((HeapWord*)heap_rs.base(), (HeapWord*)(heap_rs.base() + heap_rs.size()));
74
75 PSCardTable* card_table = new PSCardTable(reserved_region());
76 card_table->initialize();
77 CardTableBarrierSet* const barrier_set = new CardTableBarrierSet(card_table);
78 barrier_set->initialize();
|
98 const size_t old_capacity = _old_gen->capacity_in_bytes();
99 const size_t initial_promo_size = MIN2(eden_capacity, old_capacity);
100 _size_policy =
101 new PSAdaptiveSizePolicy(eden_capacity,
102 initial_promo_size,
103 young_gen()->to_space()->capacity_in_bytes(),
104 GenAlignment,
105 max_gc_pause_sec,
106 max_gc_minor_pause_sec,
107 GCTimeRatio
108 );
109
110 assert(ParallelArguments::is_heterogeneous_heap() || !UseAdaptiveGCBoundary ||
111 (old_gen()->virtual_space()->high_boundary() ==
112 young_gen()->virtual_space()->low_boundary()),
113 "Boundaries must meet");
114 // initialize the policy counters - 2 collectors, 2 generations
115 _gc_policy_counters =
116 new PSGCAdaptivePolicyCounters("ParScav:MSC", 2, 2, _size_policy);
117
118 // Set up the GCTaskManager
119 _gc_task_manager = GCTaskManager::create(ParallelGCThreads);
120
121 if (UseParallelOldGC && !PSParallelCompact::initialize()) {
122 return JNI_ENOMEM;
123 }
124
125 // Set up WorkGang
126 _workers.initialize_workers();
127
128 return JNI_OK;
129 }
130
131 void ParallelScavengeHeap::initialize_serviceability() {
132
133 _eden_pool = new EdenMutableSpacePool(_young_gen,
134 _young_gen->eden_space(),
135 "PS Eden Space",
136 false /* support_usage_threshold */);
137
138 _survivor_pool = new SurvivorMutableSpacePool(_young_gen,
139 "PS Survivor Space",
|
96 const size_t old_capacity = _old_gen->capacity_in_bytes();
97 const size_t initial_promo_size = MIN2(eden_capacity, old_capacity);
98 _size_policy =
99 new PSAdaptiveSizePolicy(eden_capacity,
100 initial_promo_size,
101 young_gen()->to_space()->capacity_in_bytes(),
102 GenAlignment,
103 max_gc_pause_sec,
104 max_gc_minor_pause_sec,
105 GCTimeRatio
106 );
107
108 assert(ParallelArguments::is_heterogeneous_heap() || !UseAdaptiveGCBoundary ||
109 (old_gen()->virtual_space()->high_boundary() ==
110 young_gen()->virtual_space()->low_boundary()),
111 "Boundaries must meet");
112 // initialize the policy counters - 2 collectors, 2 generations
113 _gc_policy_counters =
114 new PSGCAdaptivePolicyCounters("ParScav:MSC", 2, 2, _size_policy);
115
116 if (UseParallelOldGC && !PSParallelCompact::initialize()) {
117 return JNI_ENOMEM;
118 }
119
120 // Set up WorkGang
121 _workers.initialize_workers();
122
123 return JNI_OK;
124 }
125
126 void ParallelScavengeHeap::initialize_serviceability() {
127
128 _eden_pool = new EdenMutableSpacePool(_young_gen,
129 _young_gen->eden_space(),
130 "PS Eden Space",
131 false /* support_usage_threshold */);
132
133 _survivor_pool = new SurvivorMutableSpacePool(_young_gen,
134 "PS Survivor Space",
|
583 VirtualSpaceSummary heap_summary = create_heap_space_summary();
584 return PSHeapSummary(heap_summary, used(), old_summary, old_space, young_summary, eden_space, from_space, to_space);
585 }
586
587 void ParallelScavengeHeap::print_on(outputStream* st) const {
588 young_gen()->print_on(st);
589 old_gen()->print_on(st);
590 MetaspaceUtils::print_on(st);
591 }
592
593 void ParallelScavengeHeap::print_on_error(outputStream* st) const {
594 this->CollectedHeap::print_on_error(st);
595
596 if (UseParallelOldGC) {
597 st->cr();
598 PSParallelCompact::print_on_error(st);
599 }
600 }
601
602 void ParallelScavengeHeap::gc_threads_do(ThreadClosure* tc) const {
603 PSScavenge::gc_task_manager()->threads_do(tc);
604 }
605
606 void ParallelScavengeHeap::print_gc_threads_on(outputStream* st) const {
607 PSScavenge::gc_task_manager()->print_threads_on(st);
608 }
609
610 void ParallelScavengeHeap::print_tracing_info() const {
611 AdaptiveSizePolicyOutput::print();
612 log_debug(gc, heap, exit)("Accumulated young generation GC time %3.7f secs", PSScavenge::accumulated_time()->seconds());
613 log_debug(gc, heap, exit)("Accumulated old generation GC time %3.7f secs",
614 UseParallelOldGC ? PSParallelCompact::accumulated_time()->seconds() : PSMarkSweepProxy::accumulated_time()->seconds()
615 }
616
617
618 void ParallelScavengeHeap::verify(VerifyOption option /* ignored */) {
619 // Why do we need the total_collections()-filter below?
620 if (total_collections() > 0) {
621 log_debug(gc, verify)("Tenured");
622 old_gen()->verify();
623
624 log_debug(gc, verify)("Eden");
625 young_gen()->verify();
626 }
|
578 VirtualSpaceSummary heap_summary = create_heap_space_summary();
579 return PSHeapSummary(heap_summary, used(), old_summary, old_space, young_summary, eden_space, from_space, to_space);
580 }
581
582 void ParallelScavengeHeap::print_on(outputStream* st) const {
583 young_gen()->print_on(st);
584 old_gen()->print_on(st);
585 MetaspaceUtils::print_on(st);
586 }
587
588 void ParallelScavengeHeap::print_on_error(outputStream* st) const {
589 this->CollectedHeap::print_on_error(st);
590
591 if (UseParallelOldGC) {
592 st->cr();
593 PSParallelCompact::print_on_error(st);
594 }
595 }
596
597 void ParallelScavengeHeap::gc_threads_do(ThreadClosure* tc) const {
598 ParallelScavengeHeap::heap()->workers().threads_do(tc);
599 }
600
601 void ParallelScavengeHeap::print_gc_threads_on(outputStream* st) const {
602 ParallelScavengeHeap::heap()->workers().print_worker_threads_on(st);
603 }
604
605 void ParallelScavengeHeap::print_tracing_info() const {
606 AdaptiveSizePolicyOutput::print();
607 log_debug(gc, heap, exit)("Accumulated young generation GC time %3.7f secs", PSScavenge::accumulated_time()->seconds());
608 log_debug(gc, heap, exit)("Accumulated old generation GC time %3.7f secs",
609 UseParallelOldGC ? PSParallelCompact::accumulated_time()->seconds() : PSMarkSweepProxy::accumulated_time()->seconds()
610 }
611
612
613 void ParallelScavengeHeap::verify(VerifyOption option /* ignored */) {
614 // Why do we need the total_collections()-filter below?
615 if (total_collections() > 0) {
616 log_debug(gc, verify)("Tenured");
617 old_gen()->verify();
618
619 log_debug(gc, verify)("Eden");
620 young_gen()->verify();
621 }
|