< prev index next >

src/hotspot/share/ci/ciInstanceKlass.cpp

Print this page

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








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

128   _nonstatic_fields = nullptr;
129   _has_injected_fields = -1;
130   _is_hidden = false;
131   _is_record = false;
132   _loader = loader;
133   _protection_domain = protection_domain;
134   _is_shared = false;
135   _super = nullptr;
136   _java_mirror = nullptr;
137   _field_cache = nullptr;
138   _has_trusted_loader = compute_has_trusted_loader();
139 }
140 
141 
142 
143 // ------------------------------------------------------------------
144 // ciInstanceKlass::compute_shared_is_initialized
145 void ciInstanceKlass::compute_shared_init_state() {
146   GUARDED_VM_ENTRY(
147     InstanceKlass* ik = get_instanceKlass();
148     _init_state = ik->init_state();
149   )
150 }
151 










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

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

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

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

338   if (name()->index_of_at(len+1, "/", 1) >= 0)
339     return false;
340 
341   return true;
342 }
343 
344 // ------------------------------------------------------------------
345 // ciInstanceKlass::print_impl
346 //
347 // Implementation of the print method.
348 void ciInstanceKlass::print_impl(outputStream* st) {
349   ciKlass::print_impl(st);
350   GUARDED_VM_ENTRY(st->print(" loader=" INTPTR_FORMAT, p2i(loader()));)
351   if (is_loaded()) {
352     st->print(" initialized=%s finalized=%s subklass=%s size=%d flags=",
353               bool_to_str(is_initialized()),
354               bool_to_str(has_finalizer()),
355               bool_to_str(has_subklass()),
356               layout_helper());
357 
358     _flags.print_klass_flags(st);
359 
360     if (_super) {
361       st->print(" super=");
362       _super->print_name_on(st);
363     }
364     if (_java_mirror) {
365       st->print(" mirror=PRESENT");
366     }
367   }
368 }
369 
370 // ------------------------------------------------------------------
371 // ciInstanceKlass::super
372 //
373 // Get the superklass of this klass.
374 ciInstanceKlass* ciInstanceKlass::super() {
375   assert(is_loaded(), "must be loaded");
376   if (_super == nullptr && !is_java_lang_Object()) {
377     GUARDED_VM_ENTRY(
378       Klass* super_klass = get_instanceKlass()->super();
379       _super = CURRENT_ENV->get_instance_klass(super_klass);
380     )
381   }
382   return _super;
< prev index next >