< prev index next >

src/share/vm/ci/ciInstanceKlass.cpp

Print this page




  27 #include "ci/ciInstance.hpp"
  28 #include "ci/ciInstanceKlass.hpp"
  29 #include "ci/ciUtilities.hpp"
  30 #include "classfile/systemDictionary.hpp"
  31 #include "memory/allocation.hpp"
  32 #include "memory/allocation.inline.hpp"
  33 #include "memory/resourceArea.hpp"
  34 #include "oops/oop.inline.hpp"
  35 #include "oops/fieldStreams.hpp"
  36 #include "runtime/fieldDescriptor.hpp"
  37 
  38 // ciInstanceKlass
  39 //
  40 // This class represents a Klass* in the HotSpot virtual machine
  41 // whose Klass part in an InstanceKlass.
  42 
  43 // ------------------------------------------------------------------
  44 // ciInstanceKlass::ciInstanceKlass
  45 //
  46 // Loaded instance klass.
  47 ciInstanceKlass::ciInstanceKlass(KlassHandle h_k) :
  48   ciKlass(h_k)
  49 {
  50   assert(get_Klass()->is_instance_klass(), "wrong type");
  51   assert(get_instanceKlass()->is_loaded(), "must be at least loaded");
  52   InstanceKlass* ik = get_instanceKlass();
  53 
  54   AccessFlags access_flags = ik->access_flags();
  55   _flags = ciFlags(access_flags);
  56   _has_finalizer = access_flags.has_finalizer();
  57   _has_subklass = ik->subklass() != NULL;
  58   _init_state = ik->init_state();
  59   _nonstatic_field_size = ik->nonstatic_field_size();
  60   _has_nonstatic_fields = ik->has_nonstatic_fields();
  61   _has_nonstatic_concrete_methods = ik->has_nonstatic_concrete_methods();
  62   _is_anonymous = ik->is_anonymous();
  63   _nonstatic_fields = NULL; // initialized lazily by compute_nonstatic_fields:
  64   _has_injected_fields = -1;
  65   _implementor = NULL; // we will fill these lazily
  66 
  67   Thread *thread = Thread::current();
  68   if (ciObjectFactory::is_initialized()) {
  69     _loader = JNIHandles::make_local(thread, ik->class_loader());
  70     _protection_domain = JNIHandles::make_local(thread,
  71                                                 ik->protection_domain());
  72     _is_shared = false;
  73   } else {
  74     Handle h_loader(thread, ik->class_loader());
  75     Handle h_protection_domain(thread, ik->protection_domain());
  76     _loader = JNIHandles::make_global(h_loader);
  77     _protection_domain = JNIHandles::make_global(h_protection_domain);
  78     _is_shared = true;
  79   }
  80 
  81   // Lazy fields get filled in only upon request.
  82   _super  = NULL;
  83   _java_mirror = NULL;
  84 
  85   if (is_shared()) {
  86     if (h_k() != SystemDictionary::Object_klass()) {
  87       super();
  88     }
  89     //compute_nonstatic_fields();  // done outside of constructor
  90   }
  91 
  92   _field_cache = NULL;
  93 }
  94 
  95 // Version for unloaded classes:
  96 ciInstanceKlass::ciInstanceKlass(ciSymbol* name,
  97                                  jobject loader, jobject protection_domain)
  98   : ciKlass(name, T_OBJECT)
  99 {
 100   assert(name->byte_at(0) != '[', "not an instance klass");
 101   _init_state = (InstanceKlass::ClassState)0;
 102   _nonstatic_field_size = -1;
 103   _has_nonstatic_fields = false;
 104   _nonstatic_fields = NULL;
 105   _has_injected_fields = -1;
 106   _is_anonymous = false;




  27 #include "ci/ciInstance.hpp"
  28 #include "ci/ciInstanceKlass.hpp"
  29 #include "ci/ciUtilities.hpp"
  30 #include "classfile/systemDictionary.hpp"
  31 #include "memory/allocation.hpp"
  32 #include "memory/allocation.inline.hpp"
  33 #include "memory/resourceArea.hpp"
  34 #include "oops/oop.inline.hpp"
  35 #include "oops/fieldStreams.hpp"
  36 #include "runtime/fieldDescriptor.hpp"
  37 
  38 // ciInstanceKlass
  39 //
  40 // This class represents a Klass* in the HotSpot virtual machine
  41 // whose Klass part in an InstanceKlass.
  42 
  43 // ------------------------------------------------------------------
  44 // ciInstanceKlass::ciInstanceKlass
  45 //
  46 // Loaded instance klass.
  47 ciInstanceKlass::ciInstanceKlass(Klass* k) :
  48   ciKlass(k)
  49 {
  50   assert(get_Klass()->is_instance_klass(), "wrong type");
  51   assert(get_instanceKlass()->is_loaded(), "must be at least loaded");
  52   InstanceKlass* ik = get_instanceKlass();
  53 
  54   AccessFlags access_flags = ik->access_flags();
  55   _flags = ciFlags(access_flags);
  56   _has_finalizer = access_flags.has_finalizer();
  57   _has_subklass = ik->subklass() != NULL;
  58   _init_state = ik->init_state();
  59   _nonstatic_field_size = ik->nonstatic_field_size();
  60   _has_nonstatic_fields = ik->has_nonstatic_fields();
  61   _has_nonstatic_concrete_methods = ik->has_nonstatic_concrete_methods();
  62   _is_anonymous = ik->is_anonymous();
  63   _nonstatic_fields = NULL; // initialized lazily by compute_nonstatic_fields:
  64   _has_injected_fields = -1;
  65   _implementor = NULL; // we will fill these lazily
  66 
  67   Thread *thread = Thread::current();
  68   if (ciObjectFactory::is_initialized()) {
  69     _loader = JNIHandles::make_local(thread, ik->class_loader());
  70     _protection_domain = JNIHandles::make_local(thread,
  71                                                 ik->protection_domain());
  72     _is_shared = false;
  73   } else {
  74     Handle h_loader(thread, ik->class_loader());
  75     Handle h_protection_domain(thread, ik->protection_domain());
  76     _loader = JNIHandles::make_global(h_loader);
  77     _protection_domain = JNIHandles::make_global(h_protection_domain);
  78     _is_shared = true;
  79   }
  80 
  81   // Lazy fields get filled in only upon request.
  82   _super  = NULL;
  83   _java_mirror = NULL;
  84 
  85   if (is_shared()) {
  86     if (k != SystemDictionary::Object_klass()) {
  87       super();
  88     }
  89     //compute_nonstatic_fields();  // done outside of constructor
  90   }
  91 
  92   _field_cache = NULL;
  93 }
  94 
  95 // Version for unloaded classes:
  96 ciInstanceKlass::ciInstanceKlass(ciSymbol* name,
  97                                  jobject loader, jobject protection_domain)
  98   : ciKlass(name, T_OBJECT)
  99 {
 100   assert(name->byte_at(0) != '[', "not an instance klass");
 101   _init_state = (InstanceKlass::ClassState)0;
 102   _nonstatic_field_size = -1;
 103   _has_nonstatic_fields = false;
 104   _nonstatic_fields = NULL;
 105   _has_injected_fields = -1;
 106   _is_anonymous = false;


< prev index next >