Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_structs/ClassStaticsDeclarationOrderIterator.hpp
5985 views
1
/*******************************************************************************
2
* Copyright (c) 1991, 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_Structs
26
*/
27
28
#if !defined(CLASSSTATICSDECLARATIONORDERITERATOR_HPP_)
29
#define CLASSSTATICSDECLARATIONORDERITERATOR_HPP_
30
31
#include "j9.h"
32
#include "j9cfg.h"
33
#include "modron.h"
34
#include "locknursery.h"
35
36
#include "GCExtensions.hpp"
37
38
/**
39
* Iterate over all static slots in a class which contain an object reference.
40
* @note This iterator relies on a VM iterator which is not out of process safe, and consequently
41
* it is also not out of process safe.
42
* @ingroup GC_Structs
43
*/
44
class GC_ClassStaticsDeclarationOrderIterator
45
{
46
J9ROMFullTraversalFieldOffsetWalkState _walkState;
47
J9ROMFieldShape *_fieldShape;
48
J9JavaVM *_javaVM;
49
J9Class *_clazz;
50
IDATA _index;
51
52
public:
53
GC_ClassStaticsDeclarationOrderIterator(J9JavaVM *jvm, J9Class *clazz, bool shouldPreindexInterfaceFields)
54
: _javaVM(jvm)
55
, _clazz(clazz)
56
, _index(-1)
57
{
58
U_32 flags = J9VM_FIELD_OFFSET_WALK_INCLUDE_STATIC | J9VM_FIELD_OFFSET_WALK_ONLY_OBJECT_SLOTS;
59
if (shouldPreindexInterfaceFields) {
60
flags |= J9VM_FIELD_OFFSET_WALK_PREINDEX_INTERFACE_FIELDS;
61
}
62
63
_fieldShape = _javaVM->internalVMFunctions->fullTraversalFieldOffsetsStartDo(_javaVM, _clazz, &_walkState, flags);
64
};
65
66
j9object_t *nextSlot();
67
68
/**
69
* Gets the current static slot index.
70
* The current static slot index is based of the last static slot index of the superclass.
71
* @return static slot index of the entry returned by the last call of nextSlot.
72
* @return -1 if nextSlot has yet to be called.
73
*/
74
MMINLINE IDATA getIndex() {
75
return _index;
76
}
77
};
78
79
#endif /* CLASSSTATICSDECLARATIONORDERITERATOR_HPP_ */
80
81
82