< prev index next >

src/hotspot/share/oops/constantPool.cpp

Print this page

 437       oop archived = _cache->archived_references();
 438       // Create handle for the archived resolved reference array object
 439       HandleMark hm(THREAD);
 440       Handle refs_handle(THREAD, archived);
 441       set_resolved_references(loader_data->add_handle(refs_handle));
 442       _cache->clear_archived_references();
 443     } else
 444 #endif
 445     {
 446       // No mapped archived resolved reference array
 447       // Recreate the object array and add to ClassLoaderData.
 448       int map_length = resolved_reference_length();
 449       if (map_length > 0) {
 450         objArrayOop stom = oopFactory::new_objArray(vmClasses::Object_klass(), map_length, CHECK);
 451         HandleMark hm(THREAD);
 452         Handle refs_handle(THREAD, stom);  // must handleize.
 453         set_resolved_references(loader_data->add_handle(refs_handle));
 454       }
 455     }
 456   }





 457 }
 458 
 459 void ConstantPool::remove_unshareable_info() {
 460   // Shared ConstantPools are in the RO region, so the _flags cannot be modified.
 461   // The _on_stack flag is used to prevent ConstantPools from deallocation during
 462   // class redefinition. Since shared ConstantPools cannot be deallocated anyway,
 463   // we always set _on_stack to true to avoid having to change _flags during runtime.
 464   _flags |= (_on_stack | _is_shared);
 465 
 466   if (is_for_method_handle_intrinsic()) {
 467     // This CP was created by Method::make_method_handle_intrinsic() and has nothing
 468     // that need to be removed/restored. It has no cpCache since the intrinsic methods
 469     // don't have any bytecodes.
 470     assert(cache() == nullptr, "must not have cpCache");
 471     return;
 472   }
 473 
 474   // resolved_references(): remember its length. If it cannot be restored
 475   // from the archived heap objects at run time, we need to dynamically allocate it.
 476   if (cache() != nullptr) {

 482 }
 483 
 484 static const char* get_type(Klass* k) {
 485   const char* type;
 486   Klass* src_k;
 487   if (ArchiveBuilder::is_active() && ArchiveBuilder::current()->is_in_buffer_space(k)) {
 488     src_k = ArchiveBuilder::current()->get_source_addr(k);
 489   } else {
 490     src_k = k;
 491   }
 492 
 493   if (src_k->is_objArray_klass()) {
 494     src_k = ObjArrayKlass::cast(src_k)->bottom_klass();
 495     assert(!src_k->is_objArray_klass(), "sanity");
 496   }
 497 
 498   if (src_k->is_typeArray_klass()) {
 499     type = "prim";
 500   } else {
 501     InstanceKlass* src_ik = InstanceKlass::cast(src_k);



 502     oop loader = src_ik->class_loader();
 503     if (loader == nullptr) {
 504       type = "boot";
 505     } else if (loader == SystemDictionary::java_platform_loader()) {
 506       type = "plat";
 507     } else if (loader == SystemDictionary::java_system_loader()) {
 508       type = "app";
 509     } else {
 510       type = "unreg";
 511     }
 512   }
 513 
 514   return type;
 515 }
 516 
 517 void ConstantPool::remove_unshareable_entries() {
 518   ResourceMark rm;
 519   log_info(cds, resolve)("Archiving CP entries for %s", pool_holder()->name()->as_C_string());
 520   for (int cp_index = 1; cp_index < length(); cp_index++) { // cp_index 0 is unused
 521     int cp_tag = tag_at(cp_index).value();

 437       oop archived = _cache->archived_references();
 438       // Create handle for the archived resolved reference array object
 439       HandleMark hm(THREAD);
 440       Handle refs_handle(THREAD, archived);
 441       set_resolved_references(loader_data->add_handle(refs_handle));
 442       _cache->clear_archived_references();
 443     } else
 444 #endif
 445     {
 446       // No mapped archived resolved reference array
 447       // Recreate the object array and add to ClassLoaderData.
 448       int map_length = resolved_reference_length();
 449       if (map_length > 0) {
 450         objArrayOop stom = oopFactory::new_objArray(vmClasses::Object_klass(), map_length, CHECK);
 451         HandleMark hm(THREAD);
 452         Handle refs_handle(THREAD, stom);  // must handleize.
 453         set_resolved_references(loader_data->add_handle(refs_handle));
 454       }
 455     }
 456   }
 457 
 458   if (CDSConfig::is_dumping_final_static_archive() && resolved_references() != nullptr) {
 459     objArrayOop scratch_references = oopFactory::new_objArray(vmClasses::Object_klass(), resolved_references()->length(), CHECK);
 460     HeapShared::add_scratch_resolved_references(this, scratch_references);
 461   }
 462 }
 463 
 464 void ConstantPool::remove_unshareable_info() {
 465   // Shared ConstantPools are in the RO region, so the _flags cannot be modified.
 466   // The _on_stack flag is used to prevent ConstantPools from deallocation during
 467   // class redefinition. Since shared ConstantPools cannot be deallocated anyway,
 468   // we always set _on_stack to true to avoid having to change _flags during runtime.
 469   _flags |= (_on_stack | _is_shared);
 470 
 471   if (is_for_method_handle_intrinsic()) {
 472     // This CP was created by Method::make_method_handle_intrinsic() and has nothing
 473     // that need to be removed/restored. It has no cpCache since the intrinsic methods
 474     // don't have any bytecodes.
 475     assert(cache() == nullptr, "must not have cpCache");
 476     return;
 477   }
 478 
 479   // resolved_references(): remember its length. If it cannot be restored
 480   // from the archived heap objects at run time, we need to dynamically allocate it.
 481   if (cache() != nullptr) {

 487 }
 488 
 489 static const char* get_type(Klass* k) {
 490   const char* type;
 491   Klass* src_k;
 492   if (ArchiveBuilder::is_active() && ArchiveBuilder::current()->is_in_buffer_space(k)) {
 493     src_k = ArchiveBuilder::current()->get_source_addr(k);
 494   } else {
 495     src_k = k;
 496   }
 497 
 498   if (src_k->is_objArray_klass()) {
 499     src_k = ObjArrayKlass::cast(src_k)->bottom_klass();
 500     assert(!src_k->is_objArray_klass(), "sanity");
 501   }
 502 
 503   if (src_k->is_typeArray_klass()) {
 504     type = "prim";
 505   } else {
 506     InstanceKlass* src_ik = InstanceKlass::cast(src_k);
 507     if (CDSConfig::is_dumping_final_static_archive() && src_ik->class_loader_data() == nullptr) {
 508       return "unreg";
 509     }
 510     oop loader = src_ik->class_loader();
 511     if (loader == nullptr) {
 512       type = "boot";
 513     } else if (loader == SystemDictionary::java_platform_loader()) {
 514       type = "plat";
 515     } else if (loader == SystemDictionary::java_system_loader()) {
 516       type = "app";
 517     } else {
 518       type = "unreg";
 519     }
 520   }
 521 
 522   return type;
 523 }
 524 
 525 void ConstantPool::remove_unshareable_entries() {
 526   ResourceMark rm;
 527   log_info(cds, resolve)("Archiving CP entries for %s", pool_holder()->name()->as_C_string());
 528   for (int cp_index = 1; cp_index < length(); cp_index++) { // cp_index 0 is unused
 529     int cp_tag = tag_at(cp_index).value();
< prev index next >