src/hotspot/share/ci/ciObjectFactory.cpp
branchdatagramsocketimpl-branch
changeset 58678 9cf78a70fa4f
parent 54786 ebf733a324d4
child 58679 9c3209ff7550
equal deleted inserted replaced
58677:13588c901957 58678:9cf78a70fa4f
   147 
   147 
   148   _ci_metadata = new (_arena) GrowableArray<ciMetadata*>(_arena, 64, 0, NULL);
   148   _ci_metadata = new (_arena) GrowableArray<ciMetadata*>(_arena, 64, 0, NULL);
   149 
   149 
   150   for (int i = T_BOOLEAN; i <= T_CONFLICT; i++) {
   150   for (int i = T_BOOLEAN; i <= T_CONFLICT; i++) {
   151     BasicType t = (BasicType)i;
   151     BasicType t = (BasicType)i;
   152     if (type2name(t) != NULL && t != T_OBJECT && t != T_ARRAY && t != T_NARROWOOP && t != T_NARROWKLASS) {
   152     if (type2name(t) != NULL && !is_reference_type(t) &&
       
   153         t != T_NARROWOOP && t != T_NARROWKLASS) {
   153       ciType::_basic_types[t] = new (_arena) ciType(t);
   154       ciType::_basic_types[t] = new (_arena) ciType(t);
   154       init_ident_of(ciType::_basic_types[t]);
   155       init_ident_of(ciType::_basic_types[t]);
   155     }
   156     }
   156   }
   157   }
   157 
   158 
   237 // already been created, it is returned.  Otherwise, a new ciObject
   238 // already been created, it is returned.  Otherwise, a new ciObject
   238 // is created.
   239 // is created.
   239 ciObject* ciObjectFactory::get(oop key) {
   240 ciObject* ciObjectFactory::get(oop key) {
   240   ASSERT_IN_VM;
   241   ASSERT_IN_VM;
   241 
   242 
   242   assert(Universe::heap()->is_in_reserved(key), "must be");
   243   assert(Universe::heap()->is_in(key), "must be");
   243 
   244 
   244   NonPermObject* &bucket = find_non_perm(key);
   245   NonPermObject* &bucket = find_non_perm(key);
   245   if (bucket != NULL) {
   246   if (bucket != NULL) {
   246     return bucket->object();
   247     return bucket->object();
   247   }
   248   }
   248 
   249 
   249   // The ciObject does not yet exist.  Create it and insert it
   250   // The ciObject does not yet exist.  Create it and insert it
   250   // into the cache.
   251   // into the cache.
   251   Handle keyHandle(Thread::current(), key);
   252   Handle keyHandle(Thread::current(), key);
   252   ciObject* new_object = create_new_object(keyHandle());
   253   ciObject* new_object = create_new_object(keyHandle());
   253   assert(oopDesc::equals(keyHandle(), new_object->get_oop()), "must be properly recorded");
   254   assert(keyHandle() == new_object->get_oop(), "must be properly recorded");
   254   init_ident_of(new_object);
   255   init_ident_of(new_object);
   255   assert(Universe::heap()->is_in_reserved(new_object->get_oop()), "must be");
   256   assert(Universe::heap()->is_in(new_object->get_oop()), "must be");
   256 
   257 
   257   // Not a perm-space object.
   258   // Not a perm-space object.
   258   insert_non_perm(bucket, keyHandle(), new_object);
   259   insert_non_perm(bucket, keyHandle(), new_object);
   259   return new_object;
   260   return new_object;
   260 }
   261 }
   467     domain = accessing_klass->protection_domain();
   468     domain = accessing_klass->protection_domain();
   468   }
   469   }
   469   for (int i=0; i<_unloaded_klasses->length(); i++) {
   470   for (int i=0; i<_unloaded_klasses->length(); i++) {
   470     ciKlass* entry = _unloaded_klasses->at(i);
   471     ciKlass* entry = _unloaded_klasses->at(i);
   471     if (entry->name()->equals(name) &&
   472     if (entry->name()->equals(name) &&
   472         oopDesc::equals(entry->loader(), loader) &&
   473         entry->loader() == loader &&
   473         oopDesc::equals(entry->protection_domain(), domain)) {
   474         entry->protection_domain() == domain) {
   474       // We've found a match.
   475       // We've found a match.
   475       return entry;
   476       return entry;
   476     }
   477     }
   477   }
   478   }
   478 
   479 
   642 //
   643 //
   643 // Use a small hash table, hashed on the klass of the key.
   644 // Use a small hash table, hashed on the klass of the key.
   644 // If there is no entry in the cache corresponding to this oop, return
   645 // If there is no entry in the cache corresponding to this oop, return
   645 // the null tail of the bucket into which the oop should be inserted.
   646 // the null tail of the bucket into which the oop should be inserted.
   646 ciObjectFactory::NonPermObject* &ciObjectFactory::find_non_perm(oop key) {
   647 ciObjectFactory::NonPermObject* &ciObjectFactory::find_non_perm(oop key) {
   647   assert(Universe::heap()->is_in_reserved(key), "must be");
   648   assert(Universe::heap()->is_in(key), "must be");
   648   ciMetadata* klass = get_metadata(key->klass());
   649   ciMetadata* klass = get_metadata(key->klass());
   649   NonPermObject* *bp = &_non_perm_bucket[(unsigned) klass->hash() % NON_PERM_BUCKETS];
   650   NonPermObject* *bp = &_non_perm_bucket[(unsigned) klass->hash() % NON_PERM_BUCKETS];
   650   for (NonPermObject* p; (p = (*bp)) != NULL; bp = &p->next()) {
   651   for (NonPermObject* p; (p = (*bp)) != NULL; bp = &p->next()) {
   651     if (is_equal(p, key))  break;
   652     if (is_equal(p, key))  break;
   652   }
   653   }
   670 // ------------------------------------------------------------------
   671 // ------------------------------------------------------------------
   671 // ciObjectFactory::insert_non_perm
   672 // ciObjectFactory::insert_non_perm
   672 //
   673 //
   673 // Insert a ciObject into the non-perm table.
   674 // Insert a ciObject into the non-perm table.
   674 void ciObjectFactory::insert_non_perm(ciObjectFactory::NonPermObject* &where, oop key, ciObject* obj) {
   675 void ciObjectFactory::insert_non_perm(ciObjectFactory::NonPermObject* &where, oop key, ciObject* obj) {
   675   assert(Universe::heap()->is_in_reserved_or_null(key), "must be");
   676   assert(Universe::heap()->is_in_or_null(key), "must be");
   676   assert(&where != &emptyBucket, "must not try to fill empty bucket");
   677   assert(&where != &emptyBucket, "must not try to fill empty bucket");
   677   NonPermObject* p = new (arena()) NonPermObject(where, key, obj);
   678   NonPermObject* p = new (arena()) NonPermObject(where, key, obj);
   678   assert(where == p && is_equal(p, key) && p->object() == obj, "entry must match");
   679   assert(where == p && is_equal(p, key) && p->object() == obj, "entry must match");
   679   assert(find_non_perm(key) == p, "must find the same spot");
   680   assert(find_non_perm(key) == p, "must find the same spot");
   680   ++_non_perm_count;
   681   ++_non_perm_count;