Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_check/CheckBase.hpp
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_Check
27
*/
28
29
#if !defined(CHECKBASE_HPP_)
30
#define CHECKBASE_HPP_
31
32
#include "j9.h"
33
#include "j9cfg.h"
34
#include "modronopt.h"
35
36
/**
37
* @name Scan options supported by gcchk
38
* @anchor scanFlags
39
* @{
40
*/
41
42
/* scan flags */
43
#define J9MODRON_GCCHK_SCAN_ALL_SLOTS ((UDATA)0xFFFFFFF)
44
#define J9MODRON_GCCHK_SCAN_OBJECT_HEAP ((UDATA)0x00000001)
45
#define J9MODRON_GCCHK_SCAN_CLASS_HEAP ((UDATA)0x00000002)
46
#define J9MODRON_GCCHK_SCAN_REMEMBERED_SET ((UDATA)0x00000004)
47
#define J9MODRON_GCCHK_SCAN_UNFINALIZED ((UDATA)0x00000008)
48
#define J9MODRON_GCCHK_SCAN_FINALIZABLE ((UDATA)0x00000010)
49
#define J9MODRON_GCCHK_SCAN_OWNABLE_SYNCHRONIZER ((UDATA)0x00000020)
50
#define J9MODRON_GCCHK_SCAN_UNUSED1 ((UDATA)0x00000040)
51
#define J9MODRON_GCCHK_SCAN_UNUSED2 ((UDATA)0x00000080)
52
#define J9MODRON_GCCHK_SCAN_STRING_TABLE ((UDATA)0x00000100)
53
#define J9MODRON_GCCHK_SCAN_CLASS_LOADERS ((UDATA)0x00000200)
54
#define J9MODRON_GCCHK_SCAN_JNI_GLOBAL_REFERENCES ((UDATA)0x00000400)
55
#define J9MODRON_GCCHK_SCAN_JNI_WEAK_GLOBAL_REFERENCES ((UDATA)0x00000800)
56
#define J9MODRON_GCCHK_SCAN_DEBUGGER_REFERENCES ((UDATA)0x00001000)
57
#define J9MODRON_GCCHK_SCAN_DEBUGGER_CLASS_REFERENCES ((UDATA)0x00002000)
58
#define J9MODRON_GCCHK_SCAN_VM_CLASS_SLOTS ((UDATA)0x00004000)
59
#define J9MODRON_GCCHK_SCAN_VMTHREADS ((UDATA)0x00008000)
60
#define J9MODRON_GCCHK_SCAN_THREADSTACKS ((UDATA)0x00010000)
61
#define J9MODRON_GCCHK_SCAN_JVMTI_OBJECT_TAG_TABLES ((UDATA)0x00020000)
62
#define J9MODRON_GCCHK_SCAN_MONITOR_TABLE ((UDATA)0x00040000)
63
#define J9MODRON_GCCHK_SCAN_SCOPES ((UDATA)0x00080000)
64
/**
65
* @}
66
*/
67
68
/**
69
* @anchor checkFlags
70
* @name Check options
71
* @{
72
*/
73
#define J9MODRON_GCCHK_VERIFY_ALL ((UDATA)0xFFFFFFFF)
74
#define J9MODRON_GCCHK_VERIFY_CLASS_SLOT ((UDATA)0x00000001)
75
76
/* Range check only makes sense if the class pointer is verified first. */
77
#define J9MODRON_GCCHK_VERIFY_RANGE ((UDATA)0x00000002)
78
#define J9MODRON_GCCHK_VERIFY_SHAPE ((UDATA)0x00000004)
79
#define J9MODRON_GCCHK_VERIFY_FLAGS ((UDATA)0x00000008)
80
/** @} */
81
82
/**
83
* @anchor miscFlags
84
* @name Misc options
85
* @{
86
*/
87
#define J9MODRON_GCCHK_VERBOSE ((UDATA)0x00000001)
88
#define J9MODRON_GCCHK_INTERVAL ((UDATA)0x00000002)
89
#define J9MODRON_GCCHK_GLOBAL_INTERVAL ((UDATA)0x00000004)
90
#define J9MODRON_GCCHK_LOCAL_INTERVAL ((UDATA)0x00000008)
91
#define J9MODRON_GCCHK_START_INDEX ((UDATA)0x00000010)
92
#define J9MODRON_GCCHK_SCAVENGER_BACKOUT ((UDATA)0x00000020)
93
#define J9MODRON_GCCHK_SUPPRESS_LOCAL ((UDATA)0x00000040)
94
#define J9MODRON_GCCHK_SUPPRESS_GLOBAL ((UDATA)0x00000080)
95
#define J9MODRON_GCCHK_REMEMBEREDSET_OVERFLOW ((UDATA)0x00000100)
96
#define J9MODRON_GCCHK_MISC_SCAN ((UDATA)0x00000200)
97
#define J9MODRON_GCCHK_MISC_CHECK ((UDATA)0x00000400)
98
#define J9MODRON_GCCHK_MISC_QUIET ((UDATA)0x00000800)
99
#define J9MODRON_GCCHK_MISC_ABORT ((UDATA)0x00001000)
100
#define J9MODRON_GCCHK_MANUAL ((UDATA)0x00002000)
101
#define J9MODRON_GCCHK_MISC_ALWAYS_DUMP_STACK ((UDATA)0x00004000)
102
#define J9MODRON_GCCHK_MISC_DARKMATTER ((UDATA)0x00008000)
103
#define J9MODRON_GCCHK_MISC_MIDSCAVENGE ((UDATA)0x00010000)
104
#define J9MODRON_GCCHK_MISC_OWNABLESYNCHRONIZER_CONSISTENCY ((UDATA)0x00020000)
105
#define J9MODRON_GCCHK_VALID_INDEXABLE_DATA_ADDRESS ((UDATA)0x00040000)
106
/** @} */
107
108
/**
109
* Return codes for iterator functions.
110
* Verification continues if an iterator function returns J9MODRON_SLOT_ITERATOR_OK,
111
* otherwise it terminates.
112
* @name Iterator return codes
113
* @{
114
*/
115
#define J9MODRON_SLOT_ITERATOR_OK ((UDATA)0x00000000) /**< Indicates success */
116
#define J9MODRON_SLOT_ITERATOR_UNRECOVERABLE_ERROR ((UDATA)0x00000001) /**< Indicates that an unrecoverable error was detected */
117
#define J9MODRON_SLOT_ITERATOR_RECOVERABLE_ERROR ((UDATA)0x00000002) /** < Indicates that a recoverable error was detected */
118
/** @} */
119
120
/**
121
* Error codes returned to the iterator methods by helper utilities.
122
* @anchor GCCheckWalkStageErrorCodes
123
* @name Error Codes
124
* @{
125
*/
126
/* Error codes applicable to all stages */
127
#define J9MODRON_GCCHK_RC_OK ((UDATA)0)
128
#define J9MODRON_GCCHK_RC_UNALIGNED ((UDATA)1)
129
#define J9MODRON_GCCHK_RC_DOUBLE_ARRAY_UNALIGNED ((UDATA)2)
130
#define J9MODRON_GCCHK_RC_NOT_IN_OBJECT_REGION ((UDATA)3)
131
#define J9MODRON_GCCHK_RC_NOT_FOUND ((UDATA)4)
132
#define J9MODRON_GCCHK_RC_INVALID_RANGE ((UDATA)5)
133
#define J9MODRON_GCCHK_RC_STACK_OBJECT ((UDATA) 6)
134
#define J9MODRON_GCCHK_RC_DEAD_OBJECT ((UDATA) 25)
135
#define J9MODRON_GCCHK_RC_J9CLASS_HEADER_INVALID ((UDATA) 26)
136
#define J9MODRON_GCCHK_RC_OBJECT_SLOT_POINTS_TO_J9CLASS ((UDATA) 41)
137
138
/* Special error codes for when J9MODRON_GCCHK_VERIFY_CLASS_SLOT is set (all stages)*/
139
#define J9MODRON_GCCHK_RC_NULL_CLASS_POINTER ((UDATA)7)
140
#define J9MODRON_GCCHK_RC_CLASS_POINTER_UNALIGNED ((UDATA)8)
141
#define J9MODRON_GCCHK_RC_CLASS_NOT_FOUND ((UDATA)9)
142
#define J9MODRON_GCCHK_RC_CLASS_INVALID_RANGE ((UDATA)10)
143
#define J9MODRON_GCCHK_RC_CLASS_POINTER_NOT_JLCLASS ((UDATA)11)
144
#define J9MODRON_GCCHK_RC_CLASS_STACK_OBJECT ((UDATA) 12)
145
#define J9MODRON_GCCHK_RC_CLASS_OBJECT_NOT_JLCLASS ((UDATA) 27)
146
#define J9MODRON_GCCHK_RC_CLASS_IS_UNDEAD ((UDATA) 29)
147
#define J9MODRON_GCCHK_RC_CLASS_STATICS_FIELD_POINTS_WRONG_OBJECT ((UDATA) 30)
148
#define J9MODRON_GCCHK_RC_CLASS_HOT_SWAPPED_POINTS_TO_STATICS ((UDATA) 31)
149
#define J9MODRON_GCCHK_RC_CLASS_STATICS_REFERENCE_IS_NOT_IN_SCANNING_RANGE ((UDATA) 32)
150
#define J9MODRON_GCCHK_RC_CLASS_STATICS_WRONG_NUMBER_OF_REFERENCES ((UDATA) 33)
151
/* obsolete code 35 */
152
/* obsolete code 36 */
153
/* obsolete code 37 */
154
#define J9MODRON_GCCHK_RC_CLASS_HOT_SWAPPED_FOR_ARRAY ((UDATA) 39)
155
#define J9MODRON_GCCHK_RC_REPLACED_CLASS_HAS_NO_HOTSWAP_FLAG ((UDATA) 40)
156
#define J9MODRON_GCCHK_RC_CLASS_IS_UNLOADED ((UDATA) 48)
157
158
/* Special error codes for indexable data address field dataAddr checks */
159
#define J9MODRON_GCCHK_RC_INVALID_INDEXABLE_DATA_ADDRESS ((UDATA) 34)
160
161
/* Special error codes for when J9MODRON_GCCHK_VERIFY_FLAGS is set (all stages)*/
162
#define J9MODRON_GCCHK_RC_INVALID_FLAGS ((UDATA)13)
163
#define J9MODRON_GCCHK_RC_OLD_SEGMENT_INVALID_FLAGS ((UDATA)14)
164
#define J9MODRON_GCCHK_RC_NEW_SEGMENT_INVALID_FLAGS ((UDATA)15)
165
166
/* Error codes applicable only to stage_object_heap */
167
#define J9MODRON_GCCHK_RC_DEAD_OBJECT_SIZE ((UDATA)16)
168
#define J9MODRON_GCCHK_RC_NEW_POINTER_NOT_REMEMBERED ((UDATA)17)
169
#define J9MODRON_GCCHK_RC_DEAD_OBJECT_SIZE_NOT_ALIGNED ((UDATA)44)
170
#define J9MODRON_GCCHK_RC_DEAD_OBJECT_NEXT_IS_NOT_HOLE ((UDATA)45)
171
#define J9MODRON_GCCHK_RC_DEAD_OBJECT_NEXT_IS_NOT_IN_REGION ((UDATA)46)
172
#define J9MODRON_GCCHK_RC_DEAD_OBJECT_NEXT_IS_POINTED_INSIDE ((UDATA)47)
173
174
/* Error codes applicable only to stage_remembered_set */
175
#define J9MODRON_GCCHK_RC_REMEMBERED_SET_WRONG_SEGMENT ((UDATA)18)
176
#define J9MODRON_GCCHK_RC_REMEMBERED_SET_FLAGS ((UDATA)19)
177
#define J9MODRON_GCCHK_RC_REMEMBERED_SET_OLD_OBJECT ((UDATA)20)
178
179
/* Deprecated error codes applicable to puddle flags */
180
#define J9MODRON_GCCHK_RC_UNUSED_21 ((UDATA)21)
181
#define J9MODRON_GCCHK_RC_UNUSED_22 ((UDATA)22)
182
183
/* Error codes applicable for card-marking remembered set */
184
#define J9MODRON_GCCHK_RC_HEAP_OBJECT_REMEMBERED ((UDATA)23)
185
#define J9MODRON_GCCHK_RC_NEW_POINTER_NOT_REMEMBERED_IN_CARD_TABLE ((UDATA)24)
186
187
/* Error codes applicable for scopes */
188
#define J9MODRON_GCCHK_RC_INTERNAL_POINTER_NOT_IN_SCOPE ((UDATA)28)
189
190
/* Error codes for instances of java.util.concurrent.locks.AbstractOwnableSynchronizer */
191
#define J9MODRON_GCCHK_RC_OWNABLE_SYNCHRONIZER_INVALID_CLASS ((UDATA)38)
192
#define J9MODRON_GCCHK_OWNABLE_SYNCHRONIZER_OBJECT_IS_NOT_ATTACHED_TO_THE_LIST ((UDATA)42)
193
#define J9MODRON_GCCHK_OWNABLE_SYNCHRONIZER_LIST_HAS_CIRCULAR_REFERENCE ((UDATA)43)
194
195
/** @} Error codes */
196
197
/**
198
* What stage of GC invoked the check.
199
* @note If you add to this enum, you MUST add a corresponding entry in invokedByStrings[]
200
*/
201
typedef enum {
202
invocation_unknown, /**< Invocation unknown */
203
invocation_global_start, /**< The check was invoked at the start of a global GC */
204
invocation_global_end, /**< The check was invoked at the end of a global GC */
205
invocation_global_sweep_start, /**< The action was invoked at the start of the sweep phase of a global GC */
206
invocation_global_sweep_end, /**< The action was invoked at the end of the sweep phase of a global GC */
207
invocation_local_start, /**< The check was invoked at the start of a local GC */
208
invocation_local_end, /**< The check was invoked at the end of a local GC */
209
invocation_scavenger_backout, /**< The check was invoked after a scavenger (local GC) backout operation */
210
invocation_rememberedset_overflow, /**< The check was invoked when remembered set overflow was detected */
211
invocation_manual, /**< The check was manually invoked using J9HOOK_INVOKE_GC_CHECK (see @ref hookInvokeGCCheck) */
212
invocation_debugger /**< The check was triggered from the debugger extensions (windbg or gcc) */
213
} GCCheckInvokedBy;
214
215
/**
216
* Extensions used by GCCheck hooks.
217
*/
218
typedef struct GCCHK_Extensions {
219
void *checkEngine; /**< The check engine */
220
void *checkCycle; /**< The command-line check cycle */
221
UDATA gcInterval;
222
UDATA globalGcInterval;
223
UDATA globalGcCount;
224
UDATA gcStartIndex;
225
#if defined(J9VM_GC_MODRON_SCAVENGER)
226
UDATA localGcInterval;
227
UDATA localGcCount;
228
#endif /* J9VM_GC_MODRON_SCAVENGER */
229
} GCCHK_Extensions;
230
#endif /* CHECKBASE_HPP_ */
231
232
233