< prev index next >

src/hotspot/share/oops/constantPool.cpp

Print this page

 466       oop archived = _cache->archived_references();
 467       // Create handle for the archived resolved reference array object
 468       HandleMark hm(THREAD);
 469       Handle refs_handle(THREAD, archived);
 470       set_resolved_references(loader_data->add_handle(refs_handle));
 471       _cache->clear_archived_references();
 472     } else
 473 #endif
 474     {
 475       // No mapped archived resolved reference array
 476       // Recreate the object array and add to ClassLoaderData.
 477       int map_length = resolved_reference_length();
 478       if (map_length > 0) {
 479         objArrayOop stom = oopFactory::new_objArray(vmClasses::Object_klass(), map_length, CHECK);
 480         HandleMark hm(THREAD);
 481         Handle refs_handle(THREAD, stom);  // must handleize.
 482         set_resolved_references(loader_data->add_handle(refs_handle));
 483       }
 484     }
 485   }





 486 }
 487 
 488 void ConstantPool::remove_unshareable_info() {
 489   // Shared ConstantPools are in the RO region, so the _flags cannot be modified.
 490   // The _on_stack flag is used to prevent ConstantPools from deallocation during
 491   // class redefinition. Since shared ConstantPools cannot be deallocated anyway,
 492   // we always set _on_stack to true to avoid having to change _flags during runtime.
 493   _flags |= (_on_stack | _is_shared);
 494 
 495   if (is_for_method_handle_intrinsic()) {
 496     // This CP was created by Method::make_method_handle_intrinsic() and has nothing
 497     // that need to be removed/restored. It has no cpCache since the intrinsic methods
 498     // don't have any bytecodes.
 499     assert(cache() == nullptr, "must not have cpCache");
 500     return;
 501   }
 502 
 503   // resolved_references(): remember its length. If it cannot be restored
 504   // from the archived heap objects at run time, we need to dynamically allocate it.
 505   if (cache() != nullptr) {

 511 }
 512 
 513 static const char* get_type(Klass* k) {
 514   const char* type;
 515   Klass* src_k;
 516   if (ArchiveBuilder::is_active() && ArchiveBuilder::current()->is_in_buffer_space(k)) {
 517     src_k = ArchiveBuilder::current()->get_source_addr(k);
 518   } else {
 519     src_k = k;
 520   }
 521 
 522   if (src_k->is_objArray_klass()) {
 523     src_k = ObjArrayKlass::cast(src_k)->bottom_klass();
 524     assert(!src_k->is_objArray_klass(), "sanity");
 525   }
 526 
 527   if (src_k->is_typeArray_klass()) {
 528     type = "prim";
 529   } else {
 530     InstanceKlass* src_ik = InstanceKlass::cast(src_k);



 531     oop loader = src_ik->class_loader();
 532     if (loader == nullptr) {
 533       type = "boot";
 534     } else if (loader == SystemDictionary::java_platform_loader()) {
 535       type = "plat";
 536     } else if (loader == SystemDictionary::java_system_loader()) {
 537       type = "app";
 538     } else {
 539       type = "unreg";
 540     }
 541   }
 542 
 543   return type;
 544 }
 545 
 546 void ConstantPool::remove_unshareable_entries() {
 547   ResourceMark rm;
 548   log_info(cds, resolve)("Archiving CP entries for %s", pool_holder()->name()->as_C_string());
 549   for (int cp_index = 1; cp_index < length(); cp_index++) { // cp_index 0 is unused
 550     int cp_tag = tag_at(cp_index).value();

 466       oop archived = _cache->archived_references();
 467       // Create handle for the archived resolved reference array object
 468       HandleMark hm(THREAD);
 469       Handle refs_handle(THREAD, archived);
 470       set_resolved_references(loader_data->add_handle(refs_handle));
 471       _cache->clear_archived_references();
 472     } else
 473 #endif
 474     {
 475       // No mapped archived resolved reference array
 476       // Recreate the object array and add to ClassLoaderData.
 477       int map_length = resolved_reference_length();
 478       if (map_length > 0) {
 479         objArrayOop stom = oopFactory::new_objArray(vmClasses::Object_klass(), map_length, CHECK);
 480         HandleMark hm(THREAD);
 481         Handle refs_handle(THREAD, stom);  // must handleize.
 482         set_resolved_references(loader_data->add_handle(refs_handle));
 483       }
 484     }
 485   }
 486 
 487   if (CDSConfig::is_dumping_final_static_archive() && resolved_references() != nullptr) {
 488     objArrayOop scratch_references = oopFactory::new_objArray(vmClasses::Object_klass(), resolved_references()->length(), CHECK);
 489     HeapShared::add_scratch_resolved_references(this, scratch_references);
 490   }
 491 }
 492 
 493 void ConstantPool::remove_unshareable_info() {
 494   // Shared ConstantPools are in the RO region, so the _flags cannot be modified.
 495   // The _on_stack flag is used to prevent ConstantPools from deallocation during
 496   // class redefinition. Since shared ConstantPools cannot be deallocated anyway,
 497   // we always set _on_stack to true to avoid having to change _flags during runtime.
 498   _flags |= (_on_stack | _is_shared);
 499 
 500   if (is_for_method_handle_intrinsic()) {
 501     // This CP was created by Method::make_method_handle_intrinsic() and has nothing
 502     // that need to be removed/restored. It has no cpCache since the intrinsic methods
 503     // don't have any bytecodes.
 504     assert(cache() == nullptr, "must not have cpCache");
 505     return;
 506   }
 507 
 508   // resolved_references(): remember its length. If it cannot be restored
 509   // from the archived heap objects at run time, we need to dynamically allocate it.
 510   if (cache() != nullptr) {

 516 }
 517 
 518 static const char* get_type(Klass* k) {
 519   const char* type;
 520   Klass* src_k;
 521   if (ArchiveBuilder::is_active() && ArchiveBuilder::current()->is_in_buffer_space(k)) {
 522     src_k = ArchiveBuilder::current()->get_source_addr(k);
 523   } else {
 524     src_k = k;
 525   }
 526 
 527   if (src_k->is_objArray_klass()) {
 528     src_k = ObjArrayKlass::cast(src_k)->bottom_klass();
 529     assert(!src_k->is_objArray_klass(), "sanity");
 530   }
 531 
 532   if (src_k->is_typeArray_klass()) {
 533     type = "prim";
 534   } else {
 535     InstanceKlass* src_ik = InstanceKlass::cast(src_k);
 536     if (CDSConfig::is_dumping_final_static_archive() && src_ik->class_loader_data() == nullptr) {
 537       return "unreg";
 538     }
 539     oop loader = src_ik->class_loader();
 540     if (loader == nullptr) {
 541       type = "boot";
 542     } else if (loader == SystemDictionary::java_platform_loader()) {
 543       type = "plat";
 544     } else if (loader == SystemDictionary::java_system_loader()) {
 545       type = "app";
 546     } else {
 547       type = "unreg";
 548     }
 549   }
 550 
 551   return type;
 552 }
 553 
 554 void ConstantPool::remove_unshareable_entries() {
 555   ResourceMark rm;
 556   log_info(cds, resolve)("Archiving CP entries for %s", pool_holder()->name()->as_C_string());
 557   for (int cp_index = 1; cp_index < length(); cp_index++) { // cp_index 0 is unused
 558     int cp_tag = tag_at(cp_index).value();
< prev index next >