< prev index next >

src/hotspot/share/ci/ciInstanceKlass.cpp

Print this page




  46 // ------------------------------------------------------------------
  47 // ciInstanceKlass::ciInstanceKlass
  48 //
  49 // Loaded instance klass.
  50 ciInstanceKlass::ciInstanceKlass(Klass* k) :
  51   ciKlass(k)
  52 {
  53   assert(get_Klass()->is_instance_klass(), "wrong type");
  54   assert(get_instanceKlass()->is_loaded(), "must be at least loaded");
  55   InstanceKlass* ik = get_instanceKlass();
  56 
  57   AccessFlags access_flags = ik->access_flags();
  58   _flags = ciFlags(access_flags);
  59   _has_finalizer = access_flags.has_finalizer();
  60   _has_subklass = flags().is_final() ? subklass_false : subklass_unknown;
  61   _init_state = ik->init_state();
  62   _nonstatic_field_size = ik->nonstatic_field_size();
  63   _has_nonstatic_fields = ik->has_nonstatic_fields();
  64   _has_nonstatic_concrete_methods = ik->has_nonstatic_concrete_methods();
  65   _is_unsafe_anonymous = ik->is_unsafe_anonymous();

  66   _nonstatic_fields = NULL; // initialized lazily by compute_nonstatic_fields:
  67   _has_injected_fields = -1;
  68   _implementor = NULL; // we will fill these lazily
  69 
  70   // Ensure that the metadata wrapped by the ciMetadata is kept alive by GC.
  71   // This is primarily useful for metadata which is considered as weak roots
  72   // by the GC but need to be strong roots if reachable from a current compilation.
  73   // InstanceKlass are created for both weak and strong metadata.  Ensuring this metadata
  74   // alive covers the cases where there are weak roots without performance cost.
  75   oop holder = ik->klass_holder();
  76   if (ik->is_unsafe_anonymous()) {
  77     // Though ciInstanceKlass records class loader oop, it's not enough to keep
  78     // VM unsafe anonymous classes alive (loader == NULL). Klass holder should
  79     // be used instead. It is enough to record a ciObject, since cached elements are never removed
  80     // during ciObjectFactory lifetime. ciObjectFactory itself is created for
  81     // every compilation and lives for the whole duration of the compilation.
  82     assert(holder != NULL, "holder of unsafe anonymous class is the mirror which is never null");
  83     (void)CURRENT_ENV->get_object(holder);
  84   }
  85 
  86   Thread *thread = Thread::current();
  87   if (ciObjectFactory::is_initialized()) {
  88     _loader = JNIHandles::make_local(thread, ik->class_loader());
  89     _protection_domain = JNIHandles::make_local(thread,
  90                                                 ik->protection_domain());
  91     _is_shared = false;
  92   } else {
  93     Handle h_loader(thread, ik->class_loader());
  94     Handle h_protection_domain(thread, ik->protection_domain());
  95     _loader = JNIHandles::make_global(h_loader);
  96     _protection_domain = JNIHandles::make_global(h_protection_domain);
  97     _is_shared = true;
  98   }
  99 
 100   // Lazy fields get filled in only upon request.
 101   _super  = NULL;
 102   _java_mirror = NULL;


 106       super();
 107     }
 108     //compute_nonstatic_fields();  // done outside of constructor
 109   }
 110 
 111   _field_cache = NULL;
 112 }
 113 
 114 // Version for unloaded classes:
 115 ciInstanceKlass::ciInstanceKlass(ciSymbol* name,
 116                                  jobject loader, jobject protection_domain)
 117   : ciKlass(name, T_OBJECT)
 118 {
 119   assert(name->char_at(0) != '[', "not an instance klass");
 120   _init_state = (InstanceKlass::ClassState)0;
 121   _nonstatic_field_size = -1;
 122   _has_nonstatic_fields = false;
 123   _nonstatic_fields = NULL;
 124   _has_injected_fields = -1;
 125   _is_unsafe_anonymous = false;

 126   _loader = loader;
 127   _protection_domain = protection_domain;
 128   _is_shared = false;
 129   _super = NULL;
 130   _java_mirror = NULL;
 131   _field_cache = NULL;
 132 }
 133 
 134 
 135 
 136 // ------------------------------------------------------------------
 137 // ciInstanceKlass::compute_shared_is_initialized
 138 void ciInstanceKlass::compute_shared_init_state() {
 139   GUARDED_VM_ENTRY(
 140     InstanceKlass* ik = get_instanceKlass();
 141     _init_state = ik->init_state();
 142   )
 143 }
 144 
 145 // ------------------------------------------------------------------




  46 // ------------------------------------------------------------------
  47 // ciInstanceKlass::ciInstanceKlass
  48 //
  49 // Loaded instance klass.
  50 ciInstanceKlass::ciInstanceKlass(Klass* k) :
  51   ciKlass(k)
  52 {
  53   assert(get_Klass()->is_instance_klass(), "wrong type");
  54   assert(get_instanceKlass()->is_loaded(), "must be at least loaded");
  55   InstanceKlass* ik = get_instanceKlass();
  56 
  57   AccessFlags access_flags = ik->access_flags();
  58   _flags = ciFlags(access_flags);
  59   _has_finalizer = access_flags.has_finalizer();
  60   _has_subklass = flags().is_final() ? subklass_false : subklass_unknown;
  61   _init_state = ik->init_state();
  62   _nonstatic_field_size = ik->nonstatic_field_size();
  63   _has_nonstatic_fields = ik->has_nonstatic_fields();
  64   _has_nonstatic_concrete_methods = ik->has_nonstatic_concrete_methods();
  65   _is_unsafe_anonymous = ik->is_unsafe_anonymous();
  66   _is_nonfindable = ik->is_nonfindable();
  67   _nonstatic_fields = NULL; // initialized lazily by compute_nonstatic_fields:
  68   _has_injected_fields = -1;
  69   _implementor = NULL; // we will fill these lazily
  70 
  71   // Ensure that the metadata wrapped by the ciMetadata is kept alive by GC.
  72   // This is primarily useful for metadata which is considered as weak roots
  73   // by the GC but need to be strong roots if reachable from a current compilation.
  74   // InstanceKlass are created for both weak and strong metadata.  Ensuring this metadata
  75   // alive covers the cases where there are weak roots without performance cost.
  76   oop holder = ik->klass_holder();
  77   if (ik->class_loader_data()->is_shortlived()) {
  78     // Though ciInstanceKlass records class loader oop, it's not enough to keep
  79     // VM weak nonfindable and unsafe anonymous classes alive (loader == NULL). Klass holder should
  80     // be used instead. It is enough to record a ciObject, since cached elements are never removed
  81     // during ciObjectFactory lifetime. ciObjectFactory itself is created for
  82     // every compilation and lives for the whole duration of the compilation.
  83     assert(holder != NULL, "holder of nonfindable or unsafe anonymous class is the mirror which is never null");
  84     (void)CURRENT_ENV->get_object(holder);
  85   }
  86 
  87   Thread *thread = Thread::current();
  88   if (ciObjectFactory::is_initialized()) {
  89     _loader = JNIHandles::make_local(thread, ik->class_loader());
  90     _protection_domain = JNIHandles::make_local(thread,
  91                                                 ik->protection_domain());
  92     _is_shared = false;
  93   } else {
  94     Handle h_loader(thread, ik->class_loader());
  95     Handle h_protection_domain(thread, ik->protection_domain());
  96     _loader = JNIHandles::make_global(h_loader);
  97     _protection_domain = JNIHandles::make_global(h_protection_domain);
  98     _is_shared = true;
  99   }
 100 
 101   // Lazy fields get filled in only upon request.
 102   _super  = NULL;
 103   _java_mirror = NULL;


 107       super();
 108     }
 109     //compute_nonstatic_fields();  // done outside of constructor
 110   }
 111 
 112   _field_cache = NULL;
 113 }
 114 
 115 // Version for unloaded classes:
 116 ciInstanceKlass::ciInstanceKlass(ciSymbol* name,
 117                                  jobject loader, jobject protection_domain)
 118   : ciKlass(name, T_OBJECT)
 119 {
 120   assert(name->char_at(0) != '[', "not an instance klass");
 121   _init_state = (InstanceKlass::ClassState)0;
 122   _nonstatic_field_size = -1;
 123   _has_nonstatic_fields = false;
 124   _nonstatic_fields = NULL;
 125   _has_injected_fields = -1;
 126   _is_unsafe_anonymous = false;
 127   _is_nonfindable = false;
 128   _loader = loader;
 129   _protection_domain = protection_domain;
 130   _is_shared = false;
 131   _super = NULL;
 132   _java_mirror = NULL;
 133   _field_cache = NULL;
 134 }
 135 
 136 
 137 
 138 // ------------------------------------------------------------------
 139 // ciInstanceKlass::compute_shared_is_initialized
 140 void ciInstanceKlass::compute_shared_init_state() {
 141   GUARDED_VM_ENTRY(
 142     InstanceKlass* ik = get_instanceKlass();
 143     _init_state = ik->init_state();
 144   )
 145 }
 146 
 147 // ------------------------------------------------------------------


< prev index next >