< 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   void compute_shared_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   // Update the init_state for shared klasses
116   void update_if_shared(InstanceKlass::ClassState expected) {
117     if (_is_shared && _init_state != expected) {
118       if (is_loaded()) compute_shared_init_state();
119     }
120   }
121 
122 public:
123   // Has this klass been initialized?
124   bool                   is_initialized() {
125     update_if_shared(InstanceKlass::fully_initialized);
126     return _init_state == InstanceKlass::fully_initialized;
127   }
128   bool                   is_not_initialized() {
129     update_if_shared(InstanceKlass::fully_initialized);
130     return _init_state < InstanceKlass::being_initialized;
131   }
132   // Is this klass being initialized?

198   bool has_nonstatic_concrete_methods()  {
199     assert(is_loaded(), "must be loaded");
200     return _has_nonstatic_concrete_methods;
201   }
202 
203   bool is_hidden() const {
204     return _is_hidden;
205   }
206 
207   bool is_record() const {
208     return _is_record;
209   }
210 
211   bool trust_final_fields() const {
212     return _trust_final_fields;
213   }
214 
215   ciInstanceKlass* get_canonical_holder(int offset);
216   ciField* get_field_by_offset(int field_offset, bool is_static);
217   ciField* get_field_by_name(ciSymbol* name, ciSymbol* signature, bool is_static);












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




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

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


276   // Is the defining class loader of this class the default loader?
277   bool uses_default_loader() const;
278 
279   bool is_java_lang_Object() const;
280 
281   BasicType box_klass_type() const;
282   bool is_box_klass() const;
283   bool is_boxed_value_offset(int offset) const;
284 
285   // Is this klass in the given package?
286   bool is_in_package(const char* packagename) {
287     return is_in_package(packagename, (int) strlen(packagename));
288   }
289   bool is_in_package(const char* packagename, int len);
290 
291   // What kind of ciObject is this?
292   bool is_instance_klass() const { return true; }
293 
294   virtual ciKlass* exact_klass() {
295     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   void compute_shared_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   // Update the init_state for shared klasses
129   void update_if_shared(InstanceKlass::ClassState expected) {
130     if (_is_shared && _init_state != expected) {
131       if (is_loaded()) compute_shared_init_state();
132     }
133   }
134 
135 public:
136   // Has this klass been initialized?
137   bool                   is_initialized() {
138     update_if_shared(InstanceKlass::fully_initialized);
139     return _init_state == InstanceKlass::fully_initialized;
140   }
141   bool                   is_not_initialized() {
142     update_if_shared(InstanceKlass::fully_initialized);
143     return _init_state < InstanceKlass::being_initialized;
144   }
145   // Is this klass being initialized?

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

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

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