< prev index next >

src/hotspot/share/ci/ciInstanceKlass.cpp

Print this page
rev 53567 : [mq]: shjdk11-hasobjfields2.patch


  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 = ik->subklass() != NULL;
  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_anonymous = ik->is_anonymous();
  66   _nonstatic_fields = NULL; // initialized lazily by compute_nonstatic_fields:
  67   _has_injected_fields = -1;
  68   _has_object_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->holder_phantom();
  77   if (ik->is_anonymous()) {
  78     // Though ciInstanceKlass records class loader oop, it's not enough to keep
  79     // VM anonymous classes alive (loader == NULL). Klass holder should be used instead.
  80     // 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 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()) {


 106     if (k != SystemDictionary::Object_klass()) {
 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->byte_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   _has_object_fields = -1;
 127   _is_anonymous = 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 


 539   }
 540   return false;
 541 }
 542 
 543 void ciInstanceKlass::compute_injected_fields() {
 544   assert(is_loaded(), "must be loaded");
 545 
 546   int has_injected_fields = 0;
 547   if (super() != NULL && super()->has_injected_fields()) {
 548     has_injected_fields = 1;
 549   } else {
 550     GUARDED_VM_ENTRY({
 551         has_injected_fields = compute_injected_fields_helper() ? 1 : 0;
 552       });
 553   }
 554   // may be concurrently initialized for shared ciInstanceKlass objects
 555   assert(_has_injected_fields == -1 || _has_injected_fields == has_injected_fields, "broken concurrent initialization");
 556   _has_injected_fields = has_injected_fields;
 557 }
 558 
 559 void ciInstanceKlass::compute_object_fields() {
 560   for (int i = 0; i < nof_nonstatic_fields(); i++) {
 561     ciField* f = nonstatic_field_at(i);
 562     if (f->layout_type() == T_OBJECT) {
 563       assert(_has_object_fields == -1 || _has_object_fields == 1, "broken concurrent initialization");
 564       _has_object_fields = 1;
 565       return;
 566     }
 567   }
 568   assert(_has_object_fields == -1 || _has_object_fields == 0, "broken concurrent initialization");
 569   _has_object_fields = 0;
 570 }
 571 
 572 // ------------------------------------------------------------------
 573 // ciInstanceKlass::find_method
 574 //
 575 // Find a method in this klass.
 576 ciMethod* ciInstanceKlass::find_method(ciSymbol* name, ciSymbol* signature) {
 577   VM_ENTRY_MARK;
 578   InstanceKlass* k = get_instanceKlass();
 579   Symbol* name_sym = name->get_symbol();
 580   Symbol* sig_sym= signature->get_symbol();
 581 
 582   Method* m = k->find_method(name_sym, sig_sym);
 583   if (m == NULL)  return NULL;
 584 
 585   return CURRENT_THREAD_ENV->get_method(m);
 586 }
 587 
 588 // ------------------------------------------------------------------
 589 // ciInstanceKlass::is_leaf_type




  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 = ik->subklass() != NULL;
  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_anonymous = ik->is_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->holder_phantom();
  76   if (ik->is_anonymous()) {
  77     // Though ciInstanceKlass records class loader oop, it's not enough to keep
  78     // VM anonymous classes alive (loader == NULL). Klass holder should be used instead.
  79     // 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 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()) {


 105     if (k != SystemDictionary::Object_klass()) {
 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->byte_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_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 


 537   }
 538   return false;
 539 }
 540 
 541 void ciInstanceKlass::compute_injected_fields() {
 542   assert(is_loaded(), "must be loaded");
 543 
 544   int has_injected_fields = 0;
 545   if (super() != NULL && super()->has_injected_fields()) {
 546     has_injected_fields = 1;
 547   } else {
 548     GUARDED_VM_ENTRY({
 549         has_injected_fields = compute_injected_fields_helper() ? 1 : 0;
 550       });
 551   }
 552   // may be concurrently initialized for shared ciInstanceKlass objects
 553   assert(_has_injected_fields == -1 || _has_injected_fields == has_injected_fields, "broken concurrent initialization");
 554   _has_injected_fields = has_injected_fields;
 555 }
 556 
 557 bool ciInstanceKlass::has_object_fields() const {
 558   GUARDED_VM_ENTRY(
 559       return get_instanceKlass()->nonstatic_oop_map_size() > 0;
 560     );







 561 }
 562 
 563 // ------------------------------------------------------------------
 564 // ciInstanceKlass::find_method
 565 //
 566 // Find a method in this klass.
 567 ciMethod* ciInstanceKlass::find_method(ciSymbol* name, ciSymbol* signature) {
 568   VM_ENTRY_MARK;
 569   InstanceKlass* k = get_instanceKlass();
 570   Symbol* name_sym = name->get_symbol();
 571   Symbol* sig_sym= signature->get_symbol();
 572 
 573   Method* m = k->find_method(name_sym, sig_sym);
 574   if (m == NULL)  return NULL;
 575 
 576   return CURRENT_THREAD_ENV->get_method(m);
 577 }
 578 
 579 // ------------------------------------------------------------------
 580 // ciInstanceKlass::is_leaf_type


< prev index next >