Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_realtime/RealtimeMarkingScheme.hpp
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
#if !defined(REALTIMEMARKINGSCHEME_HPP_)
24
#define REALTIMEMARKINGSCHEME_HPP_
25
26
#include "omr.h"
27
28
#include "Base.hpp"
29
#include "EnvironmentRealtime.hpp"
30
#include "GCExtensionsBase.hpp"
31
#include "MarkMap.hpp"
32
33
#include "SegregatedMarkingScheme.hpp"
34
35
class MM_RealtimeGC;
36
class MM_RealtimeRootScanner;
37
class MM_Scheduler;
38
39
#define ITEM_IS_ARRAYLET 0x1
40
#define IS_ITEM_OBJECT(item) ((item & ITEM_IS_ARRAYLET) == 0x0)
41
#define IS_ITEM_ARRAYLET(item) ((item & ITEM_IS_ARRAYLET) == ITEM_IS_ARRAYLET)
42
#define ITEM_TO_OBJECT(item) ((omrobjectptr_t)(((uintptr_t)item) & (~ITEM_IS_ARRAYLET)))
43
#define ITEM_TO_ARRAYLET(item) ((fomrobject_t *)(((uintptr_t)item) & (~ITEM_IS_ARRAYLET)))
44
#define ITEM_TO_UDATAP(item) ((uintptr_t *)(((uintptr_t)item) & (~ITEM_IS_ARRAYLET)))
45
#define OBJECT_TO_ITEM(obj) ((uintptr_t) obj)
46
#define ARRAYLET_TO_ITEM(arraylet) (((uintptr_t) arraylet) | ITEM_IS_ARRAYLET)
47
48
#define REFERENCE_OBJECT_YIELD_CHECK_INTERVAL 200
49
#define UNFINALIZED_OBJECT_YIELD_CHECK_INTERVAL 70
50
#define OWNABLE_SYNCHRONIZER_OBJECT_YIELD_CHECK_INTERVAL 70
51
52
class MM_RealtimeMarkingScheme : public MM_SegregatedMarkingScheme
53
{
54
/*
55
* Data members
56
*/
57
public:
58
protected:
59
private:
60
MM_RealtimeGC *_realtimeGC; /**< The GC that this markingScheme is associated*/
61
MM_Scheduler *_scheduler;
62
63
/*
64
* Function members
65
*/
66
public:
67
static MM_RealtimeMarkingScheme *newInstance(MM_EnvironmentBase *env, MM_RealtimeGC *realtimeGC);
68
void kill(MM_EnvironmentBase *env);
69
70
void markLiveObjectsInit(MM_EnvironmentBase *env, bool initMarkMap);
71
void markLiveObjectsRoots(MM_EnvironmentBase *env);
72
void markLiveObjectsScan(MM_EnvironmentBase *env);
73
void markLiveObjectsComplete(MM_EnvironmentBase *env);
74
75
MMINLINE bool isScanned(omrobjectptr_t objectPtr)
76
{
77
return isMarked((omrobjectptr_t)((1 << J9VMGC_SIZECLASSES_LOG_SMALLEST) + (uintptr_t)objectPtr));
78
}
79
80
MMINLINE void unmark(omrobjectptr_t objPtr)
81
{
82
_markMap->clearBit(objPtr);
83
}
84
85
MMINLINE void mark(omrobjectptr_t objectPtr)
86
{
87
_markMap->setBit(objectPtr);
88
}
89
90
MMINLINE void markAtomic(omrobjectptr_t objectPtr)
91
{
92
_markMap->atomicSetBit(objectPtr);
93
}
94
95
MMINLINE void setScanAtomic(omrobjectptr_t objectPtr)
96
{
97
_markMap->atomicSetBit((omrobjectptr_t)((1 << J9VMGC_SIZECLASSES_LOG_SMALLEST) + (uintptr_t)objectPtr));
98
}
99
100
MMINLINE bool
101
markObject(MM_EnvironmentRealtime *env, omrobjectptr_t objectPtr, bool leafType = false)
102
{
103
if (objectPtr == NULL) {
104
return false;
105
}
106
107
if (isMarked(objectPtr)) {
108
return false;
109
}
110
111
if (!_markMap->atomicSetBit(objectPtr)) {
112
return false;
113
}
114
if (!leafType) {
115
env->getWorkStack()->push(env, (void *)OBJECT_TO_ITEM(objectPtr));
116
}
117
118
return true;
119
}
120
121
bool incrementalCompleteScan(MM_EnvironmentRealtime *env, uintptr_t maxCount);
122
123
/**
124
* Create a MM_RealtimeMarkingScheme object
125
*/
126
MM_RealtimeMarkingScheme(MM_EnvironmentBase *env, MM_RealtimeGC *realtimeGC)
127
: MM_SegregatedMarkingScheme(env)
128
, _realtimeGC(realtimeGC)
129
, _scheduler(NULL)
130
{
131
_typeId = __FUNCTION__;
132
}
133
protected:
134
virtual bool initialize(MM_EnvironmentBase *env);
135
virtual void tearDown(MM_EnvironmentBase *env);
136
137
/*
138
* Friends
139
*/
140
friend class MM_MetronomeDelegate;
141
};
142
143
#endif /* REALTIMEMARKINGSCHEME_HPP_ */
144
145