Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_realtime/EnvironmentRealtime.cpp
5986 views
1
/*******************************************************************************
2
* Copyright (c) 1991, 2019 IBM Corp. and others
3
*
4
* This program and the accompanying materials are made available under
5
* the terms of the Eclipse Public License 2.0 which accompanies this
6
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
7
* or the Apache License, Version 2.0 which accompanies this distribution and
8
* is available at https://www.apache.org/licenses/LICENSE-2.0.
9
*
10
* This Source Code may also be made available under the following
11
* Secondary Licenses when the conditions for such availability set
12
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
13
* General Public License, version 2 with the GNU Classpath
14
* Exception [1] and GNU General Public License, version 2 with the
15
* OpenJDK Assembly Exception [2].
16
*
17
* [1] https://www.gnu.org/software/classpath/license.html
18
* [2] http://openjdk.java.net/legal/assembly-exception.html
19
*
20
* 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
21
*******************************************************************************/
22
23
#include "omr.h"
24
#include "omrcfg.h"
25
26
#include "EnvironmentRealtime.hpp"
27
#include "GCExtensionsBase.hpp"
28
#include "HeapRegionQueue.hpp"
29
#include "OSInterface.hpp"
30
#include "RealtimeGC.hpp"
31
#include "RealtimeRootScanner.hpp"
32
#include "SegregatedAllocationTracker.hpp"
33
#include "Timer.hpp"
34
35
MM_EnvironmentRealtime *
36
MM_EnvironmentRealtime::newInstance(MM_GCExtensionsBase *extensions, OMR_VMThread *omrVMThread)
37
{
38
void *envPtr;
39
MM_EnvironmentRealtime *env = NULL;
40
41
envPtr = (void *)pool_newElement(extensions->environments);
42
if (envPtr) {
43
if (omrVMThread) {
44
env = new(envPtr) MM_EnvironmentRealtime(omrVMThread);
45
} else {
46
env = new(envPtr) MM_EnvironmentRealtime(extensions->getOmrVM());
47
}
48
if (!env->initialize(extensions)) {
49
env->kill();
50
env = NULL;
51
}
52
}
53
54
return env;
55
}
56
57
void
58
MM_EnvironmentRealtime::kill()
59
{
60
MM_EnvironmentBase::kill();
61
}
62
63
bool
64
MM_EnvironmentRealtime::initialize(MM_GCExtensionsBase *extensions)
65
{
66
/* initialize base class */
67
if(!MM_EnvironmentBase::initialize(extensions)) {
68
return false;
69
}
70
71
if (NULL == (_timer = MM_Timer::newInstance(this, _osInterface))) {
72
return false;
73
}
74
75
_monitorCacheCleared = FALSE;
76
77
_distanceToYieldTimeCheck = extensions->distanceToYieldTimeCheck;
78
79
_overflowCache = (MM_HeapRegionDescriptorRealtime**)getForge()->allocate(sizeof(MM_HeapRegionDescriptorRealtime *) * extensions->overflowCacheCount, MM_AllocationCategory::FIXED, OMR_GET_CALLSITE());
80
if (NULL == _overflowCache) {
81
return false;
82
}
83
84
_yieldDisableDepth = 0;
85
86
return true;
87
}
88
89
void
90
MM_EnvironmentRealtime::tearDown(MM_GCExtensionsBase *extensions)
91
{
92
if (_overflowCache != NULL) {
93
getForge()->free(_overflowCache);
94
_overflowCache = NULL;
95
}
96
if (NULL != _timer) {
97
_timer->kill(this);
98
_timer = NULL;
99
}
100
101
/* tearDown base class */
102
MM_EnvironmentBase::tearDown(extensions);
103
}
104
105
void MM_EnvironmentRealtime::disableYield()
106
{
107
_yieldDisableDepth++;
108
}
109
110
void MM_EnvironmentRealtime::enableYield()
111
{
112
_yieldDisableDepth--;
113
assert1(_yieldDisableDepth >= 0);
114
}
115
116
void
117
MM_EnvironmentRealtime::reportScanningSuspended() {
118
if (NULL != _rootScanner) {
119
_rootScanner->reportScanningSuspended();
120
}
121
}
122
123
void
124
MM_EnvironmentRealtime::reportScanningResumed() {
125
if (NULL != _rootScanner) {
126
_rootScanner->reportScanningResumed();
127
}
128
}
129
130