< prev index next >

src/hotspot/share/ci/ciInstanceKlass.hpp

Print this page

 52   jobject                _loader;
 53 
 54   InstanceKlass::ClassState _init_state;           // state of class
 55   bool                   _is_shared;
 56   bool                   _has_finalizer;
 57   SubklassValue          _has_subklass;
 58   bool                   _has_nonstatic_fields;
 59   bool                   _has_nonstatic_concrete_methods;
 60   bool                   _is_hidden;
 61   bool                   _is_record;
 62   bool                   _trust_final_fields;
 63   bool                   _has_trusted_loader;
 64 
 65   ciFlags                _flags;
 66 
 67   // Lazy fields get filled in only upon request.
 68   ciInstanceKlass*       _super;
 69   ciInstance*            _java_mirror;
 70 
 71   ciConstantPoolCache*   _field_cache;  // cached map index->field
 72   GrowableArray<ciField*>* _nonstatic_fields;  // ordered by JavaFieldStream













 73   int                    _has_injected_fields; // any non static injected fields? lazily initialized.
 74 
 75   // The possible values of the _implementor fall into following three cases:
 76   //   null: no implementor.
 77   //   A ciInstanceKlass that's not itself: one implementor.
 78   //   Itself: more than one implementor.
 79   ciInstanceKlass*       _implementor;
 80   GrowableArray<ciInstanceKlass*>* _transitive_interfaces;
 81 
 82   void compute_injected_fields();
 83   bool compute_injected_fields_helper();
 84   void compute_transitive_interfaces();
 85 
 86   ciField* get_nonstatic_field_by_offset(int field_offset);
 87 
 88 protected:
 89   ciInstanceKlass(Klass* k);
 90   ciInstanceKlass(ciSymbol* name, jobject loader);
 91 
 92   InstanceKlass* get_instanceKlass() const {
 93     return InstanceKlass::cast(get_Klass());
 94   }
 95 
 96   oop loader();
 97   jobject loader_handle();
 98 
 99   const char* type_string() { return "ciInstanceKlass"; }
100 
101   bool is_in_package_impl(const char* packagename, int len);
102 
103   void print_impl(outputStream* st);
104 
105   ciConstantPoolCache* field_cache();
106 
107   bool is_shared() { return _is_shared; }
108 
109   InstanceKlass::ClassState compute_init_state();
110   bool compute_shared_has_subklass();
111   int  compute_nonstatic_fields();
112   GrowableArray<ciField*>* compute_nonstatic_fields_impl(GrowableArray<ciField*>* super_fields);
113   bool compute_has_trusted_loader();
114 
115 public:
116   // Has this klass been initialized?
117   bool                   is_initialized() {
118     InstanceKlass::ClassState state = compute_init_state();
119     return state == InstanceKlass::fully_initialized;
120   }
121   bool                   is_not_initialized() {
122     InstanceKlass::ClassState state = compute_init_state();
123     return state < InstanceKlass::being_initialized;
124   }
125   // Is this klass being initialized?
126   bool                   is_being_initialized() {
127     InstanceKlass::ClassState state = compute_init_state();
128     return state == InstanceKlass::being_initialized;
129   }
130   // Has this klass been linked?
131   bool                   is_linked() {
132     InstanceKlass::ClassState state = compute_init_state();

191   bool has_nonstatic_concrete_methods()  {
192     assert(is_loaded(), "must be loaded");
193     return _has_nonstatic_concrete_methods;
194   }
195 
196   bool is_hidden() const {
197     return _is_hidden;
198   }
199 
200   bool is_record() const {
201     return _is_record;
202   }
203 
204   bool trust_final_fields() const {
205     return _trust_final_fields;
206   }
207 
208   ciInstanceKlass* get_canonical_holder(int offset);
209   ciField* get_field_by_offset(int field_offset, bool is_static);
210   ciField* get_field_by_name(ciSymbol* name, ciSymbol* signature, bool is_static);












211   ciField* get_injected_instance_field_by_name(ciSymbol* name, ciSymbol* signature);
212   BasicType get_field_type_by_offset(int field_offset, bool is_static);
213 
214   // total number of nonstatic fields (including inherited):
215   int nof_nonstatic_fields() {
216     if (_nonstatic_fields == nullptr)
217       return compute_nonstatic_fields();
218     else
219       return _nonstatic_fields->length();
220   }
221 
222   bool has_injected_fields() {
223     if (_has_injected_fields == -1) {
224       compute_injected_fields();
225     }
226     return _has_injected_fields > 0 ? true : false;
227   }
228 
229   bool has_object_fields() const;
230 
231   // nth nonstatic field (presented by ascending address)




232   ciField* nonstatic_field_at(int i) {
233     assert(_nonstatic_fields != nullptr, "");
234     return _nonstatic_fields->at(i);
235   }
236 
237   ciInstanceKlass* unique_concrete_subklass();
238   bool has_finalizable_subclass();
239 
240   bool has_class_initializer();
241 
242   bool contains_field_offset(int offset);
243 
244   // Get the instance of java.lang.Class corresponding to
245   // this klass.  This instance is used for locking of
246   // synchronized static methods of this klass.
247   ciInstance*            java_mirror();
248 
249   // Java access flags
250   bool is_public      () { return flags().is_public(); }
251   bool is_final       () { return flags().is_final(); }
252   bool is_super       () { return flags().is_super(); }
253   bool is_interface   () { return flags().is_interface(); }
254   bool is_abstract    () { return flags().is_abstract(); }

255 
256   ciMethod* find_method(ciSymbol* name, ciSymbol* signature);
257   // Note:  To find a method from name and type strings, use ciSymbol::make,
258   // but consider adding to vmSymbols.hpp instead.
259 
260   bool is_leaf_type();
261   ciInstanceKlass* implementor();
262 
263   ciInstanceKlass* unique_implementor() {
264     assert(is_loaded(), "must be loaded");
265     assert(is_interface(), "must be");
266     ciInstanceKlass* impl = implementor();
267     return (impl != this ? impl : nullptr);
268   }
269 


270   // Is the defining class loader of this class the default loader?
271   bool uses_default_loader() const;
272 
273   bool is_java_lang_Object() const;
274 
275   BasicType box_klass_type() const;
276   bool is_box_klass() const;
277   bool is_boxed_value_offset(int offset) const;
278 
279   // Is this klass in the given package?
280   bool is_in_package(const char* packagename) {
281     return is_in_package(packagename, (int) strlen(packagename));
282   }
283   bool is_in_package(const char* packagename, int len);
284 
285   // What kind of ciObject is this?
286   bool is_instance_klass() const { return true; }
287 
288   virtual ciKlass* exact_klass() {
289     if (is_loaded() && is_final() && !is_interface()) {

 52   jobject                _loader;
 53 
 54   InstanceKlass::ClassState _init_state;           // state of class
 55   bool                   _is_shared;
 56   bool                   _has_finalizer;
 57   SubklassValue          _has_subklass;
 58   bool                   _has_nonstatic_fields;
 59   bool                   _has_nonstatic_concrete_methods;
 60   bool                   _is_hidden;
 61   bool                   _is_record;
 62   bool                   _trust_final_fields;
 63   bool                   _has_trusted_loader;
 64 
 65   ciFlags                _flags;
 66 
 67   // Lazy fields get filled in only upon request.
 68   ciInstanceKlass*       _super;
 69   ciInstance*            _java_mirror;
 70 
 71   ciConstantPoolCache*   _field_cache;  // cached map index->field
 72 
 73   // Fields declared in the bytecode (without nested fields in flat fields),
 74   // ordered in JavaFieldStream order, with superclasses first (i.e. from lang.java.Object
 75   // to most derived class).
 76   const GrowableArray<ciField*>* _declared_nonstatic_fields;
 77 
 78   // Fields laid out in memory (flat fields are expanded into their components). The ciField object
 79   // for each primitive component has the holder being this ciInstanceKlass or one of its
 80   // superclasses.
 81   // Fields are in the same order as in _declared_nonstatic_fields, but flat fields are replaced by
 82   // the list of their own fields, ordered the same way (hierarchy traversed top-down, in
 83   // JavaFieldStream order).
 84   const GrowableArray<ciField*>* _nonstatic_fields;
 85 
 86   int                    _has_injected_fields; // any non static injected fields? lazily initialized.
 87 
 88   // The possible values of the _implementor fall into following three cases:
 89   //   null: no implementor.
 90   //   A ciInstanceKlass that's not itself: one implementor.
 91   //   Itself: more than one implementor.
 92   ciInstanceKlass*       _implementor;
 93   GrowableArray<ciInstanceKlass*>* _transitive_interfaces;
 94 
 95   void compute_injected_fields();
 96   bool compute_injected_fields_helper();
 97   void compute_transitive_interfaces();
 98 
 99   ciField* get_nonstatic_field_by_offset(int field_offset);
100 
101 protected:
102   ciInstanceKlass(Klass* k);
103   ciInstanceKlass(ciSymbol* name, jobject loader, BasicType bt = T_OBJECT); // for unloaded klasses
104 
105   InstanceKlass* get_instanceKlass() const {
106     return InstanceKlass::cast(get_Klass());
107   }
108 
109   oop loader();
110   jobject loader_handle();
111 
112   const char* type_string() { return "ciInstanceKlass"; }
113 
114   bool is_in_package_impl(const char* packagename, int len);
115 
116   void print_impl(outputStream* st);
117 
118   ciConstantPoolCache* field_cache();
119 
120   bool is_shared() { return _is_shared; }
121 
122   InstanceKlass::ClassState compute_init_state();
123   bool compute_shared_has_subklass();
124   void compute_nonstatic_fields();
125   void compute_nonstatic_fields_impl(const GrowableArray<ciField*>* super_declared_fields, const GrowableArray<ciField*>* super_fields);
126   bool compute_has_trusted_loader();
127 
128 public:
129   // Has this klass been initialized?
130   bool                   is_initialized() {
131     InstanceKlass::ClassState state = compute_init_state();
132     return state == InstanceKlass::fully_initialized;
133   }
134   bool                   is_not_initialized() {
135     InstanceKlass::ClassState state = compute_init_state();
136     return state < InstanceKlass::being_initialized;
137   }
138   // Is this klass being initialized?
139   bool                   is_being_initialized() {
140     InstanceKlass::ClassState state = compute_init_state();
141     return state == InstanceKlass::being_initialized;
142   }
143   // Has this klass been linked?
144   bool                   is_linked() {
145     InstanceKlass::ClassState state = compute_init_state();

204   bool has_nonstatic_concrete_methods()  {
205     assert(is_loaded(), "must be loaded");
206     return _has_nonstatic_concrete_methods;
207   }
208 
209   bool is_hidden() const {
210     return _is_hidden;
211   }
212 
213   bool is_record() const {
214     return _is_record;
215   }
216 
217   bool trust_final_fields() const {
218     return _trust_final_fields;
219   }
220 
221   ciInstanceKlass* get_canonical_holder(int offset);
222   ciField* get_field_by_offset(int field_offset, bool is_static);
223   ciField* get_field_by_name(ciSymbol* name, ciSymbol* signature, bool is_static);
224   // Get field descriptor at field_offset ignoring flattening
225   ciField* get_non_flat_field_by_offset(int field_offset);
226   // Get the index of the declared field that contains this offset
227   int field_index_by_offset(int offset);
228 
229   // Total number of nonstatic fields (including inherited)
230   int nof_declared_nonstatic_fields() {
231     if (_declared_nonstatic_fields == nullptr) {
232       compute_nonstatic_fields();
233     }
234     return _declared_nonstatic_fields->length();
235   }
236   ciField* get_injected_instance_field_by_name(ciSymbol* name, ciSymbol* signature);
237   BasicType get_field_type_by_offset(int field_offset, bool is_static);
238 

239   int nof_nonstatic_fields() {
240     if (_nonstatic_fields == nullptr) {
241       compute_nonstatic_fields();
242     }
243     return _nonstatic_fields->length();
244   }
245 
246   bool has_injected_fields() {
247     if (_has_injected_fields == -1) {
248       compute_injected_fields();
249     }
250     return _has_injected_fields > 0 ? true : false;
251   }
252 
253   bool has_object_fields() const;
254 
255   ciField* declared_nonstatic_field_at(int i) {
256     assert(_declared_nonstatic_fields != nullptr, "should be initialized");
257     return _declared_nonstatic_fields->at(i);
258   }
259 
260   ciField* nonstatic_field_at(int i) {
261     assert(_nonstatic_fields != nullptr, "");
262     return _nonstatic_fields->at(i);
263   }
264 
265   ciInstanceKlass* unique_concrete_subklass();
266   bool has_finalizable_subclass();
267 
268   bool has_class_initializer();
269 
270   bool contains_field_offset(int offset) const;
271 
272   // Get the instance of java.lang.Class corresponding to
273   // this klass.  This instance is used for locking of
274   // synchronized static methods of this klass.
275   ciInstance*            java_mirror();
276 
277   // Java access flags
278   bool is_public      () { return flags().is_public(); }
279   bool is_final       () { return flags().is_final(); }

280   bool is_interface   () { return flags().is_interface(); }
281   bool is_abstract    () { return flags().is_abstract(); }
282   bool is_abstract_value_klass() { return is_abstract() && !flags().is_identity(); }
283 
284   ciMethod* find_method(ciSymbol* name, ciSymbol* signature);
285   // Note:  To find a method from name and type strings, use ciSymbol::make,
286   // but consider adding to vmSymbols.hpp instead.
287 
288   bool is_leaf_type();
289   ciInstanceKlass* implementor();
290 
291   ciInstanceKlass* unique_implementor() {
292     assert(is_loaded(), "must be loaded");
293     assert(is_interface(), "must be");
294     ciInstanceKlass* impl = implementor();
295     return (impl != this ? impl : nullptr);
296   }
297 
298   virtual bool can_be_inline_klass(bool is_exact = false);
299 
300   // Is the defining class loader of this class the default loader?
301   bool uses_default_loader() const;
302 
303   bool is_java_lang_Object() const;
304 
305   BasicType box_klass_type() const;
306   bool is_box_klass() const;
307   bool is_boxed_value_offset(int offset) const;
308 
309   // Is this klass in the given package?
310   bool is_in_package(const char* packagename) {
311     return is_in_package(packagename, (int) strlen(packagename));
312   }
313   bool is_in_package(const char* packagename, int len);
314 
315   // What kind of ciObject is this?
316   bool is_instance_klass() const { return true; }
317 
318   virtual ciKlass* exact_klass() {
319     if (is_loaded() && is_final() && !is_interface()) {
< prev index next >