Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_glue_java/CompactSchemeFixupRoots.hpp
5985 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
#ifndef FIXUPROOTS_HPP_
25
#define FIXUPROOTS_HPP_
26
27
#include "CollectorLanguageInterfaceImpl.hpp"
28
#include "CompactScheme.hpp"
29
#include "CompactSchemeFixupObject.hpp"
30
#include "EnvironmentStandard.hpp"
31
#include "ParallelDispatcher.hpp"
32
#include "RootScanner.hpp"
33
34
class MM_CompactSchemeFixupRoots : public MM_RootScanner {
35
private:
36
MM_CompactScheme* _compactScheme;
37
38
public:
39
MM_CompactSchemeFixupRoots(MM_EnvironmentBase *env, MM_CompactScheme* compactScheme) :
40
MM_RootScanner(env),
41
_compactScheme(compactScheme)
42
{
43
setIncludeStackFrameClassReferences(false);
44
}
45
46
virtual void doSlot(omrobjectptr_t* slot)
47
{
48
*slot = _compactScheme->getForwardingPtr(*slot);
49
}
50
51
virtual void doClass(J9Class *clazz)
52
{
53
/* We MUST NOT store the forwarded class object back into the clazz since forwarding can
54
* only happen once and will be taken care of by the code below. ie: the classObject slot
55
* is part of the GC_ClassIterator.
56
*/
57
GC_ClassIterator classIterator(_env, clazz);
58
while (volatile omrobjectptr_t *slot = classIterator.nextSlot()) {
59
/* discard volatile since we must be in stop-the-world mode */
60
doSlot((omrobjectptr_t*)slot);
61
}
62
}
63
64
virtual void doClassLoader(J9ClassLoader *classLoader)
65
{
66
if (J9_GC_CLASS_LOADER_DEAD != (classLoader->gcFlags & J9_GC_CLASS_LOADER_DEAD)) {
67
doSlot(&classLoader->classLoaderObject);
68
scanModularityObjects(classLoader);
69
}
70
}
71
72
#if defined(J9VM_GC_FINALIZATION)
73
virtual void scanUnfinalizedObjects(MM_EnvironmentBase *env) {
74
/* allow the compact scheme to handle this */
75
reportScanningStarted(RootScannerEntity_UnfinalizedObjects);
76
MM_CompactSchemeFixupObject fixupObject(env, _compactScheme);
77
fixupUnfinalizedObjects(env);
78
reportScanningEnded(RootScannerEntity_UnfinalizedObjects);
79
}
80
#endif
81
82
#if defined(J9VM_GC_FINALIZATION)
83
virtual void doFinalizableObject(omrobjectptr_t object) {
84
Assert_MM_unreachable();
85
}
86
87
virtual void scanFinalizableObjects(MM_EnvironmentBase *env) {
88
if (_singleThread || J9MODRON_HANDLE_NEXT_WORK_UNIT(env)) {
89
reportScanningStarted(RootScannerEntity_FinalizableObjects);
90
MM_CompactSchemeFixupObject fixupObject(env, _compactScheme);
91
fixupFinalizableObjects(env);
92
reportScanningEnded(RootScannerEntity_FinalizableObjects);
93
}
94
}
95
#endif /* J9VM_GC_FINALIZATION */
96
97
virtual void scanOwnableSynchronizerObjects(MM_EnvironmentBase *env) {
98
/* empty, move ownable synchronizer processing in fixupObject */
99
}
100
101
private:
102
#if defined(J9VM_GC_FINALIZATION)
103
void fixupFinalizableObjects(MM_EnvironmentBase *env);
104
void fixupUnfinalizedObjects(MM_EnvironmentBase *env);
105
#endif
106
};
107
#endif /* FIXUPROOTS_HPP_ */
108
109