Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_realtime/RealtimeMarkingSchemeRootMarker.hpp
5986 views
1
/*******************************************************************************
2
* Copyright (c) 2019, 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
/**
24
* @file
25
* @ingroup GC_Metronome
26
*/
27
28
#if !defined(REALTIMEROOTMARKER_HPP_)
29
#define REALTIMEROOTMARKER_HPP_
30
31
#include "j9.h"
32
#include "j9cfg.h"
33
#include "modronopt.h"
34
35
#include "EnvironmentRealtime.hpp"
36
#include "ObjectAllocationInterface.hpp"
37
#include "RealtimeRootScanner.hpp"
38
#include "RealtimeGC.hpp"
39
#include "RealtimeMarkingScheme.hpp"
40
#include "StackSlotValidator.hpp"
41
42
/**
43
* This scanner will mark objects that pass through its doSlot.
44
*/
45
class MM_RealtimeMarkingSchemeRootMarker : public MM_RealtimeRootScanner
46
{
47
/* Data members / types */
48
public:
49
protected:
50
private:
51
52
/* Methods */
53
public:
54
55
/**
56
* Simple chained constructor.
57
*/
58
MM_RealtimeMarkingSchemeRootMarker(MM_EnvironmentRealtime *env, MM_RealtimeGC *realtimeGC) :
59
MM_RealtimeRootScanner(env, realtimeGC)
60
{
61
_typeId = __FUNCTION__;
62
}
63
64
/**
65
* This scanner can be instantiated so we must give it a name.
66
*/
67
virtual const char*
68
scannerName()
69
{
70
return "Mark";
71
}
72
73
/**
74
* Wraps the scanning of one thread to only happen if it hasn't already occured in this phase of this GC,
75
* also sets the thread up for the upcoming forwarding phase.
76
* @return true if the thread was scanned (the caller should offer to yield), false otherwise.
77
* @see MM_RootScanner::scanOneThread()
78
*/
79
virtual void
80
scanOneThreadImpl(MM_EnvironmentRealtime *env, J9VMThread* walkThread, void* localData)
81
{
82
MM_EnvironmentRealtime* walkThreadEnv = MM_EnvironmentRealtime::getEnvironment(walkThread->omrVMThread);
83
/* Scan the thread by invoking superclass */
84
MM_RootScanner::scanOneThread(env, walkThread, localData);
85
86
/*
87
* TODO CRGTMP we should be able to premark the cache instead of flushing the cache
88
* but this causes problems in overflow. When we have some time we should look into
89
* this again.
90
*/
91
/*((MM_SegregatedAllocationInterface *)walkThreadEnv->_objectAllocationInterface)->preMarkCache(walkThreadEnv);*/
92
walkThreadEnv->_objectAllocationInterface->flushCache(walkThreadEnv);
93
/* Disable the double barrier on the scanned thread. */
94
_realtimeGC->disableDoubleBarrierOnThread(env, walkThread->omrVMThread);
95
}
96
97
#if defined(J9VM_GC_FINALIZATION)
98
virtual void doFinalizableObject(j9object_t object) {
99
_markingScheme->markObject(_env, object);
100
}
101
#endif /* J9VM_GC_FINALIZATION */
102
103
/**
104
* Simply pass the call on to the RealtimeGC.
105
* @see MM_Metronome::markObject()
106
*/
107
virtual void
108
doSlot(J9Object** slot)
109
{
110
_markingScheme->markObject(_env, *slot);
111
}
112
113
virtual void
114
doStackSlot(J9Object **slotPtr, void *walkState, const void* stackLocation)
115
{
116
J9Object *object = *slotPtr;
117
if (_markingScheme->isHeapObject(object)) {
118
/* heap object - validate and mark */
119
Assert_MM_validStackSlot(MM_StackSlotValidator(0, object, stackLocation, walkState).validate(_env));
120
_markingScheme->markObject(_env, object);
121
} else if (NULL != object) {
122
/* stack object - just validate */
123
Assert_MM_validStackSlot(MM_StackSlotValidator(MM_StackSlotValidator::NOT_ON_HEAP, object, stackLocation, walkState).validate(_env));
124
}
125
}
126
127
virtual void
128
doVMThreadSlot(J9Object **slotPtr, GC_VMThreadIterator *vmThreadIterator) {
129
J9Object *object = *slotPtr;
130
if (_markingScheme->isHeapObject(object)) {
131
_markingScheme->markObject(_env, object);
132
} else if (NULL != object) {
133
Assert_MM_true(vmthreaditerator_state_monitor_records == vmThreadIterator->getState());
134
}
135
}
136
137
/**
138
* Scans non-collectable internal objects (immortal) and classes
139
*/
140
virtual void
141
scanIncrementalRoots(MM_EnvironmentRealtime *env)
142
{
143
#if defined(J9VM_GC_DYNAMIC_CLASS_UNLOADING)
144
if (_classDataAsRoots) {
145
#endif /* J9VM_GC_DYNAMIC_CLASS_UNLOADING */
146
scanClasses(env);
147
#if defined(J9VM_GC_DYNAMIC_CLASS_UNLOADING)
148
} else {
149
scanPermanentClasses(env);
150
}
151
#endif /* J9VM_GC_DYNAMIC_CLASS_UNLOADING */
152
153
CompletePhaseCode status = scanClassesComplete(env);
154
155
if (complete_phase_ABORT == status) {
156
return ;
157
}
158
}
159
protected:
160
private:
161
};
162
163
#endif /* REALTIMEROOTMARKER_HPP_ */
164
165
166