Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_structs/ConstantPoolObjectSlotIterator.cpp
5985 views
1
2
/*******************************************************************************
3
* Copyright (c) 1991, 2019 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
#include "j9cp.h"
32
#include "ModronAssertions.h"
33
34
#include "ConstantPoolObjectSlotIterator.hpp"
35
36
37
/**
38
* @return the next object slot in the constant pool
39
* @return NULL if there are no more object references
40
*/
41
j9object_t *
42
GC_ConstantPoolObjectSlotIterator::nextSlot() {
43
U_32 slotType;
44
j9object_t *slotPtr;
45
j9object_t *result = NULL;
46
47
while (_cpEntryCount) {
48
if (0 == _cpDescriptionIndex) {
49
_cpDescription = *_cpDescriptionSlots;
50
_cpDescriptionSlots += 1;
51
_cpDescriptionIndex = J9_CP_DESCRIPTIONS_PER_U32;
52
}
53
54
slotType = _cpDescription & J9_CP_DESCRIPTION_MASK;
55
slotPtr = _cpEntry;
56
57
/* Determine if the slot should be processed */
58
switch (slotType) {
59
case J9CPTYPE_STRING: /* fall through */
60
case J9CPTYPE_ANNOTATION_UTF8:
61
result = &(((J9RAMStringRef *) slotPtr)->stringObject);
62
break;
63
case J9CPTYPE_METHOD_TYPE:
64
result = &(((J9RAMMethodTypeRef *) slotPtr)->type);
65
break;
66
case J9CPTYPE_METHODHANDLE:
67
result = &(((J9RAMMethodHandleRef *) slotPtr)->methodHandle);
68
break;
69
case J9CPTYPE_CONSTANT_DYNAMIC:
70
if (NULL != (result = _constantDynamicSlotIterator.nextSlot(slotPtr))) {
71
/* Do not progress through the function.
72
* Avoids advancing the slot while a constant dynamic is being iterated */
73
return result;
74
}
75
break;
76
default:
77
break;
78
}
79
80
/* Adjust the CP slot and description information */
81
_cpEntry = (j9object_t *) (((U_8 *) _cpEntry)
82
+ sizeof(J9RAMConstantPoolItem));
83
_cpEntryCount -= 1;
84
85
_cpDescription >>= J9_CP_BITS_PER_DESCRIPTION;
86
_cpDescriptionIndex -= 1;
87
88
if (NULL != result) {
89
break;
90
}
91
92
}
93
return result;
94
}
95
96
97