< prev index next >

src/hotspot/share/ci/ciObjectFactory.cpp

Print this page
rev 49250 : [mq]: JDK-8199781.patch


 231 // ------------------------------------------------------------------
 232 // ciObjectFactory::get
 233 //
 234 // Get the ciObject corresponding to some oop.  If the ciObject has
 235 // already been created, it is returned.  Otherwise, a new ciObject
 236 // is created.
 237 ciObject* ciObjectFactory::get(oop key) {
 238   ASSERT_IN_VM;
 239 
 240   assert(Universe::heap()->is_in_reserved(key), "must be");
 241 
 242   NonPermObject* &bucket = find_non_perm(key);
 243   if (bucket != NULL) {
 244     return bucket->object();
 245   }
 246 
 247   // The ciObject does not yet exist.  Create it and insert it
 248   // into the cache.
 249   Handle keyHandle(Thread::current(), key);
 250   ciObject* new_object = create_new_object(keyHandle());
 251   assert(keyHandle() == new_object->get_oop(), "must be properly recorded");
 252   init_ident_of(new_object);
 253   assert(Universe::heap()->is_in_reserved(new_object->get_oop()), "must be");
 254 
 255   // Not a perm-space object.
 256   insert_non_perm(bucket, keyHandle(), new_object);
 257   return new_object;
 258 }
 259 
 260 int ciObjectFactory::metadata_compare(Metadata* const& key, ciMetadata* const& elt) {
 261   Metadata* value = elt->constant_encoding();
 262   if (key < value)      return -1;
 263   else if (key > value) return 1;
 264   else                  return 0;
 265 }
 266 
 267 // ------------------------------------------------------------------
 268 // ciObjectFactory::get_metadata
 269 //
 270 // Get the ciMetadata corresponding to some Metadata. If the ciMetadata has
 271 // already been created, it is returned. Otherwise, a new ciMetadata


 432 // ciObjectFactory::get_unloaded_klass
 433 //
 434 // Get a ciKlass representing an unloaded klass.
 435 //
 436 // Implementation note: unloaded klasses are currently stored in
 437 // an unordered array, requiring a linear-time lookup for each
 438 // unloaded klass.  This may need to change.
 439 ciKlass* ciObjectFactory::get_unloaded_klass(ciKlass* accessing_klass,
 440                                              ciSymbol* name,
 441                                              bool create_if_not_found) {
 442   EXCEPTION_CONTEXT;
 443   oop loader = NULL;
 444   oop domain = NULL;
 445   if (accessing_klass != NULL) {
 446     loader = accessing_klass->loader();
 447     domain = accessing_klass->protection_domain();
 448   }
 449   for (int i=0; i<_unloaded_klasses->length(); i++) {
 450     ciKlass* entry = _unloaded_klasses->at(i);
 451     if (entry->name()->equals(name) &&
 452         entry->loader() == loader &&
 453         entry->protection_domain() == domain) {
 454       // We've found a match.
 455       return entry;
 456     }
 457   }
 458 
 459   if (!create_if_not_found)
 460     return NULL;
 461 
 462   // This is a new unloaded klass.  Create it and stick it in
 463   // the cache.
 464   ciKlass* new_klass = NULL;
 465 
 466   // Two cases: this is an unloaded ObjArrayKlass or an
 467   // unloaded InstanceKlass.  Deal with both.
 468   if (name->byte_at(0) == '[') {
 469     // Decompose the name.'
 470     FieldArrayInfo fd;
 471     BasicType element_type = FieldType::get_array_info(name->get_symbol(),
 472                                                        fd, THREAD);
 473     if (HAS_PENDING_EXCEPTION) {




 231 // ------------------------------------------------------------------
 232 // ciObjectFactory::get
 233 //
 234 // Get the ciObject corresponding to some oop.  If the ciObject has
 235 // already been created, it is returned.  Otherwise, a new ciObject
 236 // is created.
 237 ciObject* ciObjectFactory::get(oop key) {
 238   ASSERT_IN_VM;
 239 
 240   assert(Universe::heap()->is_in_reserved(key), "must be");
 241 
 242   NonPermObject* &bucket = find_non_perm(key);
 243   if (bucket != NULL) {
 244     return bucket->object();
 245   }
 246 
 247   // The ciObject does not yet exist.  Create it and insert it
 248   // into the cache.
 249   Handle keyHandle(Thread::current(), key);
 250   ciObject* new_object = create_new_object(keyHandle());
 251   assert(oopDesc::equals(keyHandle(), new_object->get_oop()), "must be properly recorded");
 252   init_ident_of(new_object);
 253   assert(Universe::heap()->is_in_reserved(new_object->get_oop()), "must be");
 254 
 255   // Not a perm-space object.
 256   insert_non_perm(bucket, keyHandle(), new_object);
 257   return new_object;
 258 }
 259 
 260 int ciObjectFactory::metadata_compare(Metadata* const& key, ciMetadata* const& elt) {
 261   Metadata* value = elt->constant_encoding();
 262   if (key < value)      return -1;
 263   else if (key > value) return 1;
 264   else                  return 0;
 265 }
 266 
 267 // ------------------------------------------------------------------
 268 // ciObjectFactory::get_metadata
 269 //
 270 // Get the ciMetadata corresponding to some Metadata. If the ciMetadata has
 271 // already been created, it is returned. Otherwise, a new ciMetadata


 432 // ciObjectFactory::get_unloaded_klass
 433 //
 434 // Get a ciKlass representing an unloaded klass.
 435 //
 436 // Implementation note: unloaded klasses are currently stored in
 437 // an unordered array, requiring a linear-time lookup for each
 438 // unloaded klass.  This may need to change.
 439 ciKlass* ciObjectFactory::get_unloaded_klass(ciKlass* accessing_klass,
 440                                              ciSymbol* name,
 441                                              bool create_if_not_found) {
 442   EXCEPTION_CONTEXT;
 443   oop loader = NULL;
 444   oop domain = NULL;
 445   if (accessing_klass != NULL) {
 446     loader = accessing_klass->loader();
 447     domain = accessing_klass->protection_domain();
 448   }
 449   for (int i=0; i<_unloaded_klasses->length(); i++) {
 450     ciKlass* entry = _unloaded_klasses->at(i);
 451     if (entry->name()->equals(name) &&
 452         oopDesc::equals(entry->loader(), loader) &&
 453         oopDesc::equals(entry->protection_domain(), domain)) {
 454       // We've found a match.
 455       return entry;
 456     }
 457   }
 458 
 459   if (!create_if_not_found)
 460     return NULL;
 461 
 462   // This is a new unloaded klass.  Create it and stick it in
 463   // the cache.
 464   ciKlass* new_klass = NULL;
 465 
 466   // Two cases: this is an unloaded ObjArrayKlass or an
 467   // unloaded InstanceKlass.  Deal with both.
 468   if (name->byte_at(0) == '[') {
 469     // Decompose the name.'
 470     FieldArrayInfo fd;
 471     BasicType element_type = FieldType::get_array_info(name->get_symbol(),
 472                                                        fd, THREAD);
 473     if (HAS_PENDING_EXCEPTION) {


< prev index next >