Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/ci/ciInstanceKlass.hpp
40930 views
1
/*
2
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. 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_CI_CIINSTANCEKLASS_HPP
26
#define SHARE_CI_CIINSTANCEKLASS_HPP
27
28
#include "ci/ciConstantPoolCache.hpp"
29
#include "ci/ciFlags.hpp"
30
#include "ci/ciKlass.hpp"
31
#include "ci/ciSymbol.hpp"
32
#include "oops/instanceKlass.hpp"
33
34
// ciInstanceKlass
35
//
36
// This class represents a Klass* in the HotSpot virtual machine
37
// whose Klass part is an InstanceKlass. It may or may not
38
// be loaded.
39
class ciInstanceKlass : public ciKlass {
40
CI_PACKAGE_ACCESS
41
friend class ciBytecodeStream;
42
friend class ciEnv;
43
friend class ciExceptionHandler;
44
friend class ciMethod;
45
friend class ciField;
46
47
private:
48
enum SubklassValue { subklass_unknown, subklass_false, subklass_true };
49
50
jobject _loader;
51
jobject _protection_domain;
52
53
InstanceKlass::ClassState _init_state; // state of class
54
bool _is_shared;
55
bool _has_finalizer;
56
SubklassValue _has_subklass;
57
bool _has_nonstatic_fields;
58
bool _has_nonstatic_concrete_methods;
59
bool _is_hidden;
60
bool _is_record;
61
62
ciFlags _flags;
63
jint _nonstatic_field_size;
64
jint _nonstatic_oop_map_size;
65
66
// Lazy fields get filled in only upon request.
67
ciInstanceKlass* _super;
68
ciInstance* _java_mirror;
69
70
ciConstantPoolCache* _field_cache; // cached map index->field
71
GrowableArray<ciField*>* _nonstatic_fields;
72
int _has_injected_fields; // any non static injected fields? lazily initialized.
73
74
// The possible values of the _implementor fall into following three cases:
75
// NULL: no implementor.
76
// A ciInstanceKlass that's not itself: one implementor.
77
// Itself: more than one implementor.
78
ciInstanceKlass* _implementor;
79
80
void compute_injected_fields();
81
bool compute_injected_fields_helper();
82
83
protected:
84
ciInstanceKlass(Klass* k);
85
ciInstanceKlass(ciSymbol* name, jobject loader, jobject protection_domain);
86
87
InstanceKlass* get_instanceKlass() const {
88
return InstanceKlass::cast(get_Klass());
89
}
90
91
oop loader();
92
jobject loader_handle();
93
94
oop protection_domain();
95
jobject protection_domain_handle();
96
97
const char* type_string() { return "ciInstanceKlass"; }
98
99
bool is_in_package_impl(const char* packagename, int len);
100
101
void print_impl(outputStream* st);
102
103
ciConstantPoolCache* field_cache();
104
105
bool is_shared() { return _is_shared; }
106
107
void compute_shared_init_state();
108
bool compute_shared_has_subklass();
109
int compute_nonstatic_fields();
110
GrowableArray<ciField*>* compute_nonstatic_fields_impl(GrowableArray<ciField*>* super_fields);
111
112
// Update the init_state for shared klasses
113
void update_if_shared(InstanceKlass::ClassState expected) {
114
if (_is_shared && _init_state != expected) {
115
if (is_loaded()) compute_shared_init_state();
116
}
117
}
118
119
public:
120
// Has this klass been initialized?
121
bool is_initialized() {
122
update_if_shared(InstanceKlass::fully_initialized);
123
return _init_state == InstanceKlass::fully_initialized;
124
}
125
bool is_not_initialized() {
126
update_if_shared(InstanceKlass::fully_initialized);
127
return _init_state < InstanceKlass::being_initialized;
128
}
129
// Is this klass being initialized?
130
bool is_being_initialized() {
131
update_if_shared(InstanceKlass::being_initialized);
132
return _init_state == InstanceKlass::being_initialized;
133
}
134
// Has this klass been linked?
135
bool is_linked() {
136
update_if_shared(InstanceKlass::linked);
137
return _init_state >= InstanceKlass::linked;
138
}
139
// Is this klass in error state?
140
bool is_in_error_state() {
141
update_if_shared(InstanceKlass::initialization_error);
142
return _init_state == InstanceKlass::initialization_error;
143
}
144
145
// General klass information.
146
ciFlags flags() {
147
assert(is_loaded(), "must be loaded");
148
return _flags;
149
}
150
bool has_finalizer() {
151
assert(is_loaded(), "must be loaded");
152
return _has_finalizer; }
153
bool has_subklass() {
154
assert(is_loaded(), "must be loaded");
155
// Ignore cached subklass_false case.
156
// It could be invalidated by concurrent class loading and
157
// can result in type paradoxes during compilation when
158
// a subclass is observed, but has_subklass() returns false.
159
if (_has_subklass == subklass_true) {
160
return true;
161
}
162
if (flags().is_final()) {
163
return false;
164
}
165
return compute_shared_has_subklass();
166
}
167
168
jint size_helper() {
169
return (Klass::layout_helper_size_in_bytes(layout_helper())
170
>> LogHeapWordSize);
171
}
172
jint nonstatic_field_size() {
173
assert(is_loaded(), "must be loaded");
174
return _nonstatic_field_size; }
175
jint has_nonstatic_fields() {
176
assert(is_loaded(), "must be loaded");
177
return _has_nonstatic_fields; }
178
jint nonstatic_oop_map_size() {
179
assert(is_loaded(), "must be loaded");
180
return _nonstatic_oop_map_size; }
181
ciInstanceKlass* super();
182
jint nof_implementors() {
183
ciInstanceKlass* impl;
184
assert(is_loaded(), "must be loaded");
185
impl = implementor();
186
if (impl == NULL) {
187
return 0;
188
} else if (impl != this) {
189
return 1;
190
} else {
191
return 2;
192
}
193
}
194
bool has_nonstatic_concrete_methods() {
195
assert(is_loaded(), "must be loaded");
196
return _has_nonstatic_concrete_methods;
197
}
198
199
bool is_hidden() const {
200
return _is_hidden;
201
}
202
203
bool is_record() const {
204
return _is_record;
205
}
206
207
ciInstanceKlass* get_canonical_holder(int offset);
208
ciField* get_field_by_offset(int field_offset, bool is_static);
209
ciField* get_field_by_name(ciSymbol* name, ciSymbol* signature, bool is_static);
210
211
// total number of nonstatic fields (including inherited):
212
int nof_nonstatic_fields() {
213
if (_nonstatic_fields == NULL)
214
return compute_nonstatic_fields();
215
else
216
return _nonstatic_fields->length();
217
}
218
219
bool has_injected_fields() {
220
if (_has_injected_fields == -1) {
221
compute_injected_fields();
222
}
223
return _has_injected_fields > 0 ? true : false;
224
}
225
226
bool has_object_fields() const;
227
228
// nth nonstatic field (presented by ascending address)
229
ciField* nonstatic_field_at(int i) {
230
assert(_nonstatic_fields != NULL, "");
231
return _nonstatic_fields->at(i);
232
}
233
234
ciInstanceKlass* unique_concrete_subklass();
235
bool has_finalizable_subclass();
236
237
bool contains_field_offset(int offset);
238
239
// Get the instance of java.lang.Class corresponding to
240
// this klass. This instance is used for locking of
241
// synchronized static methods of this klass.
242
ciInstance* java_mirror();
243
244
// Java access flags
245
bool is_public () { return flags().is_public(); }
246
bool is_final () { return flags().is_final(); }
247
bool is_super () { return flags().is_super(); }
248
bool is_interface () { return flags().is_interface(); }
249
bool is_abstract () { return flags().is_abstract(); }
250
251
ciMethod* find_method(ciSymbol* name, ciSymbol* signature);
252
// Note: To find a method from name and type strings, use ciSymbol::make,
253
// but consider adding to vmSymbols.hpp instead.
254
255
bool is_leaf_type();
256
ciInstanceKlass* implementor();
257
258
ciInstanceKlass* unique_implementor() {
259
assert(is_loaded(), "must be loaded");
260
ciInstanceKlass* impl = implementor();
261
return (impl != this ? impl : NULL);
262
}
263
264
// Is the defining class loader of this class the default loader?
265
bool uses_default_loader() const;
266
267
bool is_java_lang_Object() const;
268
269
BasicType box_klass_type() const;
270
bool is_box_klass() const;
271
bool is_boxed_value_offset(int offset) const;
272
bool is_box_cache_valid() const;
273
274
// Is this klass in the given package?
275
bool is_in_package(const char* packagename) {
276
return is_in_package(packagename, (int) strlen(packagename));
277
}
278
bool is_in_package(const char* packagename, int len);
279
280
// What kind of ciObject is this?
281
bool is_instance_klass() const { return true; }
282
bool is_java_klass() const { return true; }
283
284
virtual ciKlass* exact_klass() {
285
if (is_loaded() && is_final() && !is_interface()) {
286
return this;
287
}
288
return NULL;
289
}
290
291
bool can_be_instantiated() {
292
assert(is_loaded(), "must be loaded");
293
return !is_interface() && !is_abstract();
294
}
295
296
// Dump the current state of this klass for compilation replay.
297
virtual void dump_replay_data(outputStream* out);
298
299
#ifdef ASSERT
300
bool debug_final_field_at(int offset);
301
bool debug_stable_field_at(int offset);
302
#endif
303
};
304
305
#endif // SHARE_CI_CIINSTANCEKLASS_HPP
306
307