Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/gc/parallel/parallelArguments.cpp
41149 views
1
/*
2
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
3
* Copyright (c) 2017, Red Hat, Inc. and/or its affiliates.
4
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5
*
6
* This code is free software; you can redistribute it and/or modify it
7
* under the terms of the GNU General Public License version 2 only, as
8
* published by the Free Software Foundation.
9
*
10
* This code is distributed in the hope that it will be useful, but WITHOUT
11
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13
* version 2 for more details (a copy is included in the LICENSE file that
14
* accompanied this code).
15
*
16
* You should have received a copy of the GNU General Public License version
17
* 2 along with this work; if not, write to the Free Software Foundation,
18
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19
*
20
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21
* or visit www.oracle.com if you need additional information or have any
22
* questions.
23
*
24
*/
25
26
#include "precompiled.hpp"
27
#include "gc/parallel/parallelArguments.hpp"
28
#include "gc/parallel/parallelScavengeHeap.hpp"
29
#include "gc/shared/adaptiveSizePolicy.hpp"
30
#include "gc/shared/gcArguments.hpp"
31
#include "gc/shared/genArguments.hpp"
32
#include "gc/shared/workerPolicy.hpp"
33
#include "logging/log.hpp"
34
#include "runtime/globals.hpp"
35
#include "runtime/globals_extension.hpp"
36
#include "runtime/java.hpp"
37
#include "utilities/defaultStream.hpp"
38
#include "utilities/powerOfTwo.hpp"
39
40
size_t ParallelArguments::conservative_max_heap_alignment() {
41
return compute_heap_alignment();
42
}
43
44
void ParallelArguments::initialize() {
45
GCArguments::initialize();
46
assert(UseParallelGC, "Error");
47
48
// If no heap maximum was requested explicitly, use some reasonable fraction
49
// of the physical memory, up to a maximum of 1GB.
50
FLAG_SET_DEFAULT(ParallelGCThreads,
51
WorkerPolicy::parallel_worker_threads());
52
if (ParallelGCThreads == 0) {
53
jio_fprintf(defaultStream::error_stream(),
54
"The Parallel GC can not be combined with -XX:ParallelGCThreads=0\n");
55
vm_exit(1);
56
}
57
58
if (UseAdaptiveSizePolicy) {
59
// We don't want to limit adaptive heap sizing's freedom to adjust the heap
60
// unless the user actually sets these flags.
61
if (FLAG_IS_DEFAULT(MinHeapFreeRatio)) {
62
FLAG_SET_DEFAULT(MinHeapFreeRatio, 0);
63
}
64
if (FLAG_IS_DEFAULT(MaxHeapFreeRatio)) {
65
FLAG_SET_DEFAULT(MaxHeapFreeRatio, 100);
66
}
67
}
68
69
// If InitialSurvivorRatio or MinSurvivorRatio were not specified, but the
70
// SurvivorRatio has been set, reset their default values to SurvivorRatio +
71
// 2. By doing this we make SurvivorRatio also work for Parallel Scavenger.
72
// See CR 6362902 for details.
73
if (!FLAG_IS_DEFAULT(SurvivorRatio)) {
74
if (FLAG_IS_DEFAULT(InitialSurvivorRatio)) {
75
FLAG_SET_DEFAULT(InitialSurvivorRatio, SurvivorRatio + 2);
76
}
77
if (FLAG_IS_DEFAULT(MinSurvivorRatio)) {
78
FLAG_SET_DEFAULT(MinSurvivorRatio, SurvivorRatio + 2);
79
}
80
}
81
82
// Par compact uses lower default values since they are treated as
83
// minimums. These are different defaults because of the different
84
// interpretation and are not ergonomically set.
85
if (FLAG_IS_DEFAULT(MarkSweepDeadRatio)) {
86
FLAG_SET_DEFAULT(MarkSweepDeadRatio, 1);
87
}
88
}
89
90
// The alignment used for boundary between young gen and old gen
91
static size_t default_gen_alignment() {
92
return 64 * K * HeapWordSize;
93
}
94
95
void ParallelArguments::initialize_alignments() {
96
SpaceAlignment = GenAlignment = default_gen_alignment();
97
HeapAlignment = compute_heap_alignment();
98
}
99
100
void ParallelArguments::initialize_heap_flags_and_sizes_one_pass() {
101
// Do basic sizing work
102
GenArguments::initialize_heap_flags_and_sizes();
103
104
// The survivor ratio's are calculated "raw", unlike the
105
// default gc, which adds 2 to the ratio value. We need to
106
// make sure the values are valid before using them.
107
if (MinSurvivorRatio < 3) {
108
FLAG_SET_ERGO(MinSurvivorRatio, 3);
109
}
110
111
if (InitialSurvivorRatio < 3) {
112
FLAG_SET_ERGO(InitialSurvivorRatio, 3);
113
}
114
}
115
116
void ParallelArguments::initialize_heap_flags_and_sizes() {
117
initialize_heap_flags_and_sizes_one_pass();
118
119
const size_t min_pages = 4; // 1 for eden + 1 for each survivor + 1 for old
120
const size_t page_sz = os::page_size_for_region_aligned(MinHeapSize, min_pages);
121
122
// Can a page size be something else than a power of two?
123
assert(is_power_of_2((intptr_t)page_sz), "must be a power of 2");
124
size_t new_alignment = align_up(page_sz, GenAlignment);
125
if (new_alignment != GenAlignment) {
126
GenAlignment = new_alignment;
127
SpaceAlignment = new_alignment;
128
// Redo everything from the start
129
initialize_heap_flags_and_sizes_one_pass();
130
}
131
}
132
133
size_t ParallelArguments::heap_reserved_size_bytes() {
134
return MaxHeapSize;
135
}
136
137
size_t ParallelArguments::heap_max_size_bytes() {
138
return MaxHeapSize;
139
}
140
141
CollectedHeap* ParallelArguments::create_heap() {
142
return new ParallelScavengeHeap();
143
}
144
145