Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_base/GCExtensions.hpp
5986 views
1
2
/*******************************************************************************
3
* Copyright (c) 1991, 2022 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_Base
27
*/
28
29
#if !defined(GCEXTENSIONS_HPP_)
30
#define GCEXTENSIONS_HPP_
31
32
#include <string.h>
33
34
#include "arrayCopyInterface.h"
35
#include "j9cfg.h"
36
#include "j9comp.h"
37
#include "omrhookable.h"
38
#include "mmhook_internal.h"
39
#include "modronbase.h"
40
#include "omr.h"
41
#include "omrmodroncore.h"
42
43
#include "EnvironmentBase.hpp"
44
#include "GCExtensionsBase.hpp"
45
#include "MarkJavaStats.hpp"
46
#include "OMRVMThreadListIterator.hpp"
47
#include "VMThreadListIterator.hpp"
48
#include "VerboseGCInterface.h"
49
50
#if defined(J9VM_GC_MODRON_SCAVENGER)
51
#include "ScavengerJavaStats.hpp"
52
#endif /* J9VM_GC_MODRON_SCAVENGER */
53
54
class MM_ClassLoaderManager;
55
class MM_EnvironmentBase;
56
class MM_HeapMap;
57
class MM_MemorySubSpace;
58
class MM_ObjectAccessBarrier;
59
class MM_OwnableSynchronizerObjectList;
60
class MM_StringTable;
61
class MM_UnfinalizedObjectList;
62
class MM_Wildcard;
63
64
#if defined(J9VM_GC_FINALIZATION)
65
class GC_FinalizeListManager;
66
#endif /* J9VM_GC_FINALIZATION */
67
68
#if defined(J9VM_GC_REALTIME)
69
class MM_ReferenceObjectList;
70
#endif /* J9VM_GC_REALTIME */
71
72
#if defined(OMR_GC_IDLE_HEAP_MANAGER)
73
class MM_IdleGCManager;
74
#endif
75
76
#define DEFAULT_SURVIVOR_MINIMUM_FREESIZE 2048
77
#define DEFAULT_SURVIVOR_THRESHOLD 512
78
#define MAXIMUM_SURVIVOR_MINIMUM_FREESIZE 524288
79
#define MAXIMUM_SURVIVOR_THRESHOLD 8192
80
#define MINIMUM_SURVIVOR_MINIMUM_FREESIZE 512
81
#define MINIMUM_SURVIVOR_THRESHOLD 512
82
83
/**
84
* @todo Provide class documentation
85
* @ingroup GC_Base
86
*/
87
class MM_GCExtensions : public MM_GCExtensionsBase {
88
private:
89
MM_OwnableSynchronizerObjectList* ownableSynchronizerObjectLists; /**< The global linked list of ownable synchronizer object lists. */
90
public:
91
MM_StringTable* stringTable; /**< top level String Table structure (internally organized as a set of hash sub-tables */
92
93
void* gcchkExtensions;
94
95
void* tgcExtensions;
96
J9MemoryManagerVerboseInterface verboseFunctionTable;
97
98
#if defined(J9VM_GC_FINALIZATION)
99
IDATA finalizeCycleInterval;
100
IDATA finalizeCycleLimit;
101
#endif /* J9VM_GC_FINALIZATION */
102
103
MM_HookInterface hookInterface;
104
105
bool collectStringConstants;
106
107
MM_MarkJavaStats markJavaStats;
108
#if defined(J9VM_GC_MODRON_SCAVENGER)
109
MM_ScavengerJavaStats scavengerJavaStats;
110
#endif /* J9VM_GC_MODRON_SCAVENGER */
111
112
#if defined(J9VM_GC_DYNAMIC_CLASS_UNLOADING)
113
enum DynamicClassUnloading {
114
DYNAMIC_CLASS_UNLOADING_NEVER,
115
DYNAMIC_CLASS_UNLOADING_ON_CLASS_LOADER_CHANGES,
116
DYNAMIC_CLASS_UNLOADING_ALWAYS
117
};
118
DynamicClassUnloading dynamicClassUnloading;
119
120
bool dynamicClassUnloadingSet; /**< is true if value for dynamicClassUnloading was specified in command line */
121
122
UDATA runtimeCheckDynamicClassUnloading;
123
bool dynamicClassUnloadingKickoffThresholdForced; /**< true if classUnloadingKickoffThreshold is specified in java options. */
124
bool dynamicClassUnloadingThresholdForced; /**< true if classUnloadingThresholdForced is specified in java options. */
125
UDATA dynamicClassUnloadingKickoffThreshold; /**< the threshold to kickoff a concurrent global GC from a scavenge */
126
UDATA dynamicClassUnloadingThreshold; /**< the threshold to trigger class unloading during a global GC */
127
double classUnloadingAnonymousClassWeight; /**< The weight factor to apply to anonymous classes for threshold comparisons */
128
#endif /* J9VM_GC_DYNAMIC_CLASS_UNLOADING */
129
130
U_32 _stringTableListToTreeThreshold; /**< Threshold at which we start using trees instead of lists for collision resolution in the String table */
131
132
#if defined(J9VM_GC_DYNAMIC_CLASS_UNLOADING)
133
bool fvtest_forceFinalizeClassLoaders;
134
#endif /* J9VM_GC_DYNAMIC_CLASS_UNLOADING */
135
136
UDATA maxSoftReferenceAge; /**< The fixed age specified as the soft reference threshold which acts as our baseline for the dynamicMaxSoftReferenceAge */
137
UDATA dynamicMaxSoftReferenceAge; /**< The age which represents the clearing age of soft references for a globalGC cycle. At the end of a GC cycle, it will be updated for the following cycle by taking the percentage of free heap in the oldest generation as a fraction of the maxSoftReferenceAge */
138
#if defined(J9VM_GC_FINALIZATION)
139
GC_FinalizeListManager* finalizeListManager;
140
#endif /* J9VM_GC_FINALIZATION */
141
142
J9ReferenceArrayCopyTable referenceArrayCopyTable;
143
144
#if defined(J9VM_GC_REALTIME)
145
MM_ReferenceObjectList* referenceObjectLists; /**< A global array of lists of reference objects (i.e. weak/soft/phantom) */
146
#endif /* J9VM_GC_REALTIME */
147
MM_ObjectAccessBarrier* accessBarrier;
148
149
#if defined(J9VM_GC_FINALIZATION)
150
UDATA finalizeMainPriority; /**< cmd line option to set finalize main thread priority */
151
UDATA finalizeWorkerPriority; /**< cmd line option to set finalize worker thread priority */
152
#endif /* J9VM_GC_FINALIZATION */
153
154
MM_ClassLoaderManager* classLoaderManager; /**< Pointer to the gc's classloader manager to process classloaders/classes */
155
#if defined(J9VM_GC_DYNAMIC_CLASS_UNLOADING)
156
UDATA deadClassLoaderCacheSize;
157
#endif /*defined(J9VM_GC_DYNAMIC_CLASS_UNLOADING) */
158
159
MM_UnfinalizedObjectList* unfinalizedObjectLists; /**< The global linked list of unfinalized object lists. */
160
161
UDATA objectListFragmentCount; /**< the size of Local Object Buffer(per gc thread), used by referenceObjectBuffer, UnfinalizedObjectBuffer and OwnableSynchronizerObjectBuffer */
162
163
MM_Wildcard* numaCommonThreadClassNamePatterns; /**< A linked list of thread class names which should be associated with the common context */
164
165
struct {
166
MM_UserSpecifiedParameterUDATA _Xmn; /**< Initial value of -Xmn specified by the user */
167
MM_UserSpecifiedParameterUDATA _Xmns; /**< Initial value of -Xmns specified by the user */
168
MM_UserSpecifiedParameterUDATA _Xmnx; /**< Initial value of -Xmnx specified by the user */
169
} userSpecifiedParameters;
170
171
/**
172
* Values for com.ibm.oti.vm.VM.J9_JIT_STRING_DEDUP_POLICY
173
* must hava the same values as J9_JIT_STRING_DEDUP_POLICY_DISABLED, J9_JIT_STRING_DEDUP_POLICY_FAVOUR_LOWER and J9_JIT_STRING_DEDUP_POLICY_FAVOUR_HIGHER.
174
*/
175
enum JitStringDeDupPolicy {
176
J9_JIT_STRING_DEDUP_POLICY_DISABLED = 0,
177
J9_JIT_STRING_DEDUP_POLICY_FAVOUR_LOWER = 1,
178
J9_JIT_STRING_DEDUP_POLICY_FAVOUR_HIGHER = 2,
179
J9_JIT_STRING_DEDUP_POLICY_UNDEFINED = 3,
180
};
181
JitStringDeDupPolicy stringDedupPolicy;
182
183
IDATA _asyncCallbackKey;
184
IDATA _TLHAsyncCallbackKey;
185
186
bool _HeapManagementMXBeanBackCompatibilityEnabled;
187
188
#if defined(OMR_GC_IDLE_HEAP_MANAGER)
189
MM_IdleGCManager* idleGCManager; /**< Manager which registers for VM Runtime State notification & manages free heap on notification */
190
#endif
191
192
double maxRAMPercent; /**< Value of -XX:MaxRAMPercentage specified by the user */
193
double initialRAMPercent; /**< Value of -XX:InitialRAMPercentage specified by the user */
194
UDATA minimumFreeSizeForSurvivor; /**< minimum free size can be reused by collector as survivor, for balanced GC only */
195
UDATA freeSizeThresholdForSurvivor; /**< if average freeSize(freeSize/freeCount) of the region is smaller than the Threshold, the region would not be reused by collector as survivor, for balanced GC only */
196
bool recycleRemainders; /**< true if need to recycle TLHRemainders at the end of PGC, for balanced GC only */
197
198
protected:
199
private:
200
protected:
201
virtual bool initialize(MM_EnvironmentBase* env);
202
virtual void tearDown(MM_EnvironmentBase* env);
203
204
public:
205
static MM_GCExtensions* newInstance(MM_EnvironmentBase* env);
206
virtual void kill(MM_EnvironmentBase* env);
207
208
void computeDefaultMaxHeapForJava(bool enableOriginalJDK8HeapSizeCompatibilityOption);
209
210
MMINLINE J9HookInterface** getHookInterface() { return J9_HOOK_INTERFACE(hookInterface); };
211
212
/**
213
* Fetch the global string table instance.
214
* @return the string table
215
*/
216
MMINLINE MM_StringTable* getStringTable() { return stringTable; }
217
218
MMINLINE UDATA getDynamicMaxSoftReferenceAge()
219
{
220
return dynamicMaxSoftReferenceAge;
221
}
222
223
MMINLINE UDATA getMaxSoftReferenceAge()
224
{
225
return maxSoftReferenceAge;
226
}
227
228
virtual void identityHashDataAddRange(MM_EnvironmentBase* env, MM_MemorySubSpace* subspace, UDATA size, void* lowAddress, void* highAddress);
229
virtual void identityHashDataRemoveRange(MM_EnvironmentBase* env, MM_MemorySubSpace* subspace, UDATA size, void* lowAddress, void* highAddress);
230
231
void updateIdentityHashDataForSaltIndex(UDATA index);
232
233
/**
234
* Set Tenure address range
235
* @param base low address of Old subspace range
236
* @param size size of Old subspace in bytes
237
*/
238
virtual void setTenureAddressRange(void* base, UDATA size)
239
{
240
_tenureBase = base;
241
_tenureSize = size;
242
243
/* todo: dagar move back to MemorySubSpaceGeneric addTenureRange() and removeTenureRange() once
244
* heapBaseForBarrierRange0 heapSizeForBarrierRange0 can be removed from J9VMThread
245
*
246
* setTenureAddressRange() can be removed fromo GCExtensions.hpp and made inline again
247
*/
248
GC_OMRVMThreadListIterator omrVMThreadListIterator(_omrVM);
249
while (OMR_VMThread* walkThread = omrVMThreadListIterator.nextOMRVMThread()) {
250
walkThread->lowTenureAddress = heapBaseForBarrierRange0;
251
walkThread->highTenureAddress = (void*)((UDATA)heapBaseForBarrierRange0 + heapSizeForBarrierRange0);
252
walkThread->heapBaseForBarrierRange0 = heapBaseForBarrierRange0;
253
walkThread->heapSizeForBarrierRange0 = heapSizeForBarrierRange0;
254
}
255
256
GC_VMThreadListIterator vmThreadListIterator((J9JavaVM*)_omrVM->_language_vm);
257
while (J9VMThread* walkThread = vmThreadListIterator.nextVMThread()) {
258
walkThread->lowTenureAddress = heapBaseForBarrierRange0;
259
walkThread->highTenureAddress = (void*)((UDATA)heapBaseForBarrierRange0 + heapSizeForBarrierRange0);
260
walkThread->heapBaseForBarrierRange0 = heapBaseForBarrierRange0;
261
walkThread->heapSizeForBarrierRange0 = heapSizeForBarrierRange0;
262
}
263
}
264
265
266
static MM_GCExtensions* getExtensions(OMR_VM* omrVM) { return static_cast<MM_GCExtensions*>(MM_GCExtensionsBase::getExtensions(omrVM)); }
267
static MM_GCExtensions* getExtensions(OMR_VMThread* omrVMThread) { return static_cast<MM_GCExtensions*>(MM_GCExtensionsBase::getExtensions(omrVMThread->_vm)); }
268
static MM_GCExtensions* getExtensions(J9JavaVM* javaVM) { return static_cast<MM_GCExtensions*>(MM_GCExtensionsBase::getExtensions(javaVM->omrVM)); }
269
static MM_GCExtensions* getExtensions(J9VMThread* vmThread) { return getExtensions(vmThread->javaVM); }
270
static MM_GCExtensions* getExtensions(MM_GCExtensionsBase* ext) { return static_cast<MM_GCExtensions*>(ext); }
271
static MM_GCExtensions* getExtensions(MM_EnvironmentBase* env) { return getExtensions(env->getExtensions()); }
272
273
MMINLINE J9JavaVM* getJavaVM() {return static_cast<J9JavaVM*>(_omrVM->_language_vm);}
274
275
/**
276
* Return ownable synchronizer object lists by first ensuring that the lists are in a consistent state (e.g., during concurrent gc).
277
* This should be used by any external consumer (non-GC consuming the list)
278
* @param vmThread The current J9VMThread thread (used to invoke j9gc apis if required)
279
* @return Linked list of ownable synchronizer objects
280
*/
281
MM_OwnableSynchronizerObjectList* getOwnableSynchronizerObjectListsExternal(J9VMThread *vmThread);
282
MMINLINE MM_OwnableSynchronizerObjectList* getOwnableSynchronizerObjectLists() { return ownableSynchronizerObjectLists; }
283
MMINLINE void setOwnableSynchronizerObjectLists(MM_OwnableSynchronizerObjectList* newOwnableSynchronizerObjectLists) { ownableSynchronizerObjectLists = newOwnableSynchronizerObjectLists; }
284
285
/**
286
* Create a GCExtensions object
287
*/
288
MM_GCExtensions()
289
: MM_GCExtensionsBase()
290
, ownableSynchronizerObjectLists(NULL)
291
, stringTable(NULL)
292
, gcchkExtensions(NULL)
293
, tgcExtensions(NULL)
294
#if defined(J9VM_GC_FINALIZATION)
295
, finalizeCycleInterval(J9_FINALIZABLE_INTERVAL) /* 1/2 second */
296
, finalizeCycleLimit(0) /* 0 seconds (i.e. no time limit) */
297
#endif /* J9VM_GC_FINALIZATION */
298
#if defined(J9VM_GC_DYNAMIC_CLASS_UNLOADING)
299
, dynamicClassUnloadingSet(false)
300
, dynamicClassUnloadingKickoffThresholdForced(false)
301
, dynamicClassUnloadingThresholdForced(false)
302
, dynamicClassUnloadingKickoffThreshold(0)
303
, dynamicClassUnloadingThreshold(0)
304
, classUnloadingAnonymousClassWeight(1.0)
305
#endif /* J9VM_GC_DYNAMIC_CLASS_UNLOADING */
306
, _stringTableListToTreeThreshold(1024)
307
, maxSoftReferenceAge(32)
308
#if defined(J9VM_GC_FINALIZATION)
309
, finalizeMainPriority(J9THREAD_PRIORITY_NORMAL)
310
, finalizeWorkerPriority(J9THREAD_PRIORITY_NORMAL)
311
#endif /* J9VM_GC_FINALIZATION */
312
, classLoaderManager(NULL)
313
#if defined(J9VM_GC_DYNAMIC_CLASS_UNLOADING)
314
, deadClassLoaderCacheSize(1024 * 1024) /* default is one MiB */
315
#endif /* defined(J9VM_GC_DYNAMIC_CLASS_UNLOADING) */
316
, unfinalizedObjectLists(NULL)
317
, objectListFragmentCount(0)
318
, numaCommonThreadClassNamePatterns(NULL)
319
, stringDedupPolicy(J9_JIT_STRING_DEDUP_POLICY_UNDEFINED)
320
, _asyncCallbackKey(-1)
321
, _TLHAsyncCallbackKey(-1)
322
, _HeapManagementMXBeanBackCompatibilityEnabled(false)
323
#if defined(OMR_GC_IDLE_HEAP_MANAGER)
324
, idleGCManager(NULL)
325
#endif
326
, maxRAMPercent(0.0) /* this would get overwritten by user specified value */
327
, initialRAMPercent(0.0) /* this would get overwritten by user specified value */
328
, minimumFreeSizeForSurvivor(DEFAULT_SURVIVOR_MINIMUM_FREESIZE)
329
, freeSizeThresholdForSurvivor(DEFAULT_SURVIVOR_THRESHOLD)
330
, recycleRemainders(true)
331
{
332
_typeId = __FUNCTION__;
333
}
334
};
335
336
#endif /* GCEXTENSIONS_HPP_ */
337
338