Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_stats/ScanClassesMode.hpp
5986 views
1
2
/*******************************************************************************
3
* Copyright (c) 1991, 2017 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
25
#if !defined(SCANCLASSESMODE_HPP_)
26
#define SCANCLASSESMODE_HPP_
27
28
#include "j9cfg.h"
29
#include "j9comp.h"
30
#include "omrgcconsts.h"
31
#include "AtomicOperations.hpp"
32
33
#if defined(J9VM_GC_DYNAMIC_CLASS_UNLOADING)
34
35
/**
36
* Concurrent status symbols extending ConcurrentKickoffReason enumeration.
37
* Explain why kickoff triggered by Java.
38
*/
39
enum {
40
FORCED_UNLOADING_CLASSES = (uintptr_t)((uintptr_t)NO_LANGUAGE_KICKOFF_REASON + 1)
41
};
42
43
/**
44
* @todo Provide class documentation
45
* @ingroup GC_Base_Core
46
*/
47
class MM_ScanClassesMode : public MM_Base
48
{
49
private:
50
volatile uintptr_t _scanClassesMode;
51
52
public:
53
typedef enum {
54
SCAN_CLASSES_NEED_TO_BE_EXECUTED = 1,
55
SCAN_CLASSES_CURRENTLY_ACTIVE,
56
SCAN_CLASSES_COMPLETE,
57
SCAN_CLASSES_DISABLED
58
} ScanClassesMode;
59
60
public:
61
MMINLINE ScanClassesMode getScanClassesMode() { return (ScanClassesMode)_scanClassesMode; }
62
63
MMINLINE bool
64
switchScanClassesMode(ScanClassesMode oldMode, ScanClassesMode newMode)
65
{
66
uintptr_t result = MM_AtomicOperations::lockCompareExchange(&_scanClassesMode, (uintptr_t)oldMode, (uintptr_t)newMode);
67
return result == (uintptr_t)oldMode;
68
}
69
70
MMINLINE void
71
setScanClassesMode(ScanClassesMode mode)
72
{
73
MM_AtomicOperations::set((uintptr_t *)&_scanClassesMode, (uintptr_t)mode);
74
}
75
76
MMINLINE bool
77
isPendingOrActiveMode()
78
{
79
uintptr_t mode = _scanClassesMode;
80
return (mode == SCAN_CLASSES_NEED_TO_BE_EXECUTED) || (mode == SCAN_CLASSES_CURRENTLY_ACTIVE);
81
}
82
83
MMINLINE const char *
84
getScanClassesModeAsString()
85
{
86
switch (getScanClassesMode()) {
87
case SCAN_CLASSES_NEED_TO_BE_EXECUTED:
88
return "pending";
89
90
case SCAN_CLASSES_CURRENTLY_ACTIVE:
91
return "active";
92
93
case SCAN_CLASSES_COMPLETE:
94
return "complete";
95
96
case SCAN_CLASSES_DISABLED:
97
return "disabled";
98
99
default:
100
return "unknown";
101
}
102
}
103
104
/**
105
* Create a ScanClassesMode object.
106
*/
107
MM_ScanClassesMode() :
108
MM_Base(),
109
_scanClassesMode((uintptr_t)SCAN_CLASSES_DISABLED)
110
{}
111
112
};
113
114
#endif /* J9VM_GC_DYNAMIC_CLASS_UNLOADING */
115
116
#endif /* SCANCLASSESMODE_HPP_ */
117
118