643 // Note that these tables still point to the *original* objects
644 // (because they were not processed by ExternalRefUpdater), so
645 // they would need to call DynamicArchive::original_to_target() to
646 // get the correct addresses.
647 assert(current_dump_space() == ro_space, "Must be RO space");
648 SymbolTable::write_to_archive(false);
649 SystemDictionaryShared::write_to_archive(false);
650
651 serialized_data = ro_space->top();
652 WriteClosure wc(ro_space);
653 SymbolTable::serialize_shared_table_header(&wc, false);
654 SystemDictionaryShared::serialize_dictionary_headers(&wc, false);
655 }
656
657 verify_estimate_size(_estimated_hashtable_bytes, "Hashtables");
658
659 make_trampolines();
660 make_klasses_shareable();
661
662 {
663 log_info(cds)("Final relocation of pointers ... ");
664 ResourceMark rm;
665 PointerMarker marker(this);
666 iterate_roots(&marker);
667 relocate_buffer_to_target();
668 }
669
670 write_archive(serialized_data);
671 release_header();
672
673 assert(_num_dump_regions_used == _total_dump_regions, "must be");
674 verify_universe("After CDS dynamic dump");
675 }
676
677 void iterate_roots(MetaspaceClosure* it) {
678 int i;
679 int num_klasses = _klasses->length();
680 for (i = 0; i < num_klasses; i++) {
681 it->push(&_klasses->at(i));
682 }
821 assert(p >= mc_space->base() && p <= mc_space->top(), "must be");
822 *adapter_trampoline = NULL;
823 m->set_adapter_trampoline(to_target(adapter_trampoline));
824 }
825 }
826
827 guarantee(p <= mc_space->top(), "Estimate of trampoline size is insufficient");
828 }
829
830 void DynamicArchiveBuilder::make_klasses_shareable() {
831 int i, count = _klasses->length();
832
833 InstanceKlass::disable_method_binary_search();
834 for (i = 0; i < count; i++) {
835 InstanceKlass* ik = _klasses->at(i);
836 sort_methods(ik);
837 }
838
839 for (i = 0; i < count; i++) {
840 InstanceKlass* ik = _klasses->at(i);
841 ClassLoaderData *cld = ik->class_loader_data();
842 if (cld->is_boot_class_loader_data()) {
843 ik->set_shared_class_loader_type(ClassLoader::BOOT_LOADER);
844 }
845 else if (cld->is_platform_class_loader_data()) {
846 ik->set_shared_class_loader_type(ClassLoader::PLATFORM_LOADER);
847 }
848 else if (cld->is_system_class_loader_data()) {
849 ik->set_shared_class_loader_type(ClassLoader::APP_LOADER);
850 }
851
852 MetaspaceShared::rewrite_nofast_bytecodes_and_calculate_fingerprints(Thread::current(), ik);
853 ik->remove_unshareable_info();
854
855 assert(ik->array_klasses() == NULL, "sanity");
856
857 if (log_is_enabled(Debug, cds, dynamic)) {
858 ResourceMark rm;
859 log_debug(cds, dynamic)("klasses[%4i] = " PTR_FORMAT " %s", i, p2i(to_target(ik)), ik->external_name());
860 }
861 }
862 }
863
864 // The address order of the copied Symbols may be different than when the original
865 // klasses were created. Re-sort all the tables. See Method::sort_methods().
866 void DynamicArchiveBuilder::sort_methods(InstanceKlass* ik) const {
867 assert(ik != NULL, "DynamicArchiveBuilder currently doesn't support dumping the base archive");
868 if (MetaspaceShared::is_in_shared_metaspace(ik)) {
869 // We have reached a supertype that's already in the base archive
870 return;
|
643 // Note that these tables still point to the *original* objects
644 // (because they were not processed by ExternalRefUpdater), so
645 // they would need to call DynamicArchive::original_to_target() to
646 // get the correct addresses.
647 assert(current_dump_space() == ro_space, "Must be RO space");
648 SymbolTable::write_to_archive(false);
649 SystemDictionaryShared::write_to_archive(false);
650
651 serialized_data = ro_space->top();
652 WriteClosure wc(ro_space);
653 SymbolTable::serialize_shared_table_header(&wc, false);
654 SystemDictionaryShared::serialize_dictionary_headers(&wc, false);
655 }
656
657 verify_estimate_size(_estimated_hashtable_bytes, "Hashtables");
658
659 make_trampolines();
660 make_klasses_shareable();
661
662 {
663 log_info(cds)("Adjust lambda proxy class dictionary");
664 SystemDictionaryShared::adjust_lambda_proxy_class_dictionary();
665 }
666
667 {
668 log_info(cds)("Final relocation of pointers ... ");
669 ResourceMark rm;
670 PointerMarker marker(this);
671 iterate_roots(&marker);
672 relocate_buffer_to_target();
673 }
674
675 write_archive(serialized_data);
676 release_header();
677
678 assert(_num_dump_regions_used == _total_dump_regions, "must be");
679 verify_universe("After CDS dynamic dump");
680 }
681
682 void iterate_roots(MetaspaceClosure* it) {
683 int i;
684 int num_klasses = _klasses->length();
685 for (i = 0; i < num_klasses; i++) {
686 it->push(&_klasses->at(i));
687 }
826 assert(p >= mc_space->base() && p <= mc_space->top(), "must be");
827 *adapter_trampoline = NULL;
828 m->set_adapter_trampoline(to_target(adapter_trampoline));
829 }
830 }
831
832 guarantee(p <= mc_space->top(), "Estimate of trampoline size is insufficient");
833 }
834
835 void DynamicArchiveBuilder::make_klasses_shareable() {
836 int i, count = _klasses->length();
837
838 InstanceKlass::disable_method_binary_search();
839 for (i = 0; i < count; i++) {
840 InstanceKlass* ik = _klasses->at(i);
841 sort_methods(ik);
842 }
843
844 for (i = 0; i < count; i++) {
845 InstanceKlass* ik = _klasses->at(i);
846 ik->assign_class_loader_type();
847
848 MetaspaceShared::rewrite_nofast_bytecodes_and_calculate_fingerprints(Thread::current(), ik);
849 ik->remove_unshareable_info();
850
851 assert(ik->array_klasses() == NULL, "sanity");
852
853 if (log_is_enabled(Debug, cds, dynamic)) {
854 ResourceMark rm;
855 log_debug(cds, dynamic)("klasses[%4i] = " PTR_FORMAT " %s", i, p2i(to_target(ik)), ik->external_name());
856 }
857 }
858 }
859
860 // The address order of the copied Symbols may be different than when the original
861 // klasses were created. Re-sort all the tables. See Method::sort_methods().
862 void DynamicArchiveBuilder::sort_methods(InstanceKlass* ik) const {
863 assert(ik != NULL, "DynamicArchiveBuilder currently doesn't support dumping the base archive");
864 if (MetaspaceShared::is_in_shared_metaspace(ik)) {
865 // We have reached a supertype that's already in the base archive
866 return;
|