Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_check/CheckError.hpp
5985 views
1
2
/*******************************************************************************
3
* Copyright (c) 1991, 2014 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(CHECKERROR_HPP_)
30
#define CHECKERROR_HPP_
31
32
#include "j9.h"
33
#include "j9cfg.h"
34
35
#include "Base.hpp"
36
#include "CheckBase.hpp"
37
#include "CheckCycle.hpp"
38
39
class GC_CheckReporter;
40
class MM_SublistPuddle;
41
class MM_UnfinalizedObjectList;
42
class MM_OwnableSynchronizerObjectList;
43
class GC_FinalizeListManager;
44
45
enum {
46
check_type_other = 0,
47
check_type_object,
48
check_type_class,
49
check_type_thread,
50
check_type_puddle,
51
check_type_unfinalized,
52
check_type_finalizable,
53
check_type_ownable_synchronizer
54
};
55
56
57
/**
58
* Capture information related to an error.
59
*
60
* While walking the heap various errors can be detected. This object
61
* gathers the relevant error information and is passed to
62
* GC_CheckReporter for displaying.
63
*
64
* @todo _object and _slot are not always J9Objects, so we should do the right
65
* thing for different types, and stop casting everything to J9Object when
66
* we call this constructor
67
*
68
* @see GC_CheckReporter
69
*
70
* @ingroup GC_Check
71
*/
72
class GC_CheckError : public MM_Base
73
{
74
public:
75
void *_object; /**< The object or structure that is reporting the error */
76
void *_slot; /**< The slot that is reporting the error */
77
const void *_stackLocaition; /**< The original location on the stack that reports the error */
78
GC_Check *_check; /**< The check which triggered the error */
79
GC_CheckCycle *_cycle; /**< Description of the cycle that triggered the error */
80
const char *_elementName; /**< String describing the element reporting the error */
81
UDATA _errorCode; /**< The error to be recorded, see @ref GCCheckWalkStageErrorCodes. */
82
UDATA _errorNumber; /**< Number of the error encountered */
83
UDATA _objectType; /**< The type of object */
84
85
private:
86
87
void
88
initialize(void *object, void *slot, const void *stackLocation, GC_CheckCycle *cycle, GC_Check *check, const char *elementName, UDATA errorCode, UDATA errorNumber, UDATA objectType)
89
{
90
_object = object;
91
_slot = slot;
92
_stackLocaition = stackLocation;
93
_cycle = cycle;
94
_check = check;
95
_elementName = elementName;
96
_errorCode = errorCode;
97
_errorNumber = errorNumber;
98
_objectType = objectType;
99
}
100
101
void
102
initialize(void *object, void *slot, GC_CheckCycle *cycle, GC_Check *check, const char *elementName, UDATA errorCode, UDATA errorNumber, UDATA objectType)
103
{
104
initialize(object, slot, NULL, cycle, check, elementName, errorCode, errorNumber, objectType);
105
}
106
107
void
108
initialize(void *object, void *slot, GC_CheckCycle *cycle, GC_Check *check, UDATA errorCode, UDATA errorNumber, UDATA objectType)
109
{
110
initialize(object, slot, NULL, cycle, check, "", errorCode, errorNumber, objectType);
111
}
112
113
void
114
initialize(void *object, void *slot, const void *stackLocation, GC_CheckCycle *cycle, GC_Check *check, UDATA errorCode, UDATA errorNumber, UDATA objectType)
115
{
116
initialize(object, slot, stackLocation, cycle, check, "", errorCode, errorNumber, objectType);
117
}
118
119
void
120
initialize(void *object, GC_CheckCycle *cycle, GC_Check *check, const char *elementName, UDATA errorCode, UDATA errorNumber, UDATA objectType)
121
{
122
initialize(object, NULL, NULL, cycle, check, elementName, errorCode, errorNumber, objectType);
123
}
124
125
void
126
initialize(void *object, GC_CheckCycle *cycle, GC_Check *check, UDATA errorCode, UDATA errorNumber, UDATA objectType)
127
{
128
initialize(object, NULL, NULL, cycle, check, "", errorCode, errorNumber, objectType);
129
}
130
131
public:
132
133
/**
134
* Create a new CheckError object.
135
*
136
* @param object the object (not necessarily a java.lang.Object) containing the bad slot
137
* @param slot the slot where the error was found, or the slot pointing to the object
138
* where the error was found
139
* @param invokedBy code indicating how the check was invoked (see @ref GCCheckInvokedBy)
140
* @param stage the current stage of the check, where the error was found
141
* @param manualCheckInvocation GCCheckInvokedBy#invocation_manual, if the check was invoked
142
* manually, and 0 otherwise
143
* @param elementName a string by which to refer to <code>object</code>, e.g. "Object ", "IObject ", etc.
144
* @param errorCode what kind of problem was detected (see @ref GCCheckWalkStageErrorCodes)
145
* @param errorNumber the current number of errors that have occurred, including this one
146
* @param objectType the type of the object param
147
*/
148
GC_CheckError(void *object, void *slot, GC_CheckCycle *cycle, GC_Check *check, const char *elementName, UDATA errorCode, UDATA errorNumber, UDATA objectType)
149
{
150
initialize(object, slot, cycle, check, elementName, errorCode, errorNumber, objectType);
151
}
152
153
/**
154
* Create a new CheckError object, with a blank elementName.
155
*/
156
GC_CheckError(void *object, void *slot, GC_CheckCycle *cycle, GC_Check *check, UDATA errorCode, UDATA errorNumber, UDATA objectType)
157
{
158
initialize(object, slot, cycle, check, errorCode, errorNumber, objectType);
159
}
160
161
/**
162
* Create a new CheckError object, when the error occurred while referencing
163
* an object directly on the heap (not through a slot).
164
*/
165
GC_CheckError(void *object, GC_CheckCycle *cycle, GC_Check *check, const char *elementName, UDATA errorCode, UDATA errorNumber, UDATA objectType)
166
{
167
initialize(object, cycle, check, elementName, errorCode, errorNumber, objectType);
168
}
169
170
171
/**
172
* Create a new CheckError object, with a blank element name, when the error
173
* occurred while referencing an object directly on the heap (not through a slot).
174
*/
175
GC_CheckError(void *object, GC_CheckCycle *cycle, GC_Check *check, UDATA errorCode, UDATA errorNumber, UDATA objectType)
176
{
177
initialize(object, cycle, check, errorCode, errorNumber, objectType);
178
}
179
180
//////// Constructors for J9Class ////////
181
182
/**
183
* Full constructor for errors in J9Class
184
*/
185
GC_CheckError(J9Class *object, void *slot, GC_CheckCycle *cycle, GC_Check *check, const char *elementName, UDATA errorCode, UDATA errorNumber)
186
{
187
initialize((void*)object, slot, cycle, check, elementName, errorCode, errorNumber, check_type_class);
188
}
189
190
/**
191
* Create a new CheckError object, with a blank elementName.
192
*/
193
GC_CheckError(J9Class *object, void *slot, GC_CheckCycle *cycle, GC_Check *check, UDATA errorCode, UDATA errorNumber)
194
{
195
initialize((void*)object, slot, cycle, check, errorCode, errorNumber, check_type_class);
196
}
197
198
/**
199
* Create a new CheckError object, when the error occurred while referencing
200
* an object directly on the heap (not through a slot).
201
*/
202
GC_CheckError(J9Class *object, GC_CheckCycle *cycle, GC_Check *check, const char *elementName, UDATA errorCode, UDATA errorNumber)
203
{
204
initialize((void*)object, cycle, check, elementName, errorCode, errorNumber, check_type_class);
205
}
206
207
/**
208
* Create a new CheckError object, with a blank element name, when the error
209
* occurred while referencing an object directly on the heap (not through a slot).
210
*/
211
GC_CheckError(J9Class *object, GC_CheckCycle *cycle, GC_Check *check, UDATA errorCode, UDATA errorNumber)
212
{
213
initialize((void*)object, cycle, check, errorCode, errorNumber, check_type_class);
214
}
215
216
//////// Constructors for J9VMThread ////////
217
/**
218
* Create a new CheckError object, with a blank elementName.
219
*/
220
GC_CheckError(J9VMThread *object, J9Object **slot, const void *stackLocation, GC_CheckCycle *cycle, GC_Check *check, UDATA errorCode, UDATA errorNumber)
221
{
222
initialize((void*)object, (void*)slot, stackLocation, cycle, check, errorCode, errorNumber, check_type_thread);
223
}
224
//////// Constructors for J9Object ////////
225
226
/**
227
* Full constructor for errors in J9VMThread
228
*/
229
GC_CheckError(J9Object *object, fj9object_t *slot, GC_CheckCycle *cycle, GC_Check *check, const char *elementName, UDATA errorCode, UDATA errorNumber)
230
{
231
initialize((void*)object, (void*)slot, cycle, check, elementName, errorCode, errorNumber, check_type_object);
232
}
233
234
/**
235
* Create a new CheckError object, with a blank elementName.
236
*/
237
GC_CheckError(J9Object *object, fj9object_t *slot, GC_CheckCycle *cycle, GC_Check *check, UDATA errorCode, UDATA errorNumber)
238
{
239
initialize((void*)object, (void*)slot, cycle, check, errorCode, errorNumber, check_type_object);
240
}
241
242
/**
243
* Create a new CheckError object, when the error occurred while referencing
244
* an object directly on the heap (not through a slot).
245
*/
246
GC_CheckError(J9Object *object, GC_CheckCycle *cycle, GC_Check *check, const char *elementName, UDATA errorCode, UDATA errorNumber)
247
{
248
initialize((void*)object, cycle, check, elementName, errorCode, errorNumber, check_type_object);
249
}
250
251
/**
252
* Create a new CheckError object, with a blank element name, when the error
253
* occurred while referencing an object directly on the heap (not through a slot).
254
*/
255
GC_CheckError(J9Object *object, GC_CheckCycle *cycle, GC_Check *check, UDATA errorCode, UDATA errorNumber)
256
{
257
initialize((void*)object, cycle, check, errorCode, errorNumber, check_type_object);
258
}
259
260
//////// Constructors for MM_SublistPuddle ////////
261
262
/**
263
* Full constructor for errors in MM_SublistPuddle
264
*/
265
GC_CheckError(MM_SublistPuddle *object, J9Object **slot, GC_CheckCycle *cycle, GC_Check *check, const char *elementName, UDATA errorCode, UDATA errorNumber)
266
{
267
initialize((void*)object, (void*)slot, cycle, check, elementName, errorCode, errorNumber, check_type_puddle);
268
}
269
270
/**
271
* Create a new CheckError object, with a blank elementName.
272
*/
273
GC_CheckError(MM_SublistPuddle *object, J9Object **slot, GC_CheckCycle *cycle, GC_Check *check, UDATA errorCode, UDATA errorNumber)
274
{
275
initialize((void*)object, (void*)slot, cycle, check, errorCode, errorNumber, check_type_puddle);
276
}
277
278
/**
279
* Create a new CheckError object, when the error occurred while referencing
280
* an object directly on the heap (not through a slot).
281
*/
282
GC_CheckError(MM_SublistPuddle *object, GC_CheckCycle *cycle, GC_Check *check, const char *elementName, UDATA errorCode, UDATA errorNumber)
283
{
284
initialize((void*)object, cycle, check, elementName, errorCode, errorNumber, check_type_puddle);
285
}
286
287
/**
288
* Create a new CheckError object, with a blank element name, when the error
289
* occurred while referencing an object directly on the heap (not through a slot).
290
*/
291
GC_CheckError(MM_SublistPuddle *object, GC_CheckCycle *cycle, GC_Check *check, UDATA errorCode, UDATA errorNumber)
292
{
293
initialize((void*)object, cycle, check, errorCode, errorNumber, check_type_puddle);
294
}
295
296
//////// Constructors for MM_UnfinalizedObjectList ////////
297
298
/**
299
* Create a new CheckError object, with a blank elementName.
300
*/
301
GC_CheckError(MM_UnfinalizedObjectList *object, J9Object **slot, GC_CheckCycle *cycle, GC_Check *check, UDATA errorCode, UDATA errorNumber)
302
{
303
initialize((void*)object, (void*)slot, cycle, check, errorCode, errorNumber, check_type_unfinalized);
304
}
305
306
//////// Constructors for MM_FinalizeListManager ////////
307
308
/**
309
* Create a new CheckError object, with a blank elementName.
310
*/
311
GC_CheckError(GC_FinalizeListManager *object, J9Object **slot, GC_CheckCycle *cycle, GC_Check *check, UDATA errorCode, UDATA errorNumber)
312
{
313
initialize((void*)object, (void*)slot, cycle, check, errorCode, errorNumber, check_type_finalizable);
314
}
315
316
//////// Constructors for MM_OwnableSynchronizerObjectList ////////
317
318
/**
319
* Create a new CheckError object, with a blank elementName.
320
*/
321
GC_CheckError(MM_OwnableSynchronizerObjectList *object, J9Object **slot, GC_CheckCycle *cycle, GC_Check *check, UDATA errorCode, UDATA errorNumber)
322
{
323
initialize((void*)object, (void*)slot, cycle, check, errorCode, errorNumber, check_type_ownable_synchronizer);
324
}
325
};
326
327
#endif /* CHECKERROR_HPP_ */
328
329