< prev index next >

src/hotspot/share/ci/ciInstanceKlass.hpp

Print this page

 51 
 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                   _has_trusted_loader;
 63 
 64   ciFlags                _flags;
 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;  // ordered by JavaFieldStream













 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   GrowableArray<ciInstanceKlass*>* _transitive_interfaces;
 80 
 81   void compute_injected_fields();
 82   bool compute_injected_fields_helper();
 83   void compute_transitive_interfaces();
 84 
 85   ciField* get_non_static_field_by_offset(int field_offset);
 86 
 87 protected:
 88   ciInstanceKlass(Klass* k);
 89   ciInstanceKlass(ciSymbol* name, jobject loader);
 90 
 91   InstanceKlass* get_instanceKlass() const {
 92     return InstanceKlass::cast(get_Klass());
 93   }
 94 
 95   oop loader();
 96   jobject loader_handle();
 97 
 98   const char* type_string() { return "ciInstanceKlass"; }
 99 
100   bool is_in_package_impl(const char* packagename, int len);
101 
102   void print_impl(outputStream* st);
103 
104   ciConstantPoolCache* field_cache();
105 
106   bool is_shared() { return _is_shared; }
107 
108   void compute_shared_init_state();
109   bool compute_shared_has_subklass();
110   int  compute_nonstatic_fields();
111   GrowableArray<ciField*>* compute_nonstatic_fields_impl(GrowableArray<ciField*>* super_fields);
112   bool compute_has_trusted_loader();
113 
114   // Update the init_state for shared klasses
115   void update_if_shared(InstanceKlass::ClassState expected) {
116     if (_is_shared && _init_state != expected) {
117       if (is_loaded()) compute_shared_init_state();
118     }
119   }
120 
121 public:
122   // Has this klass been initialized?
123   bool                   is_initialized() {
124     update_if_shared(InstanceKlass::fully_initialized);
125     return _init_state == InstanceKlass::fully_initialized;
126   }
127   bool                   is_not_initialized() {
128     update_if_shared(InstanceKlass::fully_initialized);
129     return _init_state < InstanceKlass::being_initialized;
130   }
131   // Is this klass being initialized?

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












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




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

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


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

 51 
 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                   _has_trusted_loader;
 63 
 64   ciFlags                _flags;
 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 
 72   // Fields declared in the bytecode (without nested fields in flat fields),
 73   // ordered in JavaFieldStream order, with superclasses first (i.e. from lang.java.Object
 74   // to most derived class).
 75   const GrowableArray<ciField*>* _declared_nonstatic_fields;
 76 
 77   // Fields laid out in memory (flat fields are expanded into their components). The ciField object
 78   // for each primitive component has the holder being this ciInstanceKlass or one of its
 79   // superclasses.
 80   // Fields are in the same order as in _declared_nonstatic_fields, but flat fields are replaced by
 81   // the list of their own fields, ordered the same way (hierarchy traversed top-down, in
 82   // JavaFieldStream order).
 83   const GrowableArray<ciField*>* _nonstatic_fields;
 84 
 85   int                    _has_injected_fields; // any non static injected fields? lazily initialized.
 86 
 87   // The possible values of the _implementor fall into following three cases:
 88   //   null: no implementor.
 89   //   A ciInstanceKlass that's not itself: one implementor.
 90   //   Itself: more than one implementor.
 91   ciInstanceKlass*       _implementor;
 92   GrowableArray<ciInstanceKlass*>* _transitive_interfaces;
 93 
 94   void compute_injected_fields();
 95   bool compute_injected_fields_helper();
 96   void compute_transitive_interfaces();
 97 
 98   ciField* get_non_static_field_by_offset(int field_offset);
 99 
100 protected:
101   ciInstanceKlass(Klass* k);
102   ciInstanceKlass(ciSymbol* name, jobject loader, BasicType bt = T_OBJECT); // for unloaded klasses
103 
104   InstanceKlass* get_instanceKlass() const {
105     return InstanceKlass::cast(get_Klass());
106   }
107 
108   oop loader();
109   jobject loader_handle();
110 
111   const char* type_string() { return "ciInstanceKlass"; }
112 
113   bool is_in_package_impl(const char* packagename, int len);
114 
115   void print_impl(outputStream* st);
116 
117   ciConstantPoolCache* field_cache();
118 
119   bool is_shared() { return _is_shared; }
120 
121   void compute_shared_init_state();
122   bool compute_shared_has_subklass();
123   void compute_nonstatic_fields();
124   void compute_nonstatic_fields_impl(const GrowableArray<ciField*>* super_declared_fields, const GrowableArray<ciField*>* super_fields);
125   bool compute_has_trusted_loader();
126 
127   // Update the init_state for shared klasses
128   void update_if_shared(InstanceKlass::ClassState expected) {
129     if (_is_shared && _init_state != expected) {
130       if (is_loaded()) compute_shared_init_state();
131     }
132   }
133 
134 public:
135   // Has this klass been initialized?
136   bool                   is_initialized() {
137     update_if_shared(InstanceKlass::fully_initialized);
138     return _init_state == InstanceKlass::fully_initialized;
139   }
140   bool                   is_not_initialized() {
141     update_if_shared(InstanceKlass::fully_initialized);
142     return _init_state < InstanceKlass::being_initialized;
143   }
144   // Is this klass being initialized?

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

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

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