< 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 protected:
 86   ciInstanceKlass(Klass* k);
 87   ciInstanceKlass(ciSymbol* name, jobject loader);
 88 
 89   InstanceKlass* get_instanceKlass() const {
 90     return InstanceKlass::cast(get_Klass());
 91   }
 92 
 93   oop loader();
 94   jobject loader_handle();
 95 
 96   const char* type_string() { return "ciInstanceKlass"; }
 97 
 98   bool is_in_package_impl(const char* packagename, int len);
 99 
100   void print_impl(outputStream* st);
101 
102   ciConstantPoolCache* field_cache();
103 
104   bool is_shared() { return _is_shared; }
105 
106   void compute_shared_init_state();
107   bool compute_shared_has_subklass();
108   int  compute_nonstatic_fields();
109   GrowableArray<ciField*>* compute_nonstatic_fields_impl(GrowableArray<ciField*>* super_fields);
110   bool compute_has_trusted_loader();
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?

187     } else {
188       return 2;
189     }
190   }
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   ciInstanceKlass* get_canonical_holder(int offset);
205   ciField* get_field_by_offset(int field_offset, bool is_static);
206   ciField* get_field_by_name(ciSymbol* name, ciSymbol* signature, bool is_static);












207 
208   // total number of nonstatic fields (including inherited):
209   int nof_nonstatic_fields() {
210     if (_nonstatic_fields == nullptr)
211       return compute_nonstatic_fields();
212     else
213       return _nonstatic_fields->length();
214   }
215 
216   bool has_injected_fields() {
217     if (_has_injected_fields == -1) {
218       compute_injected_fields();
219     }
220     return _has_injected_fields > 0 ? true : false;
221   }
222 
223   bool has_object_fields() const;
224 
225   // nth nonstatic field (presented by ascending address)




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

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


263   // Is the defining class loader of this class the default loader?
264   bool uses_default_loader() const;
265 
266   bool is_java_lang_Object() const;
267 
268   BasicType box_klass_type() const;
269   bool is_box_klass() const;
270   bool is_boxed_value_offset(int offset) const;
271 
272   // Is this klass in the given package?
273   bool is_in_package(const char* packagename) {
274     return is_in_package(packagename, (int) strlen(packagename));
275   }
276   bool is_in_package(const char* packagename, int len);
277 
278   // What kind of ciObject is this?
279   bool is_instance_klass() const { return true; }
280 
281   virtual ciKlass* exact_klass() {
282     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 protected:
 99   ciInstanceKlass(Klass* k);
100   ciInstanceKlass(ciSymbol* name, jobject loader, BasicType bt = T_OBJECT); // for unloaded klasses
101 
102   InstanceKlass* get_instanceKlass() const {
103     return InstanceKlass::cast(get_Klass());
104   }
105 
106   oop loader();
107   jobject loader_handle();
108 
109   const char* type_string() { return "ciInstanceKlass"; }
110 
111   bool is_in_package_impl(const char* packagename, int len);
112 
113   void print_impl(outputStream* st);
114 
115   ciConstantPoolCache* field_cache();
116 
117   bool is_shared() { return _is_shared; }
118 
119   void compute_shared_init_state();
120   bool compute_shared_has_subklass();
121   void compute_nonstatic_fields();
122   void compute_nonstatic_fields_impl(const GrowableArray<ciField*>* super_declared_fields, const GrowableArray<ciField*>* super_fields);
123   bool compute_has_trusted_loader();
124 
125   // Update the init_state for shared klasses
126   void update_if_shared(InstanceKlass::ClassState expected) {
127     if (_is_shared && _init_state != expected) {
128       if (is_loaded()) compute_shared_init_state();
129     }
130   }
131 
132 public:
133   // Has this klass been initialized?
134   bool                   is_initialized() {
135     update_if_shared(InstanceKlass::fully_initialized);
136     return _init_state == InstanceKlass::fully_initialized;
137   }
138   bool                   is_not_initialized() {
139     update_if_shared(InstanceKlass::fully_initialized);
140     return _init_state < InstanceKlass::being_initialized;
141   }
142   // Is this klass being initialized?

200     } else {
201       return 2;
202     }
203   }
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   ciInstanceKlass* get_canonical_holder(int offset);
218   ciField* get_field_by_offset(int field_offset, bool is_static);
219   ciField* get_field_by_name(ciSymbol* name, ciSymbol* signature, bool is_static);
220   // Get field descriptor at field_offset ignoring flattening
221   ciField* get_non_flat_field_by_offset(int field_offset);
222   // Get the index of the declared field that contains this offset
223   int field_index_by_offset(int offset);
224 
225   // Total number of nonstatic fields (including inherited)
226   int nof_declared_nonstatic_fields() {
227     if (_declared_nonstatic_fields == nullptr) {
228       compute_nonstatic_fields();
229     }
230     return _declared_nonstatic_fields->length();
231   }
232 

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

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