Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_glue_java/GlobalCollectorDelegate.hpp
5985 views
1
/*******************************************************************************
2
* Copyright (c) 2017, 2020 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
#ifndef GLOBALCOLLECTORDELEGATE_HPP_
24
#define GLOBALCOLLECTORDELEGATE_HPP_
25
26
#include "omrcfg.h"
27
28
struct J9JavaVM;
29
30
class MM_EnvironmentBase;
31
class MM_GCExtensions;
32
class MM_GlobalCollector;
33
class MM_MarkingScheme;
34
35
class MM_GlobalCollectorDelegate
36
{
37
/*
38
* Data members
39
*/
40
private:
41
42
protected:
43
J9JavaVM *_javaVM;
44
MM_GCExtensions *_extensions;
45
MM_MarkingScheme *_markingScheme;
46
MM_GlobalCollector *_globalCollector;
47
#if defined(J9VM_GC_MODRON_COMPACTION)
48
uintptr_t _criticalSectionCount;
49
#endif /* defined(J9VM_GC_MODRON_COMPACTION) */
50
#if defined(J9VM_GC_FINALIZATION)
51
bool _finalizationRequired;
52
#endif /* defined(J9VM_GC_FINALIZATION) */
53
54
public:
55
56
/*
57
* Function members
58
*/
59
private:
60
#if defined(J9VM_GC_DYNAMIC_CLASS_UNLOADING)
61
bool enterClassUnloadMutex(MM_EnvironmentBase *env, bool force);
62
void exitClassUnloadMutex(MM_EnvironmentBase *env);
63
void unloadDeadClassLoaders(MM_EnvironmentBase *env);
64
#endif /* J9VM_GC_DYNAMIC_CLASS_UNLOADING */
65
66
protected:
67
68
public:
69
/**
70
* Initialize the delegate. For standard GC policies, the global collector and marking scheme
71
* instances must be provided.
72
*
73
* @param env environment for calling thread
74
* @param globalCollector the MM_GlobalCollector instance that the delegate is bound to
75
* @param markingScheme the MM_MarkingScheme instance (may be null if not standard GC)
76
* @return true if delegate initialized successfully
77
*/
78
bool initialize(MM_EnvironmentBase *env, MM_GlobalCollector *globalCollector, MM_MarkingScheme *markingScheme);
79
void tearDown(MM_EnvironmentBase *env);
80
81
void mainThreadGarbageCollectStarted(MM_EnvironmentBase *env);
82
void postMarkProcessing(MM_EnvironmentBase *env);
83
void mainThreadGarbageCollectFinished(MM_EnvironmentBase *env, bool compactedThisCycle);
84
void postCollect(MM_EnvironmentBase* env, MM_MemorySubSpace* subSpace);
85
86
bool isAllowUserHeapWalk();
87
void prepareHeapForWalk(MM_EnvironmentBase *env);
88
89
#if defined(OMR_ENV_DATA64) && defined(OMR_GC_FULL_POINTERS)
90
void poisonSlots(MM_EnvironmentBase *env);
91
void healSlots(MM_EnvironmentBase *env);
92
#endif /* defined(OMR_ENV_DATA64) && defined(OMR_GC_FULL_POINTERS) */
93
94
bool heapAddRange(MM_EnvironmentBase *env, MM_MemorySubSpace *subspace, UDATA size, void *lowAddress, void *highAddress);
95
bool heapRemoveRange(MM_EnvironmentBase *env, MM_MemorySubSpace *subspace, UDATA size, void *lowAddress, void *highAddress, void *lowValidAddress, void *highValidAddress);
96
97
bool isTimeForGlobalGCKickoff();
98
99
#if defined(J9VM_GC_MODRON_COMPACTION)
100
CompactPreventedReason checkIfCompactionShouldBePrevented(MM_EnvironmentBase *env);
101
#endif /* J9VM_GC_MODRON_COMPACTION */
102
103
#if defined(J9VM_GC_FINALIZATION)
104
void setFinalizationRequired() { _finalizationRequired = true; }
105
bool isFinalizationRequired() { return _finalizationRequired; }
106
#endif /* defined(J9VM_GC_FINALIZATION) */
107
108
MM_GlobalCollectorDelegate()
109
: _javaVM(NULL)
110
, _extensions(NULL)
111
, _markingScheme(NULL)
112
, _globalCollector(NULL)
113
#if defined(J9VM_GC_MODRON_COMPACTION)
114
, _criticalSectionCount(0)
115
#endif /* defined(J9VM_GC_MODRON_COMPACTION) */
116
#if defined(J9VM_GC_FINALIZATION)
117
, _finalizationRequired(false)
118
#endif /* defined(J9VM_GC_FINALIZATION) */
119
{}
120
};
121
#endif /* GLOBALCOLLECTORDELEGATE_HPP_ */
122
123