Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_structs/ClassIteratorClassSlots.hpp
5985 views
1
2
/*******************************************************************************
3
* Copyright (c) 1991, 2021 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
* @file
26
* @ingroup GC_Structs
27
*/
28
29
#if !defined(CLASSITERATORCLASSSLOTS_HPP_)
30
#define CLASSITERATORCLASSSLOTS_HPP_
31
32
#include "j9.h"
33
#include "j9cfg.h"
34
#include "modron.h"
35
36
#include "ConstantPoolClassSlotIterator.hpp"
37
#include "ClassSuperclassesIterator.hpp"
38
#include "ClassLocalInterfaceIterator.hpp"
39
#include "ClassArrayClassSlotIterator.hpp"
40
#include "ClassFCCSlotIterator.hpp"
41
#include "ClassModel.hpp"
42
43
/**
44
* State constants representing the current stage of the iteration process
45
* @anchor ClassIteratorClassSlotsState
46
*/
47
enum {
48
classiteratorclassslots_state_start = 0,
49
classiteratorclassslots_state_constant_pool,
50
classiteratorclassslots_state_superclasses,
51
classiteratorclassslots_state_interfaces,
52
classiteratorclassslots_state_array_class_slots,
53
classiteratorclassslots_state_flattened_class_cache_slots,
54
classiteratorclassslots_state_end
55
};
56
57
58
/**
59
* Iterate through slots in the class which contain a class reference (as compared to
60
* GC_ClassIterator, which iterates over object references).
61
*
62
* @see GC_ClassIterator
63
* @ingroup GC_Structs
64
*/
65
class GC_ClassIteratorClassSlots
66
{
67
protected:
68
const bool _shouldScanInterfaces;
69
J9Class *_clazzPtr;
70
int _state;
71
72
GC_ConstantPoolClassSlotIterator _constantPoolClassSlotIterator;
73
GC_ClassSuperclassesIterator _classSuperclassesIterator;
74
GC_ClassLocalInterfaceIterator _classLocalInterfaceIterator;
75
GC_ClassArrayClassSlotIterator _classArrayClassSlotIterator;
76
GC_ClassFCCSlotIterator _classFCCSlotIterator;
77
78
public:
79
80
GC_ClassIteratorClassSlots(J9JavaVM *vm, J9Class *clazz) :
81
_shouldScanInterfaces(!GC_ClassModel::usesSharedITable(vm, clazz)),
82
_clazzPtr(clazz),
83
_state(classiteratorclassslots_state_start),
84
_constantPoolClassSlotIterator(clazz),
85
_classSuperclassesIterator(clazz),
86
_classLocalInterfaceIterator(clazz),
87
_classArrayClassSlotIterator(clazz),
88
_classFCCSlotIterator(clazz)
89
{}
90
91
/**
92
* @return @ref ClassIteratorClassSlotsState representing the current state (stage
93
* of the iteration process)
94
*/
95
MMINLINE int getState()
96
{
97
return _state;
98
};
99
100
/**
101
* Gets the current index corresponding to the current state.
102
* @return current index of the current state where appropriate.
103
* @return -1 if the current state is not indexed.
104
*/
105
MMINLINE IDATA getIndex()
106
{
107
switch (getState()) {
108
case classiteratorclassslots_state_constant_pool:
109
return _constantPoolClassSlotIterator.getIndex();
110
111
case classiteratorclassslots_state_superclasses:
112
return _classSuperclassesIterator.getIndex();
113
114
case classiteratorclassslots_state_array_class_slots:
115
return _classArrayClassSlotIterator.getIndex();
116
117
case classiteratorclassslots_state_flattened_class_cache_slots:
118
return _classFCCSlotIterator.getIndex();
119
120
case classiteratorclassslots_state_interfaces:
121
default:
122
return -1;
123
}
124
}
125
126
J9Class *nextSlot();
127
128
};
129
130
#endif /* CLASSITERATORCLASSSLOTS_HPP_ */
131
132
133