< prev index next >

src/hotspot/share/ci/ciInstanceKlass.cpp

Print this page

 36 #include "oops/oop.inline.hpp"
 37 #include "oops/fieldStreams.inline.hpp"
 38 #include "runtime/fieldDescriptor.inline.hpp"
 39 #include "runtime/handles.inline.hpp"
 40 #include "runtime/jniHandles.inline.hpp"
 41 
 42 // ciInstanceKlass
 43 //
 44 // This class represents a Klass* in the HotSpot virtual machine
 45 // whose Klass part in an InstanceKlass.
 46 
 47 
 48 // ------------------------------------------------------------------
 49 // ciInstanceKlass::ciInstanceKlass
 50 //
 51 // Loaded instance klass.
 52 ciInstanceKlass::ciInstanceKlass(Klass* k) :
 53   ciKlass(k)
 54 {
 55   assert(get_Klass()->is_instance_klass(), "wrong type");
 56   assert(get_instanceKlass()->is_loaded(), "must be at least loaded");
 57   InstanceKlass* ik = get_instanceKlass();
 58 








 59   AccessFlags access_flags = ik->access_flags();
 60   _flags = ciFlags(access_flags);
 61   _has_finalizer = ik->has_finalizer();
 62   _has_subklass = flags().is_final() ? subklass_false : subklass_unknown;
 63   _init_state = ik->init_state();
 64   _has_nonstatic_fields = ik->has_nonstatic_fields();
 65   _has_nonstatic_concrete_methods = ik->has_nonstatic_concrete_methods();
 66   _is_hidden = ik->is_hidden();
 67   _is_record = ik->is_record();
 68   _nonstatic_fields = nullptr; // initialized lazily by compute_nonstatic_fields:
 69   _has_injected_fields = -1;
 70   _implementor = nullptr; // we will fill these lazily
 71   _transitive_interfaces = nullptr;
 72 
 73   // Ensure that the metadata wrapped by the ciMetadata is kept alive by GC.
 74   // This is primarily useful for metadata which is considered as weak roots
 75   // by the GC but need to be strong roots if reachable from a current compilation.
 76   // InstanceKlass are created for both weak and strong metadata.  Ensuring this metadata
 77   // alive covers the cases where there are weak roots without performance cost.
 78   oop holder = ik->klass_holder();
 79   if (ik->class_loader_data()->has_class_mirror_holder()) {
 80     // Though ciInstanceKlass records class loader oop, it's not enough to keep
 81     // non-strong hidden classes alive (loader == nullptr). Klass holder should
 82     // be used instead. It is enough to record a ciObject, since cached elements are never removed
 83     // during ciObjectFactory lifetime. ciObjectFactory itself is created for

122   _has_nonstatic_fields = false;
123   _nonstatic_fields = nullptr;
124   _has_injected_fields = -1;
125   _is_hidden = false;
126   _is_record = false;
127   _loader = loader;
128   _is_shared = false;
129   _super = nullptr;
130   _java_mirror = nullptr;
131   _field_cache = nullptr;
132   _has_trusted_loader = compute_has_trusted_loader();
133 }
134 
135 
136 
137 // ------------------------------------------------------------------
138 // ciInstanceKlass::compute_shared_is_initialized
139 void ciInstanceKlass::compute_shared_init_state() {
140   GUARDED_VM_ENTRY(
141     InstanceKlass* ik = get_instanceKlass();
142     _init_state = ik->init_state();
143   )
144 }
145 










146 // ------------------------------------------------------------------
147 // ciInstanceKlass::compute_shared_has_subklass
148 bool ciInstanceKlass::compute_shared_has_subklass() {
149   GUARDED_VM_ENTRY(
150     InstanceKlass* ik = get_instanceKlass();
151     _has_subklass = ik->subklass() != nullptr ? subklass_true : subklass_false;
152     return _has_subklass == subklass_true;
153   )
154 }
155 
156 // ------------------------------------------------------------------
157 // ciInstanceKlass::loader
158 oop ciInstanceKlass::loader() {
159   ASSERT_IN_VM;
160   return JNIHandles::resolve(_loader);
161 }
162 
163 // ------------------------------------------------------------------
164 // ciInstanceKlass::loader_handle
165 jobject ciInstanceKlass::loader_handle() {

301   if (name()->index_of_at(len+1, "/", 1) >= 0)
302     return false;
303 
304   return true;
305 }
306 
307 // ------------------------------------------------------------------
308 // ciInstanceKlass::print_impl
309 //
310 // Implementation of the print method.
311 void ciInstanceKlass::print_impl(outputStream* st) {
312   ciKlass::print_impl(st);
313   GUARDED_VM_ENTRY(st->print(" loader=" INTPTR_FORMAT, p2i(loader()));)
314   if (is_loaded()) {
315     st->print(" initialized=%s finalized=%s subklass=%s size=%d flags=",
316               bool_to_str(is_initialized()),
317               bool_to_str(has_finalizer()),
318               bool_to_str(has_subklass()),
319               layout_helper());
320 
321     _flags.print_klass_flags();
322 
323     if (_super) {
324       st->print(" super=");
325       _super->print_name();
326     }
327     if (_java_mirror) {
328       st->print(" mirror=PRESENT");
329     }
330   }
331 }
332 
333 // ------------------------------------------------------------------
334 // ciInstanceKlass::super
335 //
336 // Get the superklass of this klass.
337 ciInstanceKlass* ciInstanceKlass::super() {
338   assert(is_loaded(), "must be loaded");
339   if (_super == nullptr && !is_java_lang_Object()) {
340     GUARDED_VM_ENTRY(
341       Klass* super_klass = get_instanceKlass()->super();
342       _super = CURRENT_ENV->get_instance_klass(super_klass);
343     )
344   }
345   return _super;

 36 #include "oops/oop.inline.hpp"
 37 #include "oops/fieldStreams.inline.hpp"
 38 #include "runtime/fieldDescriptor.inline.hpp"
 39 #include "runtime/handles.inline.hpp"
 40 #include "runtime/jniHandles.inline.hpp"
 41 
 42 // ciInstanceKlass
 43 //
 44 // This class represents a Klass* in the HotSpot virtual machine
 45 // whose Klass part in an InstanceKlass.
 46 
 47 
 48 // ------------------------------------------------------------------
 49 // ciInstanceKlass::ciInstanceKlass
 50 //
 51 // Loaded instance klass.
 52 ciInstanceKlass::ciInstanceKlass(Klass* k) :
 53   ciKlass(k)
 54 {
 55   assert(get_Klass()->is_instance_klass(), "wrong type");
 56 
 57   InstanceKlass* ik = get_instanceKlass();
 58 
 59 #ifdef ASSERT
 60   if (!ik->is_loaded()) {
 61     ResourceMark rm;
 62     ik->print_on(tty);
 63     assert(false, "must be at least loaded: %s", ik->name()->as_C_string());
 64   }
 65 #endif // ASSERT
 66 
 67   AccessFlags access_flags = ik->access_flags();
 68   _flags = ciFlags(access_flags);
 69   _has_finalizer = ik->has_finalizer();
 70   _has_subklass = flags().is_final() ? subklass_false : subklass_unknown;
 71   _init_state = compute_init_state(ik); // _init_state
 72   _has_nonstatic_fields = ik->has_nonstatic_fields();
 73   _has_nonstatic_concrete_methods = ik->has_nonstatic_concrete_methods();
 74   _is_hidden = ik->is_hidden();
 75   _is_record = ik->is_record();
 76   _nonstatic_fields = nullptr; // initialized lazily by compute_nonstatic_fields:
 77   _has_injected_fields = -1;
 78   _implementor = nullptr; // we will fill these lazily
 79   _transitive_interfaces = nullptr;
 80 
 81   // Ensure that the metadata wrapped by the ciMetadata is kept alive by GC.
 82   // This is primarily useful for metadata which is considered as weak roots
 83   // by the GC but need to be strong roots if reachable from a current compilation.
 84   // InstanceKlass are created for both weak and strong metadata.  Ensuring this metadata
 85   // alive covers the cases where there are weak roots without performance cost.
 86   oop holder = ik->klass_holder();
 87   if (ik->class_loader_data()->has_class_mirror_holder()) {
 88     // Though ciInstanceKlass records class loader oop, it's not enough to keep
 89     // non-strong hidden classes alive (loader == nullptr). Klass holder should
 90     // be used instead. It is enough to record a ciObject, since cached elements are never removed
 91     // during ciObjectFactory lifetime. ciObjectFactory itself is created for

130   _has_nonstatic_fields = false;
131   _nonstatic_fields = nullptr;
132   _has_injected_fields = -1;
133   _is_hidden = false;
134   _is_record = false;
135   _loader = loader;
136   _is_shared = false;
137   _super = nullptr;
138   _java_mirror = nullptr;
139   _field_cache = nullptr;
140   _has_trusted_loader = compute_has_trusted_loader();
141 }
142 
143 
144 
145 // ------------------------------------------------------------------
146 // ciInstanceKlass::compute_shared_is_initialized
147 void ciInstanceKlass::compute_shared_init_state() {
148   GUARDED_VM_ENTRY(
149     InstanceKlass* ik = get_instanceKlass();
150     _init_state = compute_init_state(ik);
151   )
152 }
153 
154 InstanceKlass::ClassState ciInstanceKlass::compute_init_state(InstanceKlass* ik) {
155   ASSERT_IN_VM;
156   ciEnv* env = CURRENT_ENV;
157   if (env != nullptr && env->is_precompiled()) {
158     return env->compute_init_state_for_precompiled(ik);
159   } else {
160     return ik->init_state();
161   }
162 }
163 
164 // ------------------------------------------------------------------
165 // ciInstanceKlass::compute_shared_has_subklass
166 bool ciInstanceKlass::compute_shared_has_subklass() {
167   GUARDED_VM_ENTRY(
168     InstanceKlass* ik = get_instanceKlass();
169     _has_subklass = ik->subklass() != nullptr ? subklass_true : subklass_false;
170     return _has_subklass == subklass_true;
171   )
172 }
173 
174 // ------------------------------------------------------------------
175 // ciInstanceKlass::loader
176 oop ciInstanceKlass::loader() {
177   ASSERT_IN_VM;
178   return JNIHandles::resolve(_loader);
179 }
180 
181 // ------------------------------------------------------------------
182 // ciInstanceKlass::loader_handle
183 jobject ciInstanceKlass::loader_handle() {

319   if (name()->index_of_at(len+1, "/", 1) >= 0)
320     return false;
321 
322   return true;
323 }
324 
325 // ------------------------------------------------------------------
326 // ciInstanceKlass::print_impl
327 //
328 // Implementation of the print method.
329 void ciInstanceKlass::print_impl(outputStream* st) {
330   ciKlass::print_impl(st);
331   GUARDED_VM_ENTRY(st->print(" loader=" INTPTR_FORMAT, p2i(loader()));)
332   if (is_loaded()) {
333     st->print(" initialized=%s finalized=%s subklass=%s size=%d flags=",
334               bool_to_str(is_initialized()),
335               bool_to_str(has_finalizer()),
336               bool_to_str(has_subklass()),
337               layout_helper());
338 
339     _flags.print_klass_flags(st);
340 
341     if (_super) {
342       st->print(" super=");
343       _super->print_name_on(st);
344     }
345     if (_java_mirror) {
346       st->print(" mirror=PRESENT");
347     }
348   }
349 }
350 
351 // ------------------------------------------------------------------
352 // ciInstanceKlass::super
353 //
354 // Get the superklass of this klass.
355 ciInstanceKlass* ciInstanceKlass::super() {
356   assert(is_loaded(), "must be loaded");
357   if (_super == nullptr && !is_java_lang_Object()) {
358     GUARDED_VM_ENTRY(
359       Klass* super_klass = get_instanceKlass()->super();
360       _super = CURRENT_ENV->get_instance_klass(super_klass);
361     )
362   }
363   return _super;
< prev index next >