Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_modron_startup/mmparseXgcpolicy.cpp
5986 views
1
2
/*******************************************************************************
3
* Copyright (c) 1991, 2018 IBM Corp. and others
4
*
5
* This program and the accompanying materials are made available under
6
* the terms of the Eclipse Public License 2.0 which accompanies this
7
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
8
* or the Apache License, Version 2.0 which accompanies this distribution and
9
* is available at https://www.apache.org/licenses/LICENSE-2.0.
10
*
11
* This Source Code may also be made available under the following
12
* Secondary Licenses when the conditions for such availability set
13
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
14
* General Public License, version 2 with the GNU Classpath
15
* Exception [1] and GNU General Public License, version 2 with the
16
* OpenJDK Assembly Exception [2].
17
*
18
* [1] https://www.gnu.org/software/classpath/license.html
19
* [2] http://openjdk.java.net/legal/assembly-exception.html
20
*
21
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
22
*******************************************************************************/
23
24
/**
25
* @file
26
* @ingroup GC_Modron_Startup
27
*/
28
29
#include "j9.h"
30
#include "j9cfg.h"
31
#include "j2sever.h"
32
#include "jvminit.h"
33
#include "mmparse.h"
34
35
#include "Configuration.hpp"
36
#include "GCExtensions.hpp"
37
38
#include <string.h>
39
40
bool MMINLINE
41
isOptthruputGCPolicySupported(MM_GCExtensions *extensions)
42
{
43
#if defined(J9VM_GC_MODRON_STANDARD)
44
return true;
45
#endif /* J9VM_GC_MODRON_STANDARD */
46
return false;
47
}
48
49
bool MMINLINE
50
isNoGcGCPolicySupported(MM_GCExtensions *extensions)
51
{
52
return true;
53
}
54
55
bool MMINLINE
56
isOptavgpauseGCPolicySupported(MM_GCExtensions *extensions)
57
{
58
#if defined(J9VM_GC_MODRON_STANDARD)
59
return true;
60
#endif /* J9VM_GC_MODRON_STANDARD */
61
return false;
62
}
63
64
bool MMINLINE
65
isGenconGCPolicySupported(MM_GCExtensions *extensions)
66
{
67
#if defined(J9VM_GC_MODRON_STANDARD) && defined(J9VM_GC_GENERATIONAL)
68
return true;
69
#endif /* J9VM_GC_MODRON_STANDARD && J9VM_GC_GENERATIONAL */
70
return false;
71
}
72
73
bool MMINLINE
74
isSubpoolAliasGCPolicySupported(MM_GCExtensions *extensions)
75
{
76
#if defined(J9VM_GC_MODRON_STANDARD) && defined(J9VM_GC_SUBPOOLS_ALIAS)
77
return true;
78
#endif /* J9VM_GC_MODRON_STANDARD && J9VM_GC_SUBPOOLS_ALIAS */
79
return false;
80
}
81
82
bool MMINLINE
83
isMetronomeGCPolicySupported(MM_GCExtensions *extensions)
84
{
85
#if defined(J9VM_GC_REALTIME)
86
#if defined(AIXPPC)
87
return true;
88
#elif defined(LINUX) && (defined(J9HAMMER) || defined(J9X86))
89
return true;
90
#endif
91
#endif /* J9VM_GC_REALTIME */
92
return false;
93
}
94
95
bool MMINLINE
96
isBalancedGCPolicySupported(MM_GCExtensions *extensions)
97
{
98
#if defined (J9VM_GC_VLHGC) && defined (J9VM_ENV_DATA64)
99
return true;
100
#endif /* J9VM_GC_VLHGC && J9VM_ENV_DATA64 */
101
return false;
102
}
103
104
/**
105
* Consume -Xgcpolicy: arguments.
106
* support -XX:+UseNoGC option for compatibility
107
*
108
* For compatibility with previous versions multiple gc policy specifications allowed:
109
* last one wins
110
*/
111
void
112
gcParseXgcpolicy(MM_GCExtensions *extensions)
113
{
114
J9JavaVM *vm = (J9JavaVM *)extensions->getOmrVM()->_language_vm;
115
J9VMInitArgs *vmArgs = vm->vmArgsArray;
116
bool enableUnsupported = false;
117
118
IDATA xgcpolicyIndex = FIND_ARG_IN_VMARGS_FORWARD( STARTSWITH_MATCH, "-Xgcpolicy:", NULL );
119
IDATA lastXgcpolicyIndex = 0;
120
while (xgcpolicyIndex >= 0) {
121
char *policy = NULL;
122
GET_OPTION_VALUE( xgcpolicyIndex, ':', &policy);
123
124
if (NULL != policy) {
125
if (0 == strcmp("enableUnsupported", policy)) {
126
/* -Xgcpolicy:enableUnsupported permits selection of GC policies which aren't officially supported. */
127
CONSUME_ARG(vmArgs, xgcpolicyIndex);
128
enableUnsupported = true;
129
} else if (0 == strcmp("disableUnsupported", policy)) {
130
CONSUME_ARG(vmArgs, xgcpolicyIndex);
131
enableUnsupported = false;
132
} else {
133
lastXgcpolicyIndex = xgcpolicyIndex;
134
if (0 == strcmp("optthruput", policy)) {
135
if (isOptthruputGCPolicySupported(extensions) || enableUnsupported) {
136
CONSUME_ARG(vmArgs, xgcpolicyIndex);
137
extensions->configurationOptions._gcPolicy = gc_policy_optthruput;
138
}
139
} else if (0 == strcmp("subpool", policy)) {
140
if (isSubpoolAliasGCPolicySupported(extensions) || enableUnsupported) {
141
CONSUME_ARG(vmArgs, xgcpolicyIndex);
142
/* subpool is not supported anymore, use optthruput instead */
143
extensions->configurationOptions._gcPolicy = gc_policy_optthruput;
144
}
145
} else if (0 == strcmp("optavgpause", policy)) {
146
if (isOptavgpauseGCPolicySupported(extensions) || enableUnsupported) {
147
CONSUME_ARG(vmArgs, xgcpolicyIndex);
148
extensions->configurationOptions._gcPolicy = gc_policy_optavgpause;
149
}
150
} else if (0 == strcmp("gencon", policy)) {
151
if (isGenconGCPolicySupported(extensions) || enableUnsupported) {
152
CONSUME_ARG(vmArgs, xgcpolicyIndex);
153
extensions->configurationOptions._gcPolicy = gc_policy_gencon;
154
}
155
} else if (0 == strcmp("metronome", policy)) {
156
if (isMetronomeGCPolicySupported(extensions) || enableUnsupported) {
157
CONSUME_ARG(vmArgs, xgcpolicyIndex);
158
extensions->configurationOptions._gcPolicy = gc_policy_metronome;
159
}
160
} else if (0 == strcmp("balanced", policy)) {
161
if (isBalancedGCPolicySupported(extensions) || enableUnsupported) {
162
CONSUME_ARG(vmArgs, xgcpolicyIndex);
163
extensions->configurationOptions._gcPolicy = gc_policy_balanced;
164
}
165
} else if (0 == strcmp("nogc", policy)) {
166
if (isNoGcGCPolicySupported(extensions) || enableUnsupported) {
167
CONSUME_ARG(vmArgs, xgcpolicyIndex);
168
extensions->configurationOptions._gcPolicy = gc_policy_nogc;
169
}
170
}
171
}
172
}
173
174
xgcpolicyIndex = FIND_NEXT_ARG_IN_VMARGS_FORWARD( STARTSWITH_MATCH, "-Xgcpolicy:", NULL, xgcpolicyIndex);
175
}
176
177
IDATA xxUseNoGCIndex = FIND_AND_CONSUME_ARG(STARTSWITH_MATCH, "-XX:+UseNoGC", NULL);
178
if (xxUseNoGCIndex > lastXgcpolicyIndex) {
179
if (isNoGcGCPolicySupported(extensions) || enableUnsupported) {
180
extensions->configurationOptions._gcPolicy = gc_policy_nogc;
181
}
182
}
183
}
184
185