50
51 jobject _loader;
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 bool _has_trusted_loader;
62
63 ciFlags _flags;
64
65 // Lazy fields get filled in only upon request.
66 ciInstanceKlass* _super;
67 ciInstance* _java_mirror;
68
69 ciConstantPoolCache* _field_cache; // cached map index->field
70 GrowableArray<ciField*>* _nonstatic_fields; // ordered by JavaFieldStream
71 int _has_injected_fields; // any non static injected fields? lazily initialized.
72
73 // The possible values of the _implementor fall into following three cases:
74 // null: no implementor.
75 // A ciInstanceKlass that's not itself: one implementor.
76 // Itself: more than one implementor.
77 ciInstanceKlass* _implementor;
78 GrowableArray<ciInstanceKlass*>* _transitive_interfaces;
79
80 void compute_injected_fields();
81 bool compute_injected_fields_helper();
82 void compute_transitive_interfaces();
83
84 protected:
85 ciInstanceKlass(Klass* k);
86 ciInstanceKlass(ciSymbol* name, jobject loader);
87
88 InstanceKlass* get_instanceKlass() const {
89 return InstanceKlass::cast(get_Klass());
90 }
91
92 oop loader();
93 jobject loader_handle();
94
95 const char* type_string() { return "ciInstanceKlass"; }
96
97 bool is_in_package_impl(const char* packagename, int len);
98
99 void print_impl(outputStream* st);
100
101 ciConstantPoolCache* field_cache();
102
103 bool is_shared() { return _is_shared; }
104
105 void compute_shared_init_state();
106 bool compute_shared_has_subklass();
107 int compute_nonstatic_fields();
108 GrowableArray<ciField*>* compute_nonstatic_fields_impl(GrowableArray<ciField*>* super_fields);
109 bool compute_has_trusted_loader();
110
111 // Update the init_state for shared klasses
112 void update_if_shared(InstanceKlass::ClassState expected) {
113 if (_is_shared && _init_state != expected) {
114 if (is_loaded()) compute_shared_init_state();
115 }
116 }
117
118 public:
119 // Has this klass been initialized?
120 bool is_initialized() {
121 update_if_shared(InstanceKlass::fully_initialized);
122 return _init_state == InstanceKlass::fully_initialized;
123 }
124 bool is_not_initialized() {
125 update_if_shared(InstanceKlass::fully_initialized);
126 return _init_state < InstanceKlass::being_initialized;
127 }
128 // Is this klass being initialized?
186 } else {
187 return 2;
188 }
189 }
190 bool has_nonstatic_concrete_methods() {
191 assert(is_loaded(), "must be loaded");
192 return _has_nonstatic_concrete_methods;
193 }
194
195 bool is_hidden() const {
196 return _is_hidden;
197 }
198
199 bool is_record() const {
200 return _is_record;
201 }
202
203 ciInstanceKlass* get_canonical_holder(int offset);
204 ciField* get_field_by_offset(int field_offset, bool is_static);
205 ciField* get_field_by_name(ciSymbol* name, ciSymbol* signature, bool is_static);
206
207 // total number of nonstatic fields (including inherited):
208 int nof_nonstatic_fields() {
209 if (_nonstatic_fields == nullptr)
210 return compute_nonstatic_fields();
211 else
212 return _nonstatic_fields->length();
213 }
214
215 bool has_injected_fields() {
216 if (_has_injected_fields == -1) {
217 compute_injected_fields();
218 }
219 return _has_injected_fields > 0 ? true : false;
220 }
221
222 bool has_object_fields() const;
223
224 // nth nonstatic field (presented by ascending address)
225 ciField* nonstatic_field_at(int i) {
226 assert(_nonstatic_fields != nullptr, "");
227 return _nonstatic_fields->at(i);
228 }
229
230 ciInstanceKlass* unique_concrete_subklass();
231 bool has_finalizable_subclass();
232
233 bool contains_field_offset(int offset);
234
235 // Get the instance of java.lang.Class corresponding to
236 // this klass. This instance is used for locking of
237 // synchronized static methods of this klass.
238 ciInstance* java_mirror();
239
240 // Java access flags
241 bool is_public () { return flags().is_public(); }
242 bool is_final () { return flags().is_final(); }
243 bool is_super () { return flags().is_super(); }
244 bool is_interface () { return flags().is_interface(); }
245 bool is_abstract () { return flags().is_abstract(); }
246
247 ciMethod* find_method(ciSymbol* name, ciSymbol* signature);
248 // Note: To find a method from name and type strings, use ciSymbol::make,
249 // but consider adding to vmSymbols.hpp instead.
250
251 bool is_leaf_type();
252 ciInstanceKlass* implementor();
253
254 ciInstanceKlass* unique_implementor() {
255 assert(is_loaded(), "must be loaded");
256 ciInstanceKlass* impl = implementor();
257 return (impl != this ? impl : nullptr);
258 }
259
260 // Is the defining class loader of this class the default loader?
261 bool uses_default_loader() const;
262
263 bool is_java_lang_Object() const;
264
265 BasicType box_klass_type() const;
266 bool is_box_klass() const;
267 bool is_boxed_value_offset(int offset) const;
268
269 // Is this klass in the given package?
270 bool is_in_package(const char* packagename) {
271 return is_in_package(packagename, (int) strlen(packagename));
272 }
273 bool is_in_package(const char* packagename, int len);
274
275 // What kind of ciObject is this?
276 bool is_instance_klass() const { return true; }
277
278 virtual ciKlass* exact_klass() {
279 if (is_loaded() && is_final() && !is_interface()) {
|
50
51 jobject _loader;
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 bool _has_trusted_loader;
62
63 ciFlags _flags;
64
65 // Lazy fields get filled in only upon request.
66 ciInstanceKlass* _super;
67 ciInstance* _java_mirror;
68
69 ciConstantPoolCache* _field_cache; // cached map index->field
70
71 // Fields declared in the bytecode (without nested fields in flat fields), ordered by
72 // offset.
73 const GrowableArray<ciField*>* _declared_nonstatic_fields;
74
75 // Fields laid out in memory (flat fields are expanded into their components). The ciField object
76 // for each primitive component has the holder being this ciInstanceKlass or one of its
77 // superclasses, ordered by offset.
78 const GrowableArray<ciField*>* _nonstatic_fields;
79
80 int _has_injected_fields; // any non static injected fields? lazily initialized.
81
82 // The possible values of the _implementor fall into following three cases:
83 // null: no implementor.
84 // A ciInstanceKlass that's not itself: one implementor.
85 // Itself: more than one implementor.
86 ciInstanceKlass* _implementor;
87 GrowableArray<ciInstanceKlass*>* _transitive_interfaces;
88
89 void compute_injected_fields();
90 bool compute_injected_fields_helper();
91 void compute_transitive_interfaces();
92
93 protected:
94 ciInstanceKlass(Klass* k);
95 ciInstanceKlass(ciSymbol* name, jobject loader, BasicType bt = T_OBJECT); // for unloaded klasses
96
97 InstanceKlass* get_instanceKlass() const {
98 return InstanceKlass::cast(get_Klass());
99 }
100
101 oop loader();
102 jobject loader_handle();
103
104 const char* type_string() { return "ciInstanceKlass"; }
105
106 bool is_in_package_impl(const char* packagename, int len);
107
108 void print_impl(outputStream* st);
109
110 ciConstantPoolCache* field_cache();
111
112 bool is_shared() { return _is_shared; }
113
114 void compute_shared_init_state();
115 bool compute_shared_has_subklass();
116 void compute_nonstatic_fields();
117 void compute_nonstatic_fields_impl(const GrowableArray<ciField*>* super_declared_fields, const GrowableArray<ciField*>* super_fields);
118 bool compute_has_trusted_loader();
119
120 // Update the init_state for shared klasses
121 void update_if_shared(InstanceKlass::ClassState expected) {
122 if (_is_shared && _init_state != expected) {
123 if (is_loaded()) compute_shared_init_state();
124 }
125 }
126
127 public:
128 // Has this klass been initialized?
129 bool is_initialized() {
130 update_if_shared(InstanceKlass::fully_initialized);
131 return _init_state == InstanceKlass::fully_initialized;
132 }
133 bool is_not_initialized() {
134 update_if_shared(InstanceKlass::fully_initialized);
135 return _init_state < InstanceKlass::being_initialized;
136 }
137 // Is this klass being initialized?
195 } else {
196 return 2;
197 }
198 }
199 bool has_nonstatic_concrete_methods() {
200 assert(is_loaded(), "must be loaded");
201 return _has_nonstatic_concrete_methods;
202 }
203
204 bool is_hidden() const {
205 return _is_hidden;
206 }
207
208 bool is_record() const {
209 return _is_record;
210 }
211
212 ciInstanceKlass* get_canonical_holder(int offset);
213 ciField* get_field_by_offset(int field_offset, bool is_static);
214 ciField* get_field_by_name(ciSymbol* name, ciSymbol* signature, bool is_static);
215 // Get field descriptor at field_offset ignoring flattening
216 ciField* get_non_flat_field_by_offset(int field_offset);
217 // Get the index of the declared field that contains this offset
218 int field_index_by_offset(int offset);
219
220 // Total number of nonstatic fields (including inherited)
221 int nof_declared_nonstatic_fields() {
222 if (_declared_nonstatic_fields == nullptr) {
223 compute_nonstatic_fields();
224 }
225 return _declared_nonstatic_fields->length();
226 }
227
228 int nof_nonstatic_fields() {
229 if (_nonstatic_fields == nullptr) {
230 compute_nonstatic_fields();
231 }
232 return _nonstatic_fields->length();
233 }
234
235 bool has_injected_fields() {
236 if (_has_injected_fields == -1) {
237 compute_injected_fields();
238 }
239 return _has_injected_fields > 0 ? true : false;
240 }
241
242 bool has_object_fields() const;
243
244 ciField* declared_nonstatic_field_at(int i) {
245 assert(_declared_nonstatic_fields != nullptr, "should be initialized");
246 return _declared_nonstatic_fields->at(i);
247 }
248
249 ciField* nonstatic_field_at(int i) {
250 assert(_nonstatic_fields != nullptr, "");
251 return _nonstatic_fields->at(i);
252 }
253
254 ciInstanceKlass* unique_concrete_subklass();
255 bool has_finalizable_subclass();
256
257 bool contains_field_offset(int offset);
258
259 // Get the instance of java.lang.Class corresponding to
260 // this klass. This instance is used for locking of
261 // synchronized static methods of this klass.
262 ciInstance* java_mirror();
263
264 // Java access flags
265 bool is_public () { return flags().is_public(); }
266 bool is_final () { return flags().is_final(); }
267 bool is_interface () { return flags().is_interface(); }
268 bool is_abstract () { return flags().is_abstract(); }
269 bool is_abstract_value_klass() { return is_abstract() && !flags().is_identity(); }
270
271 ciMethod* find_method(ciSymbol* name, ciSymbol* signature);
272 // Note: To find a method from name and type strings, use ciSymbol::make,
273 // but consider adding to vmSymbols.hpp instead.
274
275 bool is_leaf_type();
276 ciInstanceKlass* implementor();
277
278 ciInstanceKlass* unique_implementor() {
279 assert(is_loaded(), "must be loaded");
280 ciInstanceKlass* impl = implementor();
281 return (impl != this ? impl : nullptr);
282 }
283
284 virtual bool can_be_inline_klass(bool is_exact = false);
285
286 // Is the defining class loader of this class the default loader?
287 bool uses_default_loader() const;
288
289 bool is_java_lang_Object() const;
290
291 BasicType box_klass_type() const;
292 bool is_box_klass() const;
293 bool is_boxed_value_offset(int offset) const;
294
295 // Is this klass in the given package?
296 bool is_in_package(const char* packagename) {
297 return is_in_package(packagename, (int) strlen(packagename));
298 }
299 bool is_in_package(const char* packagename, int len);
300
301 // What kind of ciObject is this?
302 bool is_instance_klass() const { return true; }
303
304 virtual ciKlass* exact_klass() {
305 if (is_loaded() && is_final() && !is_interface()) {
|