// ------------------------------------------------------------------ // ciObjectFactory::insert_non_perm // // Insert a ciObject into the non-perm table. void ciObjectFactory::insert_non_perm(ciObjectFactory::NonPermObject* &where, oop key, ciObject* obj) { assert(&where != &emptyBucket, "must not try to fill empty bucket"); NonPermObject* p = new (arena()) NonPermObject(where, key, obj); assert(where == p && is_equal(p, key) && p->object() == obj, "entry must match"); assert(find_non_perm(key) == p, "must find the same spot"); ++_non_perm_count; }
// ------------------------------------------------------------------ // 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; assert(Universe::heap()->is_in_reserved(key), "must be"); NonPermObject* &bucket = find_non_perm(key); if (bucket != NULL) { return bucket->object(); } // 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); assert(Universe::heap()->is_in_reserved(new_object->get_oop()), "must be"); // Not a perm-space object. insert_non_perm(bucket, keyHandle(), new_object); return new_object; }
// ------------------------------------------------------------------ // 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); }