src/share/vm/ci/ciInstanceKlass.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/ci

src/share/vm/ci/ciInstanceKlass.cpp

Print this page
rev 7268 : 6700100: optimize inline_native_clone() for small objects with exact klass
Summary: optimize small instance clones as loads/stores
Reviewed-by:


  42 // ------------------------------------------------------------------
  43 // ciInstanceKlass::ciInstanceKlass
  44 //
  45 // Loaded instance klass.
  46 ciInstanceKlass::ciInstanceKlass(KlassHandle h_k) :
  47   ciKlass(h_k)
  48 {
  49   assert(get_Klass()->oop_is_instance(), "wrong type");
  50   assert(get_instanceKlass()->is_loaded(), "must be at least loaded");
  51   InstanceKlass* ik = get_instanceKlass();
  52 
  53   AccessFlags access_flags = ik->access_flags();
  54   _flags = ciFlags(access_flags);
  55   _has_finalizer = access_flags.has_finalizer();
  56   _has_subklass = ik->subklass() != NULL;
  57   _init_state = ik->init_state();
  58   _nonstatic_field_size = ik->nonstatic_field_size();
  59   _has_nonstatic_fields = ik->has_nonstatic_fields();
  60   _has_default_methods = ik->has_default_methods();
  61   _nonstatic_fields = NULL; // initialized lazily by compute_nonstatic_fields:
  62 
  63   _implementor = NULL; // we will fill these lazily
  64 
  65   Thread *thread = Thread::current();
  66   if (ciObjectFactory::is_initialized()) {
  67     _loader = JNIHandles::make_local(thread, ik->class_loader());
  68     _protection_domain = JNIHandles::make_local(thread,
  69                                                 ik->protection_domain());
  70     _is_shared = false;
  71   } else {
  72     Handle h_loader(thread, ik->class_loader());
  73     Handle h_protection_domain(thread, ik->protection_domain());
  74     _loader = JNIHandles::make_global(h_loader);
  75     _protection_domain = JNIHandles::make_global(h_protection_domain);
  76     _is_shared = true;
  77   }
  78 
  79   // Lazy fields get filled in only upon request.
  80   _super  = NULL;
  81   _java_mirror = NULL;
  82 
  83   if (is_shared()) {
  84     if (h_k() != SystemDictionary::Object_klass()) {
  85       super();
  86     }
  87     //compute_nonstatic_fields();  // done outside of constructor
  88   }
  89 
  90   _field_cache = NULL;
  91 }
  92 
  93 // Version for unloaded classes:
  94 ciInstanceKlass::ciInstanceKlass(ciSymbol* name,
  95                                  jobject loader, jobject protection_domain)
  96   : ciKlass(name, T_OBJECT)
  97 {
  98   assert(name->byte_at(0) != '[', "not an instance klass");
  99   _init_state = (InstanceKlass::ClassState)0;
 100   _nonstatic_field_size = -1;
 101   _has_nonstatic_fields = false;
 102   _nonstatic_fields = NULL;

 103   _loader = loader;
 104   _protection_domain = protection_domain;
 105   _is_shared = false;
 106   _super = NULL;
 107   _java_mirror = NULL;
 108   _field_cache = NULL;
 109 }
 110 
 111 
 112 
 113 // ------------------------------------------------------------------
 114 // ciInstanceKlass::compute_shared_is_initialized
 115 void ciInstanceKlass::compute_shared_init_state() {
 116   GUARDED_VM_ENTRY(
 117     InstanceKlass* ik = get_instanceKlass();
 118     _init_state = ik->init_state();
 119   )
 120 }
 121 
 122 // ------------------------------------------------------------------


 481   // allocate the array:
 482   if (flen == 0) {
 483     return NULL;  // return nothing if none are locally declared
 484   }
 485   if (super_fields != NULL) {
 486     flen += super_fields->length();
 487   }
 488   fields = new (arena) GrowableArray<ciField*>(arena, flen, 0, NULL);
 489   if (super_fields != NULL) {
 490     fields->appendAll(super_fields);
 491   }
 492 
 493   for (JavaFieldStream fs(k); !fs.done(); fs.next()) {
 494     if (fs.access_flags().is_static())  continue;
 495     fieldDescriptor& fd = fs.field_descriptor();
 496     ciField* field = new (arena) ciField(&fd);
 497     fields->append(field);
 498   }
 499   assert(fields->length() == flen, "sanity");
 500   return fields;




























 501 }
 502 
 503 // ------------------------------------------------------------------
 504 // ciInstanceKlass::find_method
 505 //
 506 // Find a method in this klass.
 507 ciMethod* ciInstanceKlass::find_method(ciSymbol* name, ciSymbol* signature) {
 508   VM_ENTRY_MARK;
 509   InstanceKlass* k = get_instanceKlass();
 510   Symbol* name_sym = name->get_symbol();
 511   Symbol* sig_sym= signature->get_symbol();
 512 
 513   Method* m = k->find_method(name_sym, sig_sym);
 514   if (m == NULL)  return NULL;
 515 
 516   return CURRENT_THREAD_ENV->get_method(m);
 517 }
 518 
 519 // ------------------------------------------------------------------
 520 // ciInstanceKlass::is_leaf_type




  42 // ------------------------------------------------------------------
  43 // ciInstanceKlass::ciInstanceKlass
  44 //
  45 // Loaded instance klass.
  46 ciInstanceKlass::ciInstanceKlass(KlassHandle h_k) :
  47   ciKlass(h_k)
  48 {
  49   assert(get_Klass()->oop_is_instance(), "wrong type");
  50   assert(get_instanceKlass()->is_loaded(), "must be at least loaded");
  51   InstanceKlass* ik = get_instanceKlass();
  52 
  53   AccessFlags access_flags = ik->access_flags();
  54   _flags = ciFlags(access_flags);
  55   _has_finalizer = access_flags.has_finalizer();
  56   _has_subklass = ik->subklass() != NULL;
  57   _init_state = ik->init_state();
  58   _nonstatic_field_size = ik->nonstatic_field_size();
  59   _has_nonstatic_fields = ik->has_nonstatic_fields();
  60   _has_default_methods = ik->has_default_methods();
  61   _nonstatic_fields = NULL; // initialized lazily by compute_nonstatic_fields:
  62   _has_injected_fields = -1;
  63   _implementor = NULL; // we will fill these lazily
  64 
  65   Thread *thread = Thread::current();
  66   if (ciObjectFactory::is_initialized()) {
  67     _loader = JNIHandles::make_local(thread, ik->class_loader());
  68     _protection_domain = JNIHandles::make_local(thread,
  69                                                 ik->protection_domain());
  70     _is_shared = false;
  71   } else {
  72     Handle h_loader(thread, ik->class_loader());
  73     Handle h_protection_domain(thread, ik->protection_domain());
  74     _loader = JNIHandles::make_global(h_loader);
  75     _protection_domain = JNIHandles::make_global(h_protection_domain);
  76     _is_shared = true;
  77   }
  78 
  79   // Lazy fields get filled in only upon request.
  80   _super  = NULL;
  81   _java_mirror = NULL;
  82 
  83   if (is_shared()) {
  84     if (h_k() != SystemDictionary::Object_klass()) {
  85       super();
  86     }
  87     //compute_nonstatic_fields();  // done outside of constructor
  88   }
  89 
  90   _field_cache = NULL;
  91 }
  92 
  93 // Version for unloaded classes:
  94 ciInstanceKlass::ciInstanceKlass(ciSymbol* name,
  95                                  jobject loader, jobject protection_domain)
  96   : ciKlass(name, T_OBJECT)
  97 {
  98   assert(name->byte_at(0) != '[', "not an instance klass");
  99   _init_state = (InstanceKlass::ClassState)0;
 100   _nonstatic_field_size = -1;
 101   _has_nonstatic_fields = false;
 102   _nonstatic_fields = NULL;
 103   _has_injected_fields = -1;
 104   _loader = loader;
 105   _protection_domain = protection_domain;
 106   _is_shared = false;
 107   _super = NULL;
 108   _java_mirror = NULL;
 109   _field_cache = NULL;
 110 }
 111 
 112 
 113 
 114 // ------------------------------------------------------------------
 115 // ciInstanceKlass::compute_shared_is_initialized
 116 void ciInstanceKlass::compute_shared_init_state() {
 117   GUARDED_VM_ENTRY(
 118     InstanceKlass* ik = get_instanceKlass();
 119     _init_state = ik->init_state();
 120   )
 121 }
 122 
 123 // ------------------------------------------------------------------


 482   // allocate the array:
 483   if (flen == 0) {
 484     return NULL;  // return nothing if none are locally declared
 485   }
 486   if (super_fields != NULL) {
 487     flen += super_fields->length();
 488   }
 489   fields = new (arena) GrowableArray<ciField*>(arena, flen, 0, NULL);
 490   if (super_fields != NULL) {
 491     fields->appendAll(super_fields);
 492   }
 493 
 494   for (JavaFieldStream fs(k); !fs.done(); fs.next()) {
 495     if (fs.access_flags().is_static())  continue;
 496     fieldDescriptor& fd = fs.field_descriptor();
 497     ciField* field = new (arena) ciField(&fd);
 498     fields->append(field);
 499   }
 500   assert(fields->length() == flen, "sanity");
 501   return fields;
 502 }
 503 
 504 void ciInstanceKlass::compute_injected_fields_helper() {
 505   ASSERT_IN_VM;
 506   InstanceKlass* k = get_instanceKlass();
 507   
 508   for (InternalFieldStream fs(k); !fs.done(); fs.next()) {
 509     if (fs.access_flags().is_static())  continue;
 510     _has_injected_fields++;
 511     break;
 512   }
 513 }
 514 
 515 bool ciInstanceKlass::compute_injected_fields() {
 516   assert(_has_injected_fields == -1, "shouldn't be initialized yet");
 517   assert(is_loaded(), "must be loaded");
 518   
 519   if (super() != NULL && super()->has_injected_fields()) {
 520     _has_injected_fields = 1;
 521     return true;
 522   }
 523   
 524   _has_injected_fields = 0;
 525   GUARDED_VM_ENTRY({
 526       compute_injected_fields_helper();
 527     });
 528 
 529   return _has_injected_fields > 0 ? true : false;
 530 }
 531 
 532 // ------------------------------------------------------------------
 533 // ciInstanceKlass::find_method
 534 //
 535 // Find a method in this klass.
 536 ciMethod* ciInstanceKlass::find_method(ciSymbol* name, ciSymbol* signature) {
 537   VM_ENTRY_MARK;
 538   InstanceKlass* k = get_instanceKlass();
 539   Symbol* name_sym = name->get_symbol();
 540   Symbol* sig_sym= signature->get_symbol();
 541 
 542   Method* m = k->find_method(name_sym, sig_sym);
 543   if (m == NULL)  return NULL;
 544 
 545   return CURRENT_THREAD_ENV->get_method(m);
 546 }
 547 
 548 // ------------------------------------------------------------------
 549 // ciInstanceKlass::is_leaf_type


src/share/vm/ci/ciInstanceKlass.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File