Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_structs/MixedObjectDeclarationOrderIterator.hpp
5990 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(MIXEDOBJECTDECLARATIONORDERITERATOR_HPP_)
29
#define MIXEDOBJECTDECLARATIONORDERITERATOR_HPP_
30
31
#include "j9.h"
32
#include "j9cfg.h"
33
#include "modron.h"
34
#include "locknursery.h"
35
36
#include "MixedObjectModel.hpp"
37
#include "SlotObject.hpp"
38
#include "locknursery.h"
39
40
/**
41
* Iterate over all slots in a mixed object which contain an object reference.
42
* @note This iterator relies on a VM iterator which is not out of process safe, and consequently
43
* it is also not out of process safe.
44
*
45
* @ingroup GC_Structs
46
*/
47
class GC_MixedObjectDeclarationOrderIterator
48
{
49
protected:
50
J9ROMFullTraversalFieldOffsetWalkState _walkState;
51
J9ROMFieldShape *_fieldShape;
52
J9JavaVM *_javaVM;
53
J9Object *_objectPtr;
54
GC_SlotObject _slotObject;
55
IDATA _index;
56
57
public:
58
GC_MixedObjectDeclarationOrderIterator(J9JavaVM *jvm, J9Object *objectPtr, bool shouldPreindexInterfaceFields) :
59
_javaVM(jvm),
60
_objectPtr(objectPtr),
61
_slotObject(jvm->omrVM, NULL),
62
_index(-1)
63
{
64
U_32 flags = J9VM_FIELD_OFFSET_WALK_INCLUDE_INSTANCE | J9VM_FIELD_OFFSET_WALK_ONLY_OBJECT_SLOTS;
65
if (shouldPreindexInterfaceFields) {
66
flags |= J9VM_FIELD_OFFSET_WALK_PREINDEX_INTERFACE_FIELDS;
67
}
68
69
J9Class *clazz = J9GC_J9OBJECT_CLAZZ_VM(objectPtr, _javaVM);
70
_fieldShape = _javaVM->internalVMFunctions->fullTraversalFieldOffsetsStartDo(_javaVM, clazz, &_walkState, flags);
71
}
72
73
GC_SlotObject *nextSlot();
74
75
/**
76
* Gets the current slot's declaration order index.
77
* The current slot's declaration order index is based on the indices of its superclass and superinterfaces.
78
* @return slot's declaration order index of the entry returned by the last call of nextSlot.
79
* @return -1 if nextSlot has yet to be called.
80
*/
81
MMINLINE IDATA getIndex() {
82
return _index;
83
}
84
};
85
86
#endif /* MIXEDOBJECTDECLARATIONORDERITERATOR_HPP_ */
87
88
89