Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_structs/ClassIterator.cpp
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
#include "j9.h"
30
#include "j9cfg.h"
31
32
#include "ClassIterator.hpp"
33
34
/**
35
* Offsets of the slots in J9Class that contain object references.
36
* NOTE: This can probably be simplified since we shouldn't be adding any more object
37
* references to the J9Class struct
38
*/
39
static const UDATA slotOffsets[] =
40
{
41
offsetof(J9Class, classObject),
42
0
43
};
44
45
/**
46
* @return the next slot in the class containing an object reference
47
* @return NULL if there are no more such slots
48
*/
49
volatile j9object_t *
50
GC_ClassIterator::nextSlot()
51
{
52
volatile j9object_t *slotPtr;
53
54
switch(_state) {
55
case classiterator_state_start:
56
_state += 1;
57
58
case classiterator_state_statics:
59
slotPtr = _classStaticsIterator.nextSlot();
60
if (NULL != slotPtr) {
61
return slotPtr;
62
}
63
_state += 1;
64
65
case classiterator_state_constant_pool:
66
slotPtr = _constantPoolObjectSlotIterator.nextSlot();
67
if (NULL != slotPtr) {
68
return slotPtr;
69
}
70
_state += 1;
71
72
case classiterator_state_slots:
73
while (slotOffsets[_scanIndex] != 0) {
74
/* shouldScanClassObject is true by default, in the case of balanced GC check if object is ClassObject */
75
if (_shouldScanClassObject || (slotOffsets[_scanIndex] != offsetof(J9Class, classObject))) {
76
return (j9object_t *)((U_8 *)_clazzPtr + (UDATA)slotOffsets[_scanIndex++]);
77
} else {
78
_scanIndex += 1;
79
}
80
}
81
_state += 1;
82
83
case classiterator_state_callsites:
84
slotPtr = _callSitesIterator.nextSlot();
85
if (NULL != slotPtr) {
86
return slotPtr;
87
}
88
_state += 1;
89
90
case classiterator_state_methodtypes:
91
slotPtr = _methodTypesIterator.nextSlot();
92
if (NULL != slotPtr) {
93
return slotPtr;
94
}
95
_state += 1;
96
97
#if defined(J9VM_OPT_METHOD_HANDLE)
98
case classiterator_state_varhandlemethodtypes:
99
slotPtr = _varHandlesMethodTypesIterator.nextSlot();
100
if (NULL != slotPtr) {
101
return slotPtr;
102
}
103
_state += 1;
104
#endif /* defined(J9VM_OPT_METHOD_HANDLE) */
105
106
case classiterator_state_valuetypes:
107
slotPtr = _valueTypesIterator.nextSlot();
108
if (NULL != slotPtr) {
109
return slotPtr;
110
}
111
_state += 1;
112
113
default:
114
break;
115
}
116
117
return NULL;
118
}
119
120
121