Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_structs/ClassIteratorDeclarationOrder.hpp
5985 views
1
2
/*******************************************************************************
3
* Copyright (c) 1991, 2014 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(CLASSITERATORDECLARATIONORDER_HPP_)
30
#define CLASSITERATORDECLARATIONORDER_HPP_
31
32
#include "j9.h"
33
#include "j9cfg.h"
34
#include "modron.h"
35
#include "j9modron.h"
36
37
#include "ClassIterator.hpp"
38
#include "ClassStaticsDeclarationOrderIterator.hpp"
39
#include "GCExtensionsBase.hpp"
40
41
/**
42
* Iterate through <i>all</i> slots in the class which contain an object reference
43
* in the order declared in the class where applicable.
44
*
45
* @see GC_ClassIterator
46
* @ingroup GC_Structs
47
*/
48
class GC_ClassIteratorDeclarationOrder : public GC_ClassIterator
49
{
50
protected:
51
GC_ClassStaticsDeclarationOrderIterator _classStaticsDeclarationOrderIterator;
52
53
public:
54
55
GC_ClassIteratorDeclarationOrder(J9JavaVM *jvm, J9Class *clazz, bool shouldPreindexInterfaceFields)
56
: GC_ClassIterator(MM_GCExtensionsBase::getExtensions(jvm->omrVM), clazz)
57
, _classStaticsDeclarationOrderIterator(jvm, clazz, shouldPreindexInterfaceFields)
58
{};
59
60
61
/**
62
* Gets the current index corresponding to the current state.
63
* @return current index of the current state where appropriate.
64
* @return -1 if the current state is not indexed.
65
*/
66
MMINLINE IDATA getIndex()
67
{
68
switch (getState()) {
69
case classiterator_state_statics:
70
return _classStaticsDeclarationOrderIterator.getIndex();
71
72
case classiterator_state_constant_pool:
73
return _constantPoolObjectSlotIterator.getIndex();
74
75
case classiterator_state_slots:
76
return (IDATA)_scanIndex;
77
78
case classiterator_state_callsites:
79
return _callSitesIterator.getIndex();
80
81
default:
82
return -1;
83
}
84
}
85
86
/**
87
* Gets the reference type of the slot referred to for the current state
88
* @return
89
*/
90
MMINLINE IDATA getSlotReferenceType()
91
{
92
IDATA refType = J9GC_REFERENCE_TYPE_UNKNOWN;
93
94
switch (getState()) {
95
case classiterator_state_statics:
96
refType = J9GC_REFERENCE_TYPE_STATIC;
97
break;
98
case classiterator_state_constant_pool:
99
refType = J9GC_REFERENCE_TYPE_CONSTANT_POOL;
100
break;
101
case classiterator_state_slots:
102
{
103
/* NOTE: asking for index after nextSlot, so 1 larger than actual index in offset array */
104
switch (_scanIndex) {
105
case 1:
106
refType = J9GC_REFERENCE_TYPE_PROTECTION_DOMAIN;
107
break;
108
case 2:
109
refType = J9GC_REFERENCE_TYPE_CLASS_NAME_STRING;
110
break;
111
default:
112
refType = J9GC_REFERENCE_TYPE_UNKNOWN;
113
break;
114
}
115
}
116
break;
117
case classiterator_state_callsites:
118
refType = J9GC_REFERENCE_TYPE_CALL_SITE;
119
break;
120
default:
121
refType = J9GC_REFERENCE_TYPE_UNKNOWN;
122
break;
123
}
124
return refType;
125
}
126
127
virtual volatile j9object_t *nextSlot();
128
};
129
130
#endif /* CLASSITERATORDECLARATIONORDER_HPP_ */
131
132
133