// ------------------------------------------------------------------ // ciObjectFactory::get_metadata // // Get the ciMetadata corresponding to some Metadata. If the ciMetadata has // already been created, it is returned. Otherwise, a new ciMetadata // is created. ciMetadata* ciObjectFactory::get_metadata(Metadata* key) { ASSERT_IN_VM; #ifdef ASSERT if (CIObjectFactoryVerify) { Metadata* last = NULL; for (int j = 0; j< _ci_metadata->length(); j++) { Metadata* o = _ci_metadata->at(j)->constant_encoding(); assert(last < o, "out of order"); last = o; } } #endif // ASSERT int len = _ci_metadata->length(); int index = find(key, _ci_metadata); #ifdef ASSERT if (CIObjectFactoryVerify) { for (int i=0; i<_ci_metadata->length(); i++) { if (_ci_metadata->at(i)->constant_encoding() == key) { assert(index == i, " bad lookup"); } } } #endif if (!is_found_at(index, key, _ci_metadata)) { // The ciMetadata does not yet exist. Create it and insert it // into the cache. ciMetadata* new_object = create_new_metadata(key); init_ident_of(new_object); assert(new_object->is_metadata(), "must be"); if (len != _ci_metadata->length()) { // creating the new object has recursively entered new objects // into the table. We need to recompute our index. index = find(key, _ci_metadata); } assert(!is_found_at(index, key, _ci_metadata), "no double insert"); insert(index, new_object, _ci_metadata); return new_object; } return _ci_metadata->at(index)->as_metadata(); }
// ------------------------------------------------------------------ // ciObjectFactory::get // // Get the ciObject corresponding to some oop. If the ciObject has // already been created, it is returned. Otherwise, a new ciObject // is created. ciObject* ciObjectFactory::get(oop key) { ASSERT_IN_VM; #ifdef ASSERT if (CIObjectFactoryVerify) { oop last = NULL; for (int j = 0; j< _ci_objects->length(); j++) { oop o = _ci_objects->at(j)->get_oop(); assert(last < o, "out of order"); last = o; } } #endif // ASSERT int len = _ci_objects->length(); int index = find(key, _ci_objects); #ifdef ASSERT if (CIObjectFactoryVerify) { for (int i=0; i<_ci_objects->length(); i++) { if (_ci_objects->at(i)->get_oop() == key) { assert(index == i, " bad lookup"); } } } #endif if (!is_found_at(index, key, _ci_objects)) { // Check in the non-perm area before putting it in the list. NonPermObject* &bucket = find_non_perm(key); if (bucket != NULL) { return bucket->object(); } // Check in the shared symbol area before putting it in the list. if (key->is_symbol()) { vmSymbols::SID sid = vmSymbols::find_sid((symbolOop)key); if (sid != vmSymbols::NO_SID) { // do not pollute the main cache with it return vm_symbol_at(sid); } } // The ciObject does not yet exist. Create it and insert it // into the cache. Handle keyHandle(key); ciObject* new_object = create_new_object(keyHandle()); assert(keyHandle() == new_object->get_oop(), "must be properly recorded"); init_ident_of(new_object); if (!new_object->is_perm()) { // Not a perm-space object. insert_non_perm(bucket, keyHandle(), new_object); return new_object; } if (len != _ci_objects->length()) { // creating the new object has recursively entered new objects // into the table. We need to recompute our index. index = find(keyHandle(), _ci_objects); } assert(!is_found_at(index, keyHandle(), _ci_objects), "no double insert"); insert(index, new_object, _ci_objects); return new_object; } return _ci_objects->at(index); }