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