Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_vlhgc/CopyForwardSchemeTask.hpp
5986 views
1
2
/*******************************************************************************
3
* Copyright (c) 1991, 2020 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
#if !defined(COPYFORWARDSCHEMETASK_HPP_)
25
#define COPYFORWARDSCHEMETASK_HPP_
26
27
#include "omrcfg.h"
28
29
#include "modronopt.h"
30
#include "omrcomp.h"
31
#include "omrmodroncore.h"
32
33
#include "CopyForwardScheme.hpp"
34
#include "EnvironmentVLHGC.hpp"
35
#include "InterRegionRememberedSet.hpp"
36
#include "ParallelTask.hpp"
37
38
class MM_CycleState;
39
40
class MM_CopyForwardSchemeTask : public MM_ParallelTask
41
{
42
private:
43
MM_CopyForwardScheme *_copyForwardScheme; /**< Tasks controlling scheme instance */
44
MM_CycleState *_cycleState; /**< Collection cycle state active for the task */
45
46
public:
47
virtual UDATA getVMStateID() { return OMRVMSTATE_GC_SCAVENGE; };
48
49
virtual void run(MM_EnvironmentBase *envBase)
50
{
51
MM_EnvironmentVLHGC *env = MM_EnvironmentVLHGC::getEnvironment(envBase);
52
_copyForwardScheme->workThreadGarbageCollect(env);
53
}
54
55
void setup(MM_EnvironmentBase *envBase)
56
{
57
MM_EnvironmentVLHGC *env = MM_EnvironmentVLHGC::getEnvironment(envBase);
58
if (env->isMainThread()) {
59
Assert_MM_true(_cycleState == env->_cycleState);
60
} else {
61
Assert_MM_true(NULL == env->_cycleState);
62
env->_cycleState = _cycleState;
63
}
64
65
env->_workPacketStats.clear();
66
env->_copyForwardStats.clear();
67
68
/* record that this thread is participating in this cycle */
69
env->_copyForwardStats._gcCount = MM_GCExtensions::getExtensions(env)->globalVLHGCStats.gcCount;
70
env->_workPacketStats._gcCount = MM_GCExtensions::getExtensions(env)->globalVLHGCStats.gcCount;
71
}
72
73
void cleanup(MM_EnvironmentBase *envBase)
74
{
75
MM_EnvironmentVLHGC *env = MM_EnvironmentVLHGC::getEnvironment(envBase);
76
77
if (env->isMainThread()) {
78
Assert_MM_true(_cycleState == env->_cycleState);
79
} else {
80
env->_cycleState = NULL;
81
}
82
83
env->_lastOverflowedRsclWithReleasedBuffers = NULL;
84
}
85
86
void mainCleanup(MM_EnvironmentBase *envBase)
87
{
88
MM_EnvironmentVLHGC *env = MM_EnvironmentVLHGC::getEnvironment(envBase);
89
90
MM_GCExtensions::getExtensions(env)->interRegionRememberedSet->resetOverflowedList();
91
}
92
93
#if defined(J9MODRON_TGC_PARALLEL_STATISTICS)
94
void synchronizeGCThreads(MM_EnvironmentBase *env, const char *id);
95
bool synchronizeGCThreadsAndReleaseMain(MM_EnvironmentBase *env, const char *id);
96
bool synchronizeGCThreadsAndReleaseSingleThread(MM_EnvironmentBase *env, const char *id);
97
98
bool synchronizeGCThreadsAndReleaseMainForAbort(MM_EnvironmentBase *env, const char *id);
99
void synchronizeGCThreadsForMark(MM_EnvironmentBase *env, const char *id);
100
bool synchronizeGCThreadsAndReleaseMainForMark(MM_EnvironmentBase *env, const char *id);
101
void synchronizeGCThreadsForInterRegionRememberedSet(MM_EnvironmentBase *env, const char *id);
102
#endif /* J9MODRON_TGC_PARALLEL_STATISTICS */
103
104
/**
105
* Create a CopyForwardSchemeTask object.
106
*/
107
MM_CopyForwardSchemeTask(MM_EnvironmentVLHGC *env, MM_ParallelDispatcher *dispatcher, MM_CopyForwardScheme *copyForwardScheme, MM_CycleState *cycleState) :
108
MM_ParallelTask((MM_EnvironmentBase *)env, dispatcher)
109
, _copyForwardScheme(copyForwardScheme)
110
, _cycleState(cycleState)
111
{
112
_typeId = __FUNCTION__;
113
}
114
};
115
116
#endif /* COPYFORWARDSCHEMETASK_HPP_ */
117