444 oop archived = _cache->archived_references();
445 // Create handle for the archived resolved reference array object
446 HandleMark hm(THREAD);
447 Handle refs_handle(THREAD, archived);
448 set_resolved_references(loader_data->add_handle(refs_handle));
449 _cache->clear_archived_references();
450 } else
451 #endif
452 {
453 // No mapped archived resolved reference array
454 // Recreate the object array and add to ClassLoaderData.
455 int map_length = resolved_reference_length();
456 if (map_length > 0) {
457 objArrayOop stom = oopFactory::new_objArray(vmClasses::Object_klass(), map_length, CHECK);
458 HandleMark hm(THREAD);
459 Handle refs_handle(THREAD, stom); // must handleize.
460 set_resolved_references(loader_data->add_handle(refs_handle));
461 }
462 }
463 }
464 }
465
466 void ConstantPool::remove_unshareable_info() {
467 // Shared ConstantPools are in the RO region, so the _flags cannot be modified.
468 // The _on_stack flag is used to prevent ConstantPools from deallocation during
469 // class redefinition. Since shared ConstantPools cannot be deallocated anyway,
470 // we always set _on_stack to true to avoid having to change _flags during runtime.
471 _flags |= (_on_stack | _is_shared);
472
473 if (is_for_method_handle_intrinsic()) {
474 // This CP was created by Method::make_method_handle_intrinsic() and has nothing
475 // that need to be removed/restored. It has no cpCache since the intrinsic methods
476 // don't have any bytecodes.
477 assert(cache() == NULL, "must not have cpCache");
478 return;
479 }
480
481 // resolved_references(): remember its length. If it cannot be restored
482 // from the archived heap objects at run time, we need to dynamically allocate it.
483 if (cache() != nullptr) {
489 }
490
491 static const char* get_type(Klass* k) {
492 const char* type;
493 Klass* src_k;
494 if (ArchiveBuilder::is_active() && ArchiveBuilder::current()->is_in_buffer_space(k)) {
495 src_k = ArchiveBuilder::current()->get_source_addr(k);
496 } else {
497 src_k = k;
498 }
499
500 if (src_k->is_objArray_klass()) {
501 src_k = ObjArrayKlass::cast(src_k)->bottom_klass();
502 assert(!src_k->is_objArray_klass(), "sanity");
503 }
504
505 if (src_k->is_typeArray_klass()) {
506 type = "prim";
507 } else {
508 InstanceKlass* src_ik = InstanceKlass::cast(src_k);
509 oop loader = src_ik->class_loader();
510 if (loader == nullptr) {
511 type = "boot";
512 } else if (loader == SystemDictionary::java_platform_loader()) {
513 type = "plat";
514 } else if (loader == SystemDictionary::java_system_loader()) {
515 type = "app";
516 } else {
517 type = "unreg";
518 }
519 }
520
521 return type;
522 }
523
524 void ConstantPool::remove_unshareable_entries() {
525 ResourceMark rm;
526 log_info(cds, resolve)("Archiving CP entries for %s", pool_holder()->name()->as_C_string());
527 for (int cp_index = 1; cp_index < length(); cp_index++) { // cp_index 0 is unused
528 int cp_tag = tag_at(cp_index).value();
|
444 oop archived = _cache->archived_references();
445 // Create handle for the archived resolved reference array object
446 HandleMark hm(THREAD);
447 Handle refs_handle(THREAD, archived);
448 set_resolved_references(loader_data->add_handle(refs_handle));
449 _cache->clear_archived_references();
450 } else
451 #endif
452 {
453 // No mapped archived resolved reference array
454 // Recreate the object array and add to ClassLoaderData.
455 int map_length = resolved_reference_length();
456 if (map_length > 0) {
457 objArrayOop stom = oopFactory::new_objArray(vmClasses::Object_klass(), map_length, CHECK);
458 HandleMark hm(THREAD);
459 Handle refs_handle(THREAD, stom); // must handleize.
460 set_resolved_references(loader_data->add_handle(refs_handle));
461 }
462 }
463 }
464
465 if (CDSConfig::is_dumping_final_static_archive() && resolved_references() != nullptr) {
466 objArrayOop scratch_references = oopFactory::new_objArray(vmClasses::Object_klass(), resolved_references()->length(), CHECK);
467 HeapShared::add_scratch_resolved_references(this, scratch_references);
468 }
469 }
470
471 void ConstantPool::remove_unshareable_info() {
472 // Shared ConstantPools are in the RO region, so the _flags cannot be modified.
473 // The _on_stack flag is used to prevent ConstantPools from deallocation during
474 // class redefinition. Since shared ConstantPools cannot be deallocated anyway,
475 // we always set _on_stack to true to avoid having to change _flags during runtime.
476 _flags |= (_on_stack | _is_shared);
477
478 if (is_for_method_handle_intrinsic()) {
479 // This CP was created by Method::make_method_handle_intrinsic() and has nothing
480 // that need to be removed/restored. It has no cpCache since the intrinsic methods
481 // don't have any bytecodes.
482 assert(cache() == NULL, "must not have cpCache");
483 return;
484 }
485
486 // resolved_references(): remember its length. If it cannot be restored
487 // from the archived heap objects at run time, we need to dynamically allocate it.
488 if (cache() != nullptr) {
494 }
495
496 static const char* get_type(Klass* k) {
497 const char* type;
498 Klass* src_k;
499 if (ArchiveBuilder::is_active() && ArchiveBuilder::current()->is_in_buffer_space(k)) {
500 src_k = ArchiveBuilder::current()->get_source_addr(k);
501 } else {
502 src_k = k;
503 }
504
505 if (src_k->is_objArray_klass()) {
506 src_k = ObjArrayKlass::cast(src_k)->bottom_klass();
507 assert(!src_k->is_objArray_klass(), "sanity");
508 }
509
510 if (src_k->is_typeArray_klass()) {
511 type = "prim";
512 } else {
513 InstanceKlass* src_ik = InstanceKlass::cast(src_k);
514 if (CDSConfig::is_dumping_final_static_archive() && src_ik->class_loader_data() == nullptr) {
515 return "unreg";
516 }
517 oop loader = src_ik->class_loader();
518 if (loader == nullptr) {
519 type = "boot";
520 } else if (loader == SystemDictionary::java_platform_loader()) {
521 type = "plat";
522 } else if (loader == SystemDictionary::java_system_loader()) {
523 type = "app";
524 } else {
525 type = "unreg";
526 }
527 }
528
529 return type;
530 }
531
532 void ConstantPool::remove_unshareable_entries() {
533 ResourceMark rm;
534 log_info(cds, resolve)("Archiving CP entries for %s", pool_holder()->name()->as_C_string());
535 for (int cp_index = 1; cp_index < length(); cp_index++) { // cp_index 0 is unused
536 int cp_tag = tag_at(cp_index).value();
|