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 */ 24 25 #include "incls/_precompiled.incl" 26 #include "incls/_ciObjectFactory.cpp.incl" 27 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. 44 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; 49 50 51 // ------------------------------------------------------------------ 52 // ciObjectFactory::ciObjectFactory 53 ciObjectFactory::ciObjectFactory(Arena* arena, 54 int expected_size) { 55 56 for (int i = 0; i < NON_PERM_BUCKETS; i++) { 57 _non_perm_bucket[i] = NULL; 58 } 59 _non_perm_count = 0; 60 61 _next_ident = _shared_ident_limit; 62 _arena = arena; 63 _ci_objects = new (arena) GrowableArray<ciObject*>(arena, expected_size, 0, NULL); 64 65 // If the shared ci objects exist append them to this factory's objects 66 67 if (_shared_ci_objects != NULL) { 68 _ci_objects->appendAll(_shared_ci_objects); 69 } 70 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 } 76 77 // ------------------------------------------------------------------ 78 // ciObjectFactory::ciObjectFactory 79 void ciObjectFactory::initialize() { 80 ASSERT_IN_VM; 81 JavaThread* thread = JavaThread::current(); 82 HandleMark handle_mark(thread); 83 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(); 91 92 _initialized = true; 93 94 } 95 96 void ciObjectFactory::init_shared_objects() { 97 98 _next_ident = 1; // start numbering CI objects at 1 99 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 } 119 120 _ci_objects = new (_arena) GrowableArray<ciObject*>(_arena, 64, 0, NULL); 121 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 } 129 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(); 147 ciEnv::_ArrayStoreException = 148 get(SystemDictionary::ArrayStoreException_klass()) 149 ->as_instance_klass(); 150 ciEnv::_Class = 151 get(SystemDictionary::class_klass()) 152 ->as_instance_klass(); 153 ciEnv::_ClassCastException = 154 get(SystemDictionary::ClassCastException_klass()) 155 ->as_instance_klass(); 156 if (EnableInvokeDynamic) { 157 ciEnv::_InvokeDynamic = 158 get(SystemDictionary::InvokeDynamic_klass())->as_instance_klass(); 159 } 160 ciEnv::_Object = 161 get(SystemDictionary::object_klass()) 162 ->as_instance_klass(); 163 ciEnv::_Throwable = 164 get(SystemDictionary::throwable_klass()) 165 ->as_instance_klass(); 166 ciEnv::_Thread = 167 get(SystemDictionary::thread_klass()) 168 ->as_instance_klass(); 169 ciEnv::_OutOfMemoryError = 170 get(SystemDictionary::OutOfMemoryError_klass()) 171 ->as_instance_klass(); 172 ciEnv::_String = 173 get(SystemDictionary::string_klass()) 174 ->as_instance_klass(); 175 176 for (int len = -1; len != _ci_objects->length(); ) { 177 len = _ci_objects->length(); 178 for (int i2 = 0; i2 < len; i2++) { 179 ciObject* obj = _ci_objects->at(i2); 180 if (obj->is_loaded() && obj->is_instance_klass()) { 181 obj->as_instance_klass()->compute_nonstatic_fields(); 182 } 183 } 184 } 185 186 ciEnv::_unloaded_cisymbol = (ciSymbol*) ciObjectFactory::get(vmSymbols::dummy_symbol_oop()); 187 // Create dummy instanceKlass and objArrayKlass object and assign them idents 188 ciEnv::_unloaded_ciinstance_klass = new (_arena) ciInstanceKlass(ciEnv::_unloaded_cisymbol, NULL, NULL); 189 init_ident_of(ciEnv::_unloaded_ciinstance_klass); 190 ciEnv::_unloaded_ciobjarrayklass = new (_arena) ciObjArrayKlass(ciEnv::_unloaded_cisymbol, ciEnv::_unloaded_ciinstance_klass, 1); 191 init_ident_of(ciEnv::_unloaded_ciobjarrayklass); 192 assert(ciEnv::_unloaded_ciobjarrayklass->is_obj_array_klass(), "just checking"); 193 194 get(Universe::boolArrayKlassObj()); 195 get(Universe::charArrayKlassObj()); 196 get(Universe::singleArrayKlassObj()); 197 get(Universe::doubleArrayKlassObj()); 198 get(Universe::byteArrayKlassObj()); 199 get(Universe::shortArrayKlassObj()); 200 get(Universe::intArrayKlassObj()); 201 get(Universe::longArrayKlassObj()); 202 203 204 205 assert(_non_perm_count == 0, "no shared non-perm objects"); 206 207 // The shared_ident_limit is the first ident number that will 208 // be used for non-shared objects. That is, numbers less than 209 // this limit are permanently assigned to shared CI objects, 210 // while the higher numbers are recycled afresh by each new ciEnv. 211 212 _shared_ident_limit = _next_ident; 213 _shared_ci_objects = _ci_objects; 214 } 215 216 // ------------------------------------------------------------------ 217 // ciObjectFactory::get 218 // 219 // Get the ciObject corresponding to some oop. If the ciObject has 220 // already been created, it is returned. Otherwise, a new ciObject 221 // is created. 222 ciObject* ciObjectFactory::get(oop key) { 223 ASSERT_IN_VM; 224 225 #ifdef ASSERT 226 if (CIObjectFactoryVerify) { 227 oop last = NULL; 228 for (int j = 0; j< _ci_objects->length(); j++) { 229 oop o = _ci_objects->at(j)->get_oop(); 230 assert(last < o, "out of order"); 231 last = o; 232 } 233 } 234 #endif // ASSERT 235 int len = _ci_objects->length(); 236 int index = find(key, _ci_objects); 237 #ifdef ASSERT 238 if (CIObjectFactoryVerify) { 239 for (int i=0; i<_ci_objects->length(); i++) { 240 if (_ci_objects->at(i)->get_oop() == key) { 241 assert(index == i, " bad lookup"); 242 } 243 } 244 } 245 #endif 246 if (!is_found_at(index, key, _ci_objects)) { 247 // Check in the non-perm area before putting it in the list. 248 NonPermObject* &bucket = find_non_perm(key); 249 if (bucket != NULL) { 250 return bucket->object(); 251 } 252 253 // Check in the shared symbol area before putting it in the list. 254 if (key->is_symbol()) { 255 vmSymbols::SID sid = vmSymbols::find_sid((symbolOop)key); 256 if (sid != vmSymbols::NO_SID) { 257 // do not pollute the main cache with it 258 return vm_symbol_at(sid); 259 } 260 } 261 262 // The ciObject does not yet exist. Create it and insert it 263 // into the cache. 264 Handle keyHandle(key); 265 ciObject* new_object = create_new_object(keyHandle()); 266 assert(keyHandle() == new_object->get_oop(), "must be properly recorded"); 267 init_ident_of(new_object); 268 if (!new_object->is_perm()) { 269 // Not a perm-space object. 270 insert_non_perm(bucket, keyHandle(), new_object); 271 return new_object; 272 } 273 if (len != _ci_objects->length()) { 274 // creating the new object has recursively entered new objects 275 // into the table. We need to recompute our index. 276 index = find(keyHandle(), _ci_objects); 277 } 278 assert(!is_found_at(index, keyHandle(), _ci_objects), "no double insert"); 279 insert(index, new_object, _ci_objects); 280 return new_object; 281 } 282 return _ci_objects->at(index); 283 } 284 285 // ------------------------------------------------------------------ 286 // ciObjectFactory::create_new_object 287 // 288 // Create a new ciObject from an oop. 289 // 290 // Implementation note: this functionality could be virtual behavior 291 // of the oop itself. For now, we explicitly marshal the object. 292 ciObject* ciObjectFactory::create_new_object(oop o) { 293 EXCEPTION_CONTEXT; 294 295 if (o->is_symbol()) { 296 symbolHandle h_o(THREAD, (symbolOop)o); 297 return new (arena()) ciSymbol(h_o); 298 } else if (o->is_klass()) { 299 KlassHandle h_k(THREAD, (klassOop)o); 300 Klass* k = ((klassOop)o)->klass_part(); 301 if (k->oop_is_instance()) { 302 return new (arena()) ciInstanceKlass(h_k); 303 } else if (k->oop_is_objArray()) { 304 return new (arena()) ciObjArrayKlass(h_k); 305 } else if (k->oop_is_typeArray()) { 306 return new (arena()) ciTypeArrayKlass(h_k); 307 } else if (k->oop_is_method()) { 308 return new (arena()) ciMethodKlass(h_k); 309 } else if (k->oop_is_symbol()) { 310 return new (arena()) ciSymbolKlass(h_k); 311 } else if (k->oop_is_klass()) { 312 if (k->oop_is_objArrayKlass()) { 313 return new (arena()) ciObjArrayKlassKlass(h_k); 314 } else if (k->oop_is_typeArrayKlass()) { 315 return new (arena()) ciTypeArrayKlassKlass(h_k); 316 } else if (k->oop_is_instanceKlass()) { 317 return new (arena()) ciInstanceKlassKlass(h_k); 318 } else { 319 assert(o == Universe::klassKlassObj(), "bad klassKlass"); 320 return new (arena()) ciKlassKlass(h_k); 321 } 322 } 323 } else if (o->is_method()) { 324 methodHandle h_m(THREAD, (methodOop)o); 325 return new (arena()) ciMethod(h_m); 326 } else if (o->is_methodData()) { 327 methodDataHandle h_md(THREAD, (methodDataOop)o); 328 return new (arena()) ciMethodData(h_md); 329 } else if (o->is_instance()) { 330 instanceHandle h_i(THREAD, (instanceOop)o); 331 if (java_dyn_CallSite::is_instance(o)) 332 return new (arena()) ciCallSite(h_i); 333 else if (java_dyn_MethodHandle::is_instance(o)) 334 return new (arena()) ciMethodHandle(h_i); 335 else 336 return new (arena()) ciInstance(h_i); 337 } else if (o->is_objArray()) { 338 objArrayHandle h_oa(THREAD, (objArrayOop)o); 339 return new (arena()) ciObjArray(h_oa); 340 } else if (o->is_typeArray()) { 341 typeArrayHandle h_ta(THREAD, (typeArrayOop)o); 342 return new (arena()) ciTypeArray(h_ta); 343 } else if (o->is_constantPoolCache()) { 344 constantPoolCacheHandle h_cpc(THREAD, (constantPoolCacheOop) o); 345 return new (arena()) ciCPCache(h_cpc); 346 } 347 348 // The oop is of some type not supported by the compiler interface. 349 ShouldNotReachHere(); 350 return NULL; 351 } 352 353 //------------------------------------------------------------------ 354 // ciObjectFactory::get_unloaded_method 355 // 356 // Get the ciMethod representing an unloaded/unfound method. 357 // 358 // Implementation note: unloaded methods are currently stored in 359 // an unordered array, requiring a linear-time lookup for each 360 // unloaded method. This may need to change. 361 ciMethod* ciObjectFactory::get_unloaded_method(ciInstanceKlass* holder, 362 ciSymbol* name, 363 ciSymbol* signature) { 364 for (int i=0; i<_unloaded_methods->length(); i++) { 365 ciMethod* entry = _unloaded_methods->at(i); 366 if (entry->holder()->equals(holder) && 367 entry->name()->equals(name) && 368 entry->signature()->as_symbol()->equals(signature)) { 369 // We've found a match. 370 return entry; 371 } 372 } 373 374 // This is a new unloaded method. Create it and stick it in 375 // the cache. 376 ciMethod* new_method = new (arena()) ciMethod(holder, name, signature); 377 378 init_ident_of(new_method); 379 _unloaded_methods->append(new_method); 380 381 return new_method; 382 } 383 384 //------------------------------------------------------------------ 385 // ciObjectFactory::get_unloaded_klass 386 // 387 // Get a ciKlass representing an unloaded klass. 388 // 389 // Implementation note: unloaded klasses are currently stored in 390 // an unordered array, requiring a linear-time lookup for each 391 // unloaded klass. This may need to change. 392 ciKlass* ciObjectFactory::get_unloaded_klass(ciKlass* accessing_klass, 393 ciSymbol* name, 394 bool create_if_not_found) { 395 EXCEPTION_CONTEXT; 396 oop loader = NULL; 397 oop domain = NULL; 398 if (accessing_klass != NULL) { 399 loader = accessing_klass->loader(); 400 domain = accessing_klass->protection_domain(); 401 } 402 for (int i=0; i<_unloaded_klasses->length(); i++) { 403 ciKlass* entry = _unloaded_klasses->at(i); 404 if (entry->name()->equals(name) && 405 entry->loader() == loader && 406 entry->protection_domain() == domain) { 407 // We've found a match. 408 return entry; 409 } 410 } 411 412 if (!create_if_not_found) 413 return NULL; 414 415 // This is a new unloaded klass. Create it and stick it in 416 // the cache. 417 ciKlass* new_klass = NULL; 418 419 // Two cases: this is an unloaded objArrayKlass or an 420 // unloaded instanceKlass. Deal with both. 421 if (name->byte_at(0) == '[') { 422 // Decompose the name.' 423 jint dimension = 0; 424 symbolOop element_name = NULL; 425 BasicType element_type= FieldType::get_array_info(name->get_symbolOop(), 426 &dimension, 427 &element_name, 428 THREAD); 429 if (HAS_PENDING_EXCEPTION) { 430 CLEAR_PENDING_EXCEPTION; 431 CURRENT_THREAD_ENV->record_out_of_memory_failure(); 432 return ciEnv::_unloaded_ciobjarrayklass; 433 } 434 assert(element_type != T_ARRAY, "unsuccessful decomposition"); 435 ciKlass* element_klass = NULL; 436 if (element_type == T_OBJECT) { 437 ciEnv *env = CURRENT_THREAD_ENV; 438 ciSymbol* ci_name = env->get_object(element_name)->as_symbol(); 439 element_klass = 440 env->get_klass_by_name(accessing_klass, ci_name, false)->as_instance_klass(); 441 } else { 442 assert(dimension > 1, "one dimensional type arrays are always loaded."); 443 444 // The type array itself takes care of one of the dimensions. 445 dimension--; 446 447 // The element klass is a typeArrayKlass. 448 element_klass = ciTypeArrayKlass::make(element_type); 449 } 450 new_klass = new (arena()) ciObjArrayKlass(name, element_klass, dimension); 451 } else { 452 jobject loader_handle = NULL; 453 jobject domain_handle = NULL; 454 if (accessing_klass != NULL) { 455 loader_handle = accessing_klass->loader_handle(); 456 domain_handle = accessing_klass->protection_domain_handle(); 457 } 458 new_klass = new (arena()) ciInstanceKlass(name, loader_handle, domain_handle); 459 } 460 init_ident_of(new_klass); 461 _unloaded_klasses->append(new_klass); 462 463 return new_klass; 464 } 465 466 //------------------------------------------------------------------ 467 // ciObjectFactory::get_empty_methodData 468 // 469 // Get the ciMethodData representing the methodData for a method with 470 // none. 471 ciMethodData* ciObjectFactory::get_empty_methodData() { 472 ciMethodData* new_methodData = new (arena()) ciMethodData(); 473 init_ident_of(new_methodData); 474 return new_methodData; 475 } 476 477 //------------------------------------------------------------------ 478 // ciObjectFactory::get_return_address 479 // 480 // Get a ciReturnAddress for a specified bci. 481 ciReturnAddress* ciObjectFactory::get_return_address(int bci) { 482 for (int i=0; i<_return_addresses->length(); i++) { 483 ciReturnAddress* entry = _return_addresses->at(i); 484 if (entry->bci() == bci) { 485 // We've found a match. 486 return entry; 487 } 488 } 489 490 ciReturnAddress* new_ret_addr = new (arena()) ciReturnAddress(bci); 491 init_ident_of(new_ret_addr); 492 _return_addresses->append(new_ret_addr); 493 return new_ret_addr; 494 } 495 496 // ------------------------------------------------------------------ 497 // ciObjectFactory::init_ident_of 498 void ciObjectFactory::init_ident_of(ciObject* obj) { 499 obj->set_ident(_next_ident++); 500 } 501 502 503 // ------------------------------------------------------------------ 504 // ciObjectFactory::find 505 // 506 // Use binary search to find the position of this oop in the cache. 507 // If there is no entry in the cache corresponding to this oop, return 508 // the position at which the oop should be inserted. 509 int ciObjectFactory::find(oop key, GrowableArray<ciObject*>* objects) { 510 int min = 0; 511 int max = objects->length()-1; 512 513 // print_contents(); 514 515 while (max >= min) { 516 int mid = (max + min) / 2; 517 oop value = objects->at(mid)->get_oop(); 518 if (value < key) { 519 min = mid + 1; 520 } else if (value > key) { 521 max = mid - 1; 522 } else { 523 return mid; 524 } 525 } 526 return min; 527 } 528 529 // ------------------------------------------------------------------ 530 // ciObjectFactory::is_found_at 531 // 532 // Verify that the binary seach found the given key. 533 bool ciObjectFactory::is_found_at(int index, oop key, GrowableArray<ciObject*>* objects) { 534 return (index < objects->length() && 535 objects->at(index)->get_oop() == key); 536 } 537 538 539 // ------------------------------------------------------------------ 540 // ciObjectFactory::insert 541 // 542 // Insert a ciObject into the table at some index. 543 void ciObjectFactory::insert(int index, ciObject* obj, GrowableArray<ciObject*>* objects) { 544 int len = objects->length(); 545 if (len == index) { 546 objects->append(obj); 547 } else { 548 objects->append(objects->at(len-1)); 549 int pos; 550 for (pos = len-2; pos >= index; pos--) { 551 objects->at_put(pos+1,objects->at(pos)); 552 } 553 objects->at_put(index, obj); 554 } 555 #ifdef ASSERT 556 if (CIObjectFactoryVerify) { 557 oop last = NULL; 558 for (int j = 0; j< objects->length(); j++) { 559 oop o = objects->at(j)->get_oop(); 560 assert(last < o, "out of order"); 561 last = o; 562 } 563 } 564 #endif // ASSERT 565 } 566 567 static ciObjectFactory::NonPermObject* emptyBucket = NULL; 568 569 // ------------------------------------------------------------------ 570 // ciObjectFactory::find_non_perm 571 // 572 // Use a small hash table, hashed on the klass of the key. 573 // If there is no entry in the cache corresponding to this oop, return 574 // the null tail of the bucket into which the oop should be inserted. 575 ciObjectFactory::NonPermObject* &ciObjectFactory::find_non_perm(oop key) { 576 // Be careful: is_perm might change from false to true. 577 // Thus, there might be a matching perm object in the table. 578 // If there is, this probe must find it. 579 if (key->is_perm() && _non_perm_count == 0) { 580 return emptyBucket; 581 } else if (key->is_instance()) { 582 if (key->klass() == SystemDictionary::class_klass()) { 583 // class mirror instances are always perm 584 return emptyBucket; 585 } 586 // fall through to probe 587 } else if (key->is_array()) { 588 // fall through to probe 589 } else { 590 // not an array or instance 591 return emptyBucket; 592 } 593 594 ciObject* klass = get(key->klass()); 595 NonPermObject* *bp = &_non_perm_bucket[(unsigned) klass->hash() % NON_PERM_BUCKETS]; 596 for (NonPermObject* p; (p = (*bp)) != NULL; bp = &p->next()) { 597 if (is_equal(p, key)) break; 598 } 599 return (*bp); 600 } 601 602 603 604 // ------------------------------------------------------------------ 605 // Code for for NonPermObject 606 // 607 inline ciObjectFactory::NonPermObject::NonPermObject(ciObjectFactory::NonPermObject* &bucket, oop key, ciObject* object) { 608 assert(ciObjectFactory::is_initialized(), ""); 609 _object = object; 610 _next = bucket; 611 bucket = this; 612 } 613 614 615 616 // ------------------------------------------------------------------ 617 // ciObjectFactory::insert_non_perm 618 // 619 // Insert a ciObject into the non-perm table. 620 void ciObjectFactory::insert_non_perm(ciObjectFactory::NonPermObject* &where, oop key, ciObject* obj) { 621 assert(&where != &emptyBucket, "must not try to fill empty bucket"); 622 NonPermObject* p = new (arena()) NonPermObject(where, key, obj); 623 assert(where == p && is_equal(p, key) && p->object() == obj, "entry must match"); 624 assert(find_non_perm(key) == p, "must find the same spot"); 625 ++_non_perm_count; 626 } 627 628 // ------------------------------------------------------------------ 629 // ciObjectFactory::vm_symbol_at 630 // Get the ciSymbol corresponding to some index in vmSymbols. 631 ciSymbol* ciObjectFactory::vm_symbol_at(int index) { 632 assert(index >= vmSymbols::FIRST_SID && index < vmSymbols::SID_LIMIT, "oob"); 633 return _shared_ci_symbols[index]; 634 } 635 636 // ------------------------------------------------------------------ 637 // ciObjectFactory::print_contents_impl 638 void ciObjectFactory::print_contents_impl() { 639 int len = _ci_objects->length(); 640 tty->print_cr("ciObjectFactory (%d) oop contents:", len); 641 for (int i=0; i<len; i++) { 642 _ci_objects->at(i)->print(); 643 tty->cr(); 644 } 645 } 646 647 // ------------------------------------------------------------------ 648 // ciObjectFactory::print_contents 649 void ciObjectFactory::print_contents() { 650 print(); 651 tty->cr(); 652 GUARDED_VM_ENTRY(print_contents_impl();) 653 } 654 655 // ------------------------------------------------------------------ 656 // ciObjectFactory::print 657 // 658 // Print debugging information about the object factory 659 void ciObjectFactory::print() { 660 tty->print("<ciObjectFactory oops=%d unloaded_methods=%d unloaded_klasses=%d>", 661 _ci_objects->length(), _unloaded_methods->length(), 662 _unloaded_klasses->length()); 663 }