Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/gc/shenandoah/shenandoahAsserts.hpp
40961 views
1
/*
2
* Copyright (c) 2018, 2019, Red Hat, Inc. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*
23
*/
24
25
#ifndef SHARE_GC_SHENANDOAH_SHENANDOAHASSERTS_HPP
26
#define SHARE_GC_SHENANDOAH_SHENANDOAHASSERTS_HPP
27
28
#include "memory/iterator.hpp"
29
#include "runtime/mutex.hpp"
30
#include "utilities/formatBuffer.hpp"
31
32
typedef FormatBuffer<8192> ShenandoahMessageBuffer;
33
34
class ShenandoahAsserts {
35
public:
36
enum SafeLevel {
37
_safe_unknown,
38
_safe_oop,
39
_safe_oop_fwd,
40
_safe_all
41
};
42
43
static void print_obj(ShenandoahMessageBuffer &msg, oop obj);
44
45
static void print_non_obj(ShenandoahMessageBuffer &msg, void *loc);
46
47
static void print_obj_safe(ShenandoahMessageBuffer &msg, void *loc);
48
49
static void print_failure(SafeLevel level, oop obj, void *interior_loc, oop loc,
50
const char *phase, const char *label,
51
const char *file, int line);
52
53
static void print_rp_failure(const char *label, BoolObjectClosure* actual,
54
const char *file, int line);
55
56
static void assert_in_heap(void* interior_loc, oop obj, const char* file, int line);
57
static void assert_in_heap_or_null(void* interior_loc, oop obj, const char* file, int line);
58
static void assert_in_correct_region(void* interior_loc, oop obj, const char* file, int line);
59
60
static void assert_correct(void* interior_loc, oop obj, const char* file, int line);
61
static void assert_forwarded(void* interior_loc, oop obj, const char* file, int line);
62
static void assert_not_forwarded(void* interior_loc, oop obj, const char* file, int line);
63
static void assert_marked(void* interior_loc, oop obj, const char* file, int line);
64
static void assert_in_cset(void* interior_loc, oop obj, const char* file, int line);
65
static void assert_not_in_cset(void* interior_loc, oop obj, const char* file, int line);
66
static void assert_not_in_cset_loc(void* interior_loc, const char* file, int line);
67
68
static void assert_locked_or_shenandoah_safepoint(Mutex* lock, const char* file, int line);
69
70
static void assert_heaplocked(const char* file, int line);
71
static void assert_not_heaplocked(const char* file, int line);
72
static void assert_heaplocked_or_safepoint(const char* file, int line);
73
74
#ifdef ASSERT
75
#define shenandoah_assert_in_heap(interior_loc, obj) \
76
ShenandoahAsserts::assert_in_heap(interior_loc, obj, __FILE__, __LINE__)
77
#define shenandoah_assert_in_heap_or_null(interior_loc, obj) \
78
ShenandoahAsserts::assert_in_heap_or_null(interior_loc, obj, __FILE__, __LINE__)
79
#define shenandoah_assert_in_correct_region(interior_loc, obj) \
80
ShenandoahAsserts::assert_in_correct_region(interior_loc, obj, __FILE__, __LINE__)
81
82
#define shenandoah_assert_correct_if(interior_loc, obj, condition) \
83
if (condition) ShenandoahAsserts::assert_correct(interior_loc, obj, __FILE__, __LINE__)
84
#define shenandoah_assert_correct_except(interior_loc, obj, exception) \
85
if (!(exception)) ShenandoahAsserts::assert_correct(interior_loc, obj, __FILE__, __LINE__)
86
#define shenandoah_assert_correct(interior_loc, obj) \
87
ShenandoahAsserts::assert_correct(interior_loc, obj, __FILE__, __LINE__)
88
89
#define shenandoah_assert_forwarded_if(interior_loc, obj, condition) \
90
if (condition) ShenandoahAsserts::assert_forwarded(interior_loc, obj, __FILE__, __LINE__)
91
#define shenandoah_assert_forwarded_except(interior_loc, obj, exception) \
92
if (!(exception)) ShenandoahAsserts::assert_forwarded(interior_loc, obj, __FILE__, __LINE__)
93
#define shenandoah_assert_forwarded(interior_loc, obj) \
94
ShenandoahAsserts::assert_forwarded(interior_loc, obj, __FILE__, __LINE__)
95
96
#define shenandoah_assert_not_forwarded_if(interior_loc, obj, condition) \
97
if (condition) ShenandoahAsserts::assert_not_forwarded(interior_loc, obj, __FILE__, __LINE__)
98
#define shenandoah_assert_not_forwarded_except(interior_loc, obj, exception) \
99
if (!(exception)) ShenandoahAsserts::assert_not_forwarded(interior_loc, obj, __FILE__, __LINE__)
100
#define shenandoah_assert_not_forwarded(interior_loc, obj) \
101
ShenandoahAsserts::assert_not_forwarded(interior_loc, obj, __FILE__, __LINE__)
102
103
#define shenandoah_assert_marked_if(interior_loc, obj, condition) \
104
if (condition) ShenandoahAsserts::assert_marked(interior_loc, obj, __FILE__, __LINE__)
105
#define shenandoah_assert_marked_except(interior_loc, obj, exception) \
106
if (!(exception)) ShenandoahAsserts::assert_marked(interior_loc, obj, __FILE__, __LINE__)
107
#define shenandoah_assert_marked(interior_loc, obj) \
108
ShenandoahAsserts::assert_marked(interior_loc, obj, __FILE__, __LINE__)
109
110
#define shenandoah_assert_in_cset_if(interior_loc, obj, condition) \
111
if (condition) ShenandoahAsserts::assert_in_cset(interior_loc, obj, __FILE__, __LINE__)
112
#define shenandoah_assert_in_cset_except(interior_loc, obj, exception) \
113
if (!(exception)) ShenandoahAsserts::assert_in_cset(interior_loc, obj, __FILE__, __LINE__)
114
#define shenandoah_assert_in_cset(interior_loc, obj) \
115
ShenandoahAsserts::assert_in_cset(interior_loc, obj, __FILE__, __LINE__)
116
117
#define shenandoah_assert_not_in_cset_if(interior_loc, obj, condition) \
118
if (condition) ShenandoahAsserts::assert_not_in_cset(interior_loc, obj, __FILE__, __LINE__)
119
#define shenandoah_assert_not_in_cset_except(interior_loc, obj, exception) \
120
if (!(exception)) ShenandoahAsserts::assert_not_in_cset(interior_loc, obj, __FILE__, __LINE__)
121
#define shenandoah_assert_not_in_cset(interior_loc, obj) \
122
ShenandoahAsserts::assert_not_in_cset(interior_loc, obj, __FILE__, __LINE__)
123
124
#define shenandoah_assert_not_in_cset_loc_if(interior_loc, condition) \
125
if (condition) ShenandoahAsserts::assert_not_in_cset_loc(interior_loc, __FILE__, __LINE__)
126
#define shenandoah_assert_not_in_cset_loc_except(interior_loc, exception) \
127
if (!(exception)) ShenandoahAsserts::assert_not_in_cset_loc(interior_loc, __FILE__, __LINE__)
128
#define shenandoah_assert_not_in_cset_loc(interior_loc) \
129
ShenandoahAsserts::assert_not_in_cset_loc(interior_loc, __FILE__, __LINE__)
130
131
#define shenandoah_assert_rp_isalive_installed() \
132
ShenandoahAsserts::assert_rp_isalive_installed(__FILE__, __LINE__)
133
#define shenandoah_assert_rp_isalive_not_installed() \
134
ShenandoahAsserts::assert_rp_isalive_not_installed(__FILE__, __LINE__)
135
136
#define shenandoah_assert_safepoint() \
137
assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "Should be at Shenandoah Safepoints")
138
139
#define shenandoah_assert_locked_or_safepoint(lock) \
140
ShenandoahAsserts::assert_locked_or_shenandoah_safepoint(lock, __FILE__, __LINE__)
141
142
#define shenandoah_assert_heaplocked() \
143
ShenandoahAsserts::assert_heaplocked(__FILE__, __LINE__)
144
145
#define shenandoah_assert_not_heaplocked() \
146
ShenandoahAsserts::assert_not_heaplocked(__FILE__, __LINE__)
147
148
#define shenandoah_assert_heaplocked_or_safepoint() \
149
ShenandoahAsserts::assert_heaplocked_or_safepoint(__FILE__, __LINE__)
150
#else
151
#define shenandoah_assert_in_heap(interior_loc, obj)
152
#define shenandoah_assert_in_heap_or_null(interior_loc, obj)
153
#define shenandoah_assert_in_correct_region(interior_loc, obj)
154
155
#define shenandoah_assert_correct_if(interior_loc, obj, condition)
156
#define shenandoah_assert_correct_except(interior_loc, obj, exception)
157
#define shenandoah_assert_correct(interior_loc, obj)
158
159
#define shenandoah_assert_forwarded_if(interior_loc, obj, condition)
160
#define shenandoah_assert_forwarded_except(interior_loc, obj, exception)
161
#define shenandoah_assert_forwarded(interior_loc, obj)
162
163
#define shenandoah_assert_not_forwarded_if(interior_loc, obj, condition)
164
#define shenandoah_assert_not_forwarded_except(interior_loc, obj, exception)
165
#define shenandoah_assert_not_forwarded(interior_loc, obj)
166
167
#define shenandoah_assert_marked_if(interior_loc, obj, condition)
168
#define shenandoah_assert_marked_except(interior_loc, obj, exception)
169
#define shenandoah_assert_marked(interior_loc, obj)
170
171
#define shenandoah_assert_in_cset_if(interior_loc, obj, condition)
172
#define shenandoah_assert_in_cset_except(interior_loc, obj, exception)
173
#define shenandoah_assert_in_cset(interior_loc, obj)
174
175
#define shenandoah_assert_not_in_cset_if(interior_loc, obj, condition)
176
#define shenandoah_assert_not_in_cset_except(interior_loc, obj, exception)
177
#define shenandoah_assert_not_in_cset(interior_loc, obj)
178
179
#define shenandoah_assert_not_in_cset_loc_if(interior_loc, condition)
180
#define shenandoah_assert_not_in_cset_loc_except(interior_loc, exception)
181
#define shenandoah_assert_not_in_cset_loc(interior_loc)
182
183
#define shenandoah_assert_rp_isalive_installed()
184
#define shenandoah_assert_rp_isalive_not_installed()
185
186
#define shenandoah_assert_safepoint()
187
#define shenandoah_assert_locked_or_safepoint(lock)
188
189
#define shenandoah_assert_heaplocked()
190
#define shenandoah_assert_not_heaplocked()
191
#define shenandoah_assert_heaplocked_or_safepoint()
192
193
#endif
194
195
#define shenandoah_not_implemented \
196
{ fatal("Deliberately not implemented."); }
197
#define shenandoah_not_implemented_return(v) \
198
{ fatal("Deliberately not implemented."); return v; }
199
200
};
201
202
#endif // SHARE_GC_SHENANDOAH_SHENANDOAHASSERTS_HPP
203
204