src/share/vm/ci/ciObjectFactory.cpp

Mon, 26 Apr 2010 23:59:45 -0700

author
never
date
Mon, 26 Apr 2010 23:59:45 -0700
changeset 1832
b4776199210f
parent 1577
4ce7240d622c
child 1862
cd5dbf694d45
permissions
-rw-r--r--

6943485: JVMTI always on capabilities change code generation too much
Reviewed-by: twisti, dcubed

     1 /*
     2  * Copyright 1999-2009 Sun Microsystems, Inc.  All Rights Reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    20  * CA 95054 USA or visit www.sun.com if you need additional information or
    21  * have any questions.
    22  *
    23  */
    25 #include "incls/_precompiled.incl"
    26 #include "incls/_ciObjectFactory.cpp.incl"
    28 // ciObjectFactory
    29 //
    30 // This class handles requests for the creation of new instances
    31 // of ciObject and its subclasses.  It contains a caching mechanism
    32 // which ensures that for each oop, at most one ciObject is created.
    33 // This invariant allows more efficient implementation of ciObject.
    34 //
    35 // Implementation note: the oop->ciObject mapping is represented as
    36 // a table stored in an array.  Even though objects are moved
    37 // by the garbage collector, the compactor preserves their relative
    38 // order; address comparison of oops (in perm space) is safe so long
    39 // as we prohibit GC during our comparisons.  We currently use binary
    40 // search to find the oop in the table, and inserting a new oop
    41 // into the table may be costly.  If this cost ends up being
    42 // problematic the underlying data structure can be switched to some
    43 // sort of balanced binary tree.
    45 GrowableArray<ciObject*>* ciObjectFactory::_shared_ci_objects = NULL;
    46 ciSymbol*                 ciObjectFactory::_shared_ci_symbols[vmSymbols::SID_LIMIT];
    47 int                       ciObjectFactory::_shared_ident_limit = 0;
    48 volatile bool             ciObjectFactory::_initialized = false;
    51 // ------------------------------------------------------------------
    52 // ciObjectFactory::ciObjectFactory
    53 ciObjectFactory::ciObjectFactory(Arena* arena,
    54                                  int expected_size) {
    56   for (int i = 0; i < NON_PERM_BUCKETS; i++) {
    57     _non_perm_bucket[i] = NULL;
    58   }
    59   _non_perm_count = 0;
    61   _next_ident = _shared_ident_limit;
    62   _arena = arena;
    63   _ci_objects = new (arena) GrowableArray<ciObject*>(arena, expected_size, 0, NULL);
    65   // If the shared ci objects exist append them to this factory's objects
    67   if (_shared_ci_objects != NULL) {
    68     _ci_objects->appendAll(_shared_ci_objects);
    69   }
    71   _unloaded_methods = new (arena) GrowableArray<ciMethod*>(arena, 4, 0, NULL);
    72   _unloaded_klasses = new (arena) GrowableArray<ciKlass*>(arena, 8, 0, NULL);
    73   _return_addresses =
    74     new (arena) GrowableArray<ciReturnAddress*>(arena, 8, 0, NULL);
    75 }
    77 // ------------------------------------------------------------------
    78 // ciObjectFactory::ciObjectFactory
    79 void ciObjectFactory::initialize() {
    80   ASSERT_IN_VM;
    81   JavaThread* thread = JavaThread::current();
    82   HandleMark  handle_mark(thread);
    84   // This Arena is long lived and exists in the resource mark of the
    85   // compiler thread that initializes the initial ciObjectFactory which
    86   // creates the shared ciObjects that all later ciObjectFactories use.
    87   Arena* arena = new Arena();
    88   ciEnv initial(arena);
    89   ciEnv* env = ciEnv::current();
    90   env->_factory->init_shared_objects();
    92   _initialized = true;
    94 }
    96 void ciObjectFactory::init_shared_objects() {
    98   _next_ident = 1;  // start numbering CI objects at 1
   100   {
   101     // Create the shared symbols, but not in _shared_ci_objects.
   102     int i;
   103     for (i = vmSymbols::FIRST_SID; i < vmSymbols::SID_LIMIT; i++) {
   104       symbolHandle sym_handle = vmSymbolHandles::symbol_handle_at((vmSymbols::SID) i);
   105       assert(vmSymbols::find_sid(sym_handle()) == i, "1-1 mapping");
   106       ciSymbol* sym = new (_arena) ciSymbol(sym_handle);
   107       init_ident_of(sym);
   108       _shared_ci_symbols[i] = sym;
   109     }
   110 #ifdef ASSERT
   111     for (i = vmSymbols::FIRST_SID; i < vmSymbols::SID_LIMIT; i++) {
   112       symbolHandle sym_handle = vmSymbolHandles::symbol_handle_at((vmSymbols::SID) i);
   113       ciSymbol* sym = vm_symbol_at((vmSymbols::SID) i);
   114       assert(sym->get_oop() == sym_handle(), "oop must match");
   115     }
   116     assert(ciSymbol::void_class_signature()->get_oop() == vmSymbols::void_class_signature(), "spot check");
   117 #endif
   118   }
   120   _ci_objects = new (_arena) GrowableArray<ciObject*>(_arena, 64, 0, NULL);
   122   for (int i = T_BOOLEAN; i <= T_CONFLICT; i++) {
   123     BasicType t = (BasicType)i;
   124     if (type2name(t) != NULL && t != T_OBJECT && t != T_ARRAY && t != T_NARROWOOP) {
   125       ciType::_basic_types[t] = new (_arena) ciType(t);
   126       init_ident_of(ciType::_basic_types[t]);
   127     }
   128   }
   130   ciEnv::_null_object_instance = new (_arena) ciNullObject();
   131   init_ident_of(ciEnv::_null_object_instance);
   132   ciEnv::_method_klass_instance =
   133     get(Universe::methodKlassObj())->as_method_klass();
   134   ciEnv::_symbol_klass_instance =
   135     get(Universe::symbolKlassObj())->as_symbol_klass();
   136   ciEnv::_klass_klass_instance =
   137     get(Universe::klassKlassObj())->as_klass_klass();
   138   ciEnv::_instance_klass_klass_instance =
   139     get(Universe::instanceKlassKlassObj())
   140       ->as_instance_klass_klass();
   141   ciEnv::_type_array_klass_klass_instance =
   142     get(Universe::typeArrayKlassKlassObj())
   143       ->as_type_array_klass_klass();
   144   ciEnv::_obj_array_klass_klass_instance =
   145     get(Universe::objArrayKlassKlassObj())
   146       ->as_obj_array_klass_klass();
   148 #define WK_KLASS_DEFN(name, ignore_s, opt)                              \
   149   if (SystemDictionary::name() != NULL) \
   150     ciEnv::_##name = get(SystemDictionary::name())->as_instance_klass();
   152   WK_KLASSES_DO(WK_KLASS_DEFN)
   153 #undef WK_KLASS_DEFN
   155   for (int len = -1; len != _ci_objects->length(); ) {
   156     len = _ci_objects->length();
   157     for (int i2 = 0; i2 < len; i2++) {
   158       ciObject* obj = _ci_objects->at(i2);
   159       if (obj->is_loaded() && obj->is_instance_klass()) {
   160         obj->as_instance_klass()->compute_nonstatic_fields();
   161       }
   162     }
   163   }
   165   ciEnv::_unloaded_cisymbol = (ciSymbol*) ciObjectFactory::get(vmSymbols::dummy_symbol_oop());
   166   // Create dummy instanceKlass and objArrayKlass object and assign them idents
   167   ciEnv::_unloaded_ciinstance_klass = new (_arena) ciInstanceKlass(ciEnv::_unloaded_cisymbol, NULL, NULL);
   168   init_ident_of(ciEnv::_unloaded_ciinstance_klass);
   169   ciEnv::_unloaded_ciobjarrayklass = new (_arena) ciObjArrayKlass(ciEnv::_unloaded_cisymbol, ciEnv::_unloaded_ciinstance_klass, 1);
   170   init_ident_of(ciEnv::_unloaded_ciobjarrayklass);
   171   assert(ciEnv::_unloaded_ciobjarrayklass->is_obj_array_klass(), "just checking");
   173   get(Universe::boolArrayKlassObj());
   174   get(Universe::charArrayKlassObj());
   175   get(Universe::singleArrayKlassObj());
   176   get(Universe::doubleArrayKlassObj());
   177   get(Universe::byteArrayKlassObj());
   178   get(Universe::shortArrayKlassObj());
   179   get(Universe::intArrayKlassObj());
   180   get(Universe::longArrayKlassObj());
   184   assert(_non_perm_count == 0, "no shared non-perm objects");
   186   // The shared_ident_limit is the first ident number that will
   187   // be used for non-shared objects.  That is, numbers less than
   188   // this limit are permanently assigned to shared CI objects,
   189   // while the higher numbers are recycled afresh by each new ciEnv.
   191   _shared_ident_limit = _next_ident;
   192   _shared_ci_objects = _ci_objects;
   193 }
   195 // ------------------------------------------------------------------
   196 // ciObjectFactory::get
   197 //
   198 // Get the ciObject corresponding to some oop.  If the ciObject has
   199 // already been created, it is returned.  Otherwise, a new ciObject
   200 // is created.
   201 ciObject* ciObjectFactory::get(oop key) {
   202   ASSERT_IN_VM;
   204 #ifdef ASSERT
   205   if (CIObjectFactoryVerify) {
   206     oop last = NULL;
   207     for (int j = 0; j< _ci_objects->length(); j++) {
   208       oop o = _ci_objects->at(j)->get_oop();
   209       assert(last < o, "out of order");
   210       last = o;
   211     }
   212   }
   213 #endif // ASSERT
   214   int len = _ci_objects->length();
   215   int index = find(key, _ci_objects);
   216 #ifdef ASSERT
   217   if (CIObjectFactoryVerify) {
   218     for (int i=0; i<_ci_objects->length(); i++) {
   219       if (_ci_objects->at(i)->get_oop() == key) {
   220         assert(index == i, " bad lookup");
   221       }
   222     }
   223   }
   224 #endif
   225   if (!is_found_at(index, key, _ci_objects)) {
   226     // Check in the non-perm area before putting it in the list.
   227     NonPermObject* &bucket = find_non_perm(key);
   228     if (bucket != NULL) {
   229       return bucket->object();
   230     }
   232     // Check in the shared symbol area before putting it in the list.
   233     if (key->is_symbol()) {
   234       vmSymbols::SID sid = vmSymbols::find_sid((symbolOop)key);
   235       if (sid != vmSymbols::NO_SID) {
   236         // do not pollute the main cache with it
   237         return vm_symbol_at(sid);
   238       }
   239     }
   241     // The ciObject does not yet exist.  Create it and insert it
   242     // into the cache.
   243     Handle keyHandle(key);
   244     ciObject* new_object = create_new_object(keyHandle());
   245     assert(keyHandle() == new_object->get_oop(), "must be properly recorded");
   246     init_ident_of(new_object);
   247     if (!new_object->is_perm()) {
   248       // Not a perm-space object.
   249       insert_non_perm(bucket, keyHandle(), new_object);
   250       return new_object;
   251     }
   252     if (len != _ci_objects->length()) {
   253       // creating the new object has recursively entered new objects
   254       // into the table.  We need to recompute our index.
   255       index = find(keyHandle(), _ci_objects);
   256     }
   257     assert(!is_found_at(index, keyHandle(), _ci_objects), "no double insert");
   258     insert(index, new_object, _ci_objects);
   259     return new_object;
   260   }
   261   return _ci_objects->at(index);
   262 }
   264 // ------------------------------------------------------------------
   265 // ciObjectFactory::create_new_object
   266 //
   267 // Create a new ciObject from an oop.
   268 //
   269 // Implementation note: this functionality could be virtual behavior
   270 // of the oop itself.  For now, we explicitly marshal the object.
   271 ciObject* ciObjectFactory::create_new_object(oop o) {
   272   EXCEPTION_CONTEXT;
   274   if (o->is_symbol()) {
   275     symbolHandle h_o(THREAD, (symbolOop)o);
   276     return new (arena()) ciSymbol(h_o);
   277   } else if (o->is_klass()) {
   278     KlassHandle h_k(THREAD, (klassOop)o);
   279     Klass* k = ((klassOop)o)->klass_part();
   280     if (k->oop_is_instance()) {
   281       return new (arena()) ciInstanceKlass(h_k);
   282     } else if (k->oop_is_objArray()) {
   283       return new (arena()) ciObjArrayKlass(h_k);
   284     } else if (k->oop_is_typeArray()) {
   285       return new (arena()) ciTypeArrayKlass(h_k);
   286     } else if (k->oop_is_method()) {
   287       return new (arena()) ciMethodKlass(h_k);
   288     } else if (k->oop_is_symbol()) {
   289       return new (arena()) ciSymbolKlass(h_k);
   290     } else if (k->oop_is_klass()) {
   291       if (k->oop_is_objArrayKlass()) {
   292         return new (arena()) ciObjArrayKlassKlass(h_k);
   293       } else if (k->oop_is_typeArrayKlass()) {
   294         return new (arena()) ciTypeArrayKlassKlass(h_k);
   295       } else if (k->oop_is_instanceKlass()) {
   296         return new (arena()) ciInstanceKlassKlass(h_k);
   297       } else {
   298         assert(o == Universe::klassKlassObj(), "bad klassKlass");
   299         return new (arena()) ciKlassKlass(h_k);
   300       }
   301     }
   302   } else if (o->is_method()) {
   303     methodHandle h_m(THREAD, (methodOop)o);
   304     return new (arena()) ciMethod(h_m);
   305   } else if (o->is_methodData()) {
   306     methodDataHandle h_md(THREAD, (methodDataOop)o);
   307     return new (arena()) ciMethodData(h_md);
   308   } else if (o->is_instance()) {
   309     instanceHandle h_i(THREAD, (instanceOop)o);
   310     if (java_dyn_CallSite::is_instance(o))
   311       return new (arena()) ciCallSite(h_i);
   312     else if (java_dyn_MethodHandle::is_instance(o))
   313       return new (arena()) ciMethodHandle(h_i);
   314     else
   315       return new (arena()) ciInstance(h_i);
   316   } else if (o->is_objArray()) {
   317     objArrayHandle h_oa(THREAD, (objArrayOop)o);
   318     return new (arena()) ciObjArray(h_oa);
   319   } else if (o->is_typeArray()) {
   320     typeArrayHandle h_ta(THREAD, (typeArrayOop)o);
   321     return new (arena()) ciTypeArray(h_ta);
   322   } else if (o->is_constantPoolCache()) {
   323     constantPoolCacheHandle h_cpc(THREAD, (constantPoolCacheOop) o);
   324     return new (arena()) ciCPCache(h_cpc);
   325   }
   327   // The oop is of some type not supported by the compiler interface.
   328   ShouldNotReachHere();
   329   return NULL;
   330 }
   332 //------------------------------------------------------------------
   333 // ciObjectFactory::get_unloaded_method
   334 //
   335 // Get the ciMethod representing an unloaded/unfound method.
   336 //
   337 // Implementation note: unloaded methods are currently stored in
   338 // an unordered array, requiring a linear-time lookup for each
   339 // unloaded method.  This may need to change.
   340 ciMethod* ciObjectFactory::get_unloaded_method(ciInstanceKlass* holder,
   341                                                ciSymbol*        name,
   342                                                ciSymbol*        signature) {
   343   for (int i=0; i<_unloaded_methods->length(); i++) {
   344     ciMethod* entry = _unloaded_methods->at(i);
   345     if (entry->holder()->equals(holder) &&
   346         entry->name()->equals(name) &&
   347         entry->signature()->as_symbol()->equals(signature)) {
   348       // We've found a match.
   349       return entry;
   350     }
   351   }
   353   // This is a new unloaded method.  Create it and stick it in
   354   // the cache.
   355   ciMethod* new_method = new (arena()) ciMethod(holder, name, signature);
   357   init_ident_of(new_method);
   358   _unloaded_methods->append(new_method);
   360   return new_method;
   361 }
   363 //------------------------------------------------------------------
   364 // ciObjectFactory::get_unloaded_klass
   365 //
   366 // Get a ciKlass representing an unloaded klass.
   367 //
   368 // Implementation note: unloaded klasses are currently stored in
   369 // an unordered array, requiring a linear-time lookup for each
   370 // unloaded klass.  This may need to change.
   371 ciKlass* ciObjectFactory::get_unloaded_klass(ciKlass* accessing_klass,
   372                                              ciSymbol* name,
   373                                              bool create_if_not_found) {
   374   EXCEPTION_CONTEXT;
   375   oop loader = NULL;
   376   oop domain = NULL;
   377   if (accessing_klass != NULL) {
   378     loader = accessing_klass->loader();
   379     domain = accessing_klass->protection_domain();
   380   }
   381   for (int i=0; i<_unloaded_klasses->length(); i++) {
   382     ciKlass* entry = _unloaded_klasses->at(i);
   383     if (entry->name()->equals(name) &&
   384         entry->loader() == loader &&
   385         entry->protection_domain() == domain) {
   386       // We've found a match.
   387       return entry;
   388     }
   389   }
   391   if (!create_if_not_found)
   392     return NULL;
   394   // This is a new unloaded klass.  Create it and stick it in
   395   // the cache.
   396   ciKlass* new_klass = NULL;
   398   // Two cases: this is an unloaded objArrayKlass or an
   399   // unloaded instanceKlass.  Deal with both.
   400   if (name->byte_at(0) == '[') {
   401     // Decompose the name.'
   402     jint dimension = 0;
   403     symbolOop element_name = NULL;
   404     BasicType element_type= FieldType::get_array_info(name->get_symbolOop(),
   405                                                       &dimension,
   406                                                       &element_name,
   407                                                       THREAD);
   408     if (HAS_PENDING_EXCEPTION) {
   409       CLEAR_PENDING_EXCEPTION;
   410       CURRENT_THREAD_ENV->record_out_of_memory_failure();
   411       return ciEnv::_unloaded_ciobjarrayklass;
   412     }
   413     assert(element_type != T_ARRAY, "unsuccessful decomposition");
   414     ciKlass* element_klass = NULL;
   415     if (element_type == T_OBJECT) {
   416       ciEnv *env = CURRENT_THREAD_ENV;
   417       ciSymbol* ci_name = env->get_object(element_name)->as_symbol();
   418       element_klass =
   419         env->get_klass_by_name(accessing_klass, ci_name, false)->as_instance_klass();
   420     } else {
   421       assert(dimension > 1, "one dimensional type arrays are always loaded.");
   423       // The type array itself takes care of one of the dimensions.
   424       dimension--;
   426       // The element klass is a typeArrayKlass.
   427       element_klass = ciTypeArrayKlass::make(element_type);
   428     }
   429     new_klass = new (arena()) ciObjArrayKlass(name, element_klass, dimension);
   430   } else {
   431     jobject loader_handle = NULL;
   432     jobject domain_handle = NULL;
   433     if (accessing_klass != NULL) {
   434       loader_handle = accessing_klass->loader_handle();
   435       domain_handle = accessing_klass->protection_domain_handle();
   436     }
   437     new_klass = new (arena()) ciInstanceKlass(name, loader_handle, domain_handle);
   438   }
   439   init_ident_of(new_klass);
   440   _unloaded_klasses->append(new_klass);
   442   return new_klass;
   443 }
   445 //------------------------------------------------------------------
   446 // ciObjectFactory::get_empty_methodData
   447 //
   448 // Get the ciMethodData representing the methodData for a method with
   449 // none.
   450 ciMethodData* ciObjectFactory::get_empty_methodData() {
   451   ciMethodData* new_methodData = new (arena()) ciMethodData();
   452   init_ident_of(new_methodData);
   453   return new_methodData;
   454 }
   456 //------------------------------------------------------------------
   457 // ciObjectFactory::get_return_address
   458 //
   459 // Get a ciReturnAddress for a specified bci.
   460 ciReturnAddress* ciObjectFactory::get_return_address(int bci) {
   461   for (int i=0; i<_return_addresses->length(); i++) {
   462     ciReturnAddress* entry = _return_addresses->at(i);
   463     if (entry->bci() == bci) {
   464       // We've found a match.
   465       return entry;
   466     }
   467   }
   469   ciReturnAddress* new_ret_addr = new (arena()) ciReturnAddress(bci);
   470   init_ident_of(new_ret_addr);
   471   _return_addresses->append(new_ret_addr);
   472   return new_ret_addr;
   473 }
   475 // ------------------------------------------------------------------
   476 // ciObjectFactory::init_ident_of
   477 void ciObjectFactory::init_ident_of(ciObject* obj) {
   478   obj->set_ident(_next_ident++);
   479 }
   482 // ------------------------------------------------------------------
   483 // ciObjectFactory::find
   484 //
   485 // Use binary search to find the position of this oop in the cache.
   486 // If there is no entry in the cache corresponding to this oop, return
   487 // the position at which the oop should be inserted.
   488 int ciObjectFactory::find(oop key, GrowableArray<ciObject*>* objects) {
   489   int min = 0;
   490   int max = objects->length()-1;
   492   // print_contents();
   494   while (max >= min) {
   495     int mid = (max + min) / 2;
   496     oop value = objects->at(mid)->get_oop();
   497     if (value < key) {
   498       min = mid + 1;
   499     } else if (value > key) {
   500       max = mid - 1;
   501     } else {
   502       return mid;
   503     }
   504   }
   505   return min;
   506 }
   508 // ------------------------------------------------------------------
   509 // ciObjectFactory::is_found_at
   510 //
   511 // Verify that the binary seach found the given key.
   512 bool ciObjectFactory::is_found_at(int index, oop key, GrowableArray<ciObject*>* objects) {
   513   return (index < objects->length() &&
   514           objects->at(index)->get_oop() == key);
   515 }
   518 // ------------------------------------------------------------------
   519 // ciObjectFactory::insert
   520 //
   521 // Insert a ciObject into the table at some index.
   522 void ciObjectFactory::insert(int index, ciObject* obj, GrowableArray<ciObject*>* objects) {
   523   int len = objects->length();
   524   if (len == index) {
   525     objects->append(obj);
   526   } else {
   527     objects->append(objects->at(len-1));
   528     int pos;
   529     for (pos = len-2; pos >= index; pos--) {
   530       objects->at_put(pos+1,objects->at(pos));
   531     }
   532     objects->at_put(index, obj);
   533   }
   534 #ifdef ASSERT
   535   if (CIObjectFactoryVerify) {
   536     oop last = NULL;
   537     for (int j = 0; j< objects->length(); j++) {
   538       oop o = objects->at(j)->get_oop();
   539       assert(last < o, "out of order");
   540       last = o;
   541     }
   542   }
   543 #endif // ASSERT
   544 }
   546 static ciObjectFactory::NonPermObject* emptyBucket = NULL;
   548 // ------------------------------------------------------------------
   549 // ciObjectFactory::find_non_perm
   550 //
   551 // Use a small hash table, hashed on the klass of the key.
   552 // If there is no entry in the cache corresponding to this oop, return
   553 // the null tail of the bucket into which the oop should be inserted.
   554 ciObjectFactory::NonPermObject* &ciObjectFactory::find_non_perm(oop key) {
   555   // Be careful:  is_perm might change from false to true.
   556   // Thus, there might be a matching perm object in the table.
   557   // If there is, this probe must find it.
   558   if (key->is_perm() && _non_perm_count == 0) {
   559     return emptyBucket;
   560   } else if (key->is_instance()) {
   561     if (key->klass() == SystemDictionary::Class_klass()) {
   562       // class mirror instances are always perm
   563       return emptyBucket;
   564     }
   565     // fall through to probe
   566   } else if (key->is_array()) {
   567     // fall through to probe
   568   } else {
   569     // not an array or instance
   570     return emptyBucket;
   571   }
   573   ciObject* klass = get(key->klass());
   574   NonPermObject* *bp = &_non_perm_bucket[(unsigned) klass->hash() % NON_PERM_BUCKETS];
   575   for (NonPermObject* p; (p = (*bp)) != NULL; bp = &p->next()) {
   576     if (is_equal(p, key))  break;
   577   }
   578   return (*bp);
   579 }
   583 // ------------------------------------------------------------------
   584 // Code for for NonPermObject
   585 //
   586 inline ciObjectFactory::NonPermObject::NonPermObject(ciObjectFactory::NonPermObject* &bucket, oop key, ciObject* object) {
   587   assert(ciObjectFactory::is_initialized(), "");
   588   _object = object;
   589   _next = bucket;
   590   bucket = this;
   591 }
   595 // ------------------------------------------------------------------
   596 // ciObjectFactory::insert_non_perm
   597 //
   598 // Insert a ciObject into the non-perm table.
   599 void ciObjectFactory::insert_non_perm(ciObjectFactory::NonPermObject* &where, oop key, ciObject* obj) {
   600   assert(&where != &emptyBucket, "must not try to fill empty bucket");
   601   NonPermObject* p = new (arena()) NonPermObject(where, key, obj);
   602   assert(where == p && is_equal(p, key) && p->object() == obj, "entry must match");
   603   assert(find_non_perm(key) == p, "must find the same spot");
   604   ++_non_perm_count;
   605 }
   607 // ------------------------------------------------------------------
   608 // ciObjectFactory::vm_symbol_at
   609 // Get the ciSymbol corresponding to some index in vmSymbols.
   610 ciSymbol* ciObjectFactory::vm_symbol_at(int index) {
   611   assert(index >= vmSymbols::FIRST_SID && index < vmSymbols::SID_LIMIT, "oob");
   612   return _shared_ci_symbols[index];
   613 }
   615 // ------------------------------------------------------------------
   616 // ciObjectFactory::print_contents_impl
   617 void ciObjectFactory::print_contents_impl() {
   618   int len = _ci_objects->length();
   619   tty->print_cr("ciObjectFactory (%d) oop contents:", len);
   620   for (int i=0; i<len; i++) {
   621     _ci_objects->at(i)->print();
   622     tty->cr();
   623   }
   624 }
   626 // ------------------------------------------------------------------
   627 // ciObjectFactory::print_contents
   628 void ciObjectFactory::print_contents() {
   629   print();
   630   tty->cr();
   631   GUARDED_VM_ENTRY(print_contents_impl();)
   632 }
   634 // ------------------------------------------------------------------
   635 // ciObjectFactory::print
   636 //
   637 // Print debugging information about the object factory
   638 void ciObjectFactory::print() {
   639   tty->print("<ciObjectFactory oops=%d unloaded_methods=%d unloaded_klasses=%d>",
   640              _ci_objects->length(), _unloaded_methods->length(),
   641              _unloaded_klasses->length());
   642 }

mercurial