91 |
92 |
92 void MetaspaceShared::initialize_shared_rs(ReservedSpace* rs) { |
93 void MetaspaceShared::initialize_shared_rs(ReservedSpace* rs) { |
93 assert(DumpSharedSpaces, "dump time only"); |
94 assert(DumpSharedSpaces, "dump time only"); |
94 _shared_rs = rs; |
95 _shared_rs = rs; |
95 |
96 |
96 // Split up and initialize the misc code and data spaces |
97 size_t core_spaces_size = FileMapInfo::core_spaces_size(); |
97 size_t metadata_size = SharedReadOnlySize + SharedReadWriteSize; |
98 size_t metadata_size = SharedReadOnlySize + SharedReadWriteSize; |
98 ReservedSpace shared_ro_rw = _shared_rs->first_part(metadata_size); |
99 |
99 ReservedSpace misc_section = _shared_rs->last_part(metadata_size); |
100 // Split into the core and optional sections |
100 |
101 ReservedSpace core_data = _shared_rs->first_part(core_spaces_size); |
101 // Now split into misc sections. |
102 ReservedSpace optional_data = _shared_rs->last_part(core_spaces_size); |
|
103 |
|
104 // The RO/RW and the misc sections |
|
105 ReservedSpace shared_ro_rw = core_data.first_part(metadata_size); |
|
106 ReservedSpace misc_section = core_data.last_part(metadata_size); |
|
107 |
|
108 // Now split the misc code and misc data sections. |
102 ReservedSpace md_rs = misc_section.first_part(SharedMiscDataSize); |
109 ReservedSpace md_rs = misc_section.first_part(SharedMiscDataSize); |
103 ReservedSpace mc_rs = misc_section.last_part(SharedMiscDataSize); |
110 ReservedSpace mc_rs = misc_section.last_part(SharedMiscDataSize); |
|
111 |
104 _md.initialize(md_rs, SharedMiscDataSize, SharedMiscData); |
112 _md.initialize(md_rs, SharedMiscDataSize, SharedMiscData); |
105 _mc.initialize(mc_rs, SharedMiscCodeSize, SharedMiscData); |
113 _mc.initialize(mc_rs, SharedMiscCodeSize, SharedMiscCode); |
|
114 _od.initialize(optional_data, metadata_size, SharedOptional); |
106 } |
115 } |
107 |
116 |
108 // Read/write a data stream for restoring/preserving metadata pointers and |
117 // Read/write a data stream for restoring/preserving metadata pointers and |
109 // miscellaneous data from/to the shared archive file. |
118 // miscellaneous data from/to the shared archive file. |
110 |
119 |
596 // Remove all references outside the metadata |
606 // Remove all references outside the metadata |
597 tty->print("Removing unshareable information ... "); |
607 tty->print("Removing unshareable information ... "); |
598 remove_unshareable_in_classes(); |
608 remove_unshareable_in_classes(); |
599 tty->print_cr("done. "); |
609 tty->print_cr("done. "); |
600 |
610 |
601 // Set up the share data and shared code segments. |
611 // Set up the misc data, misc code and optional data segments. |
602 _md_vs = *MetaspaceShared::misc_data_region()->virtual_space(); |
612 _md_vs = *MetaspaceShared::misc_data_region()->virtual_space(); |
603 _mc_vs = *MetaspaceShared::misc_code_region()->virtual_space(); |
613 _mc_vs = *MetaspaceShared::misc_code_region()->virtual_space(); |
|
614 _od_vs = *MetaspaceShared::optional_data_region()->virtual_space(); |
604 char* md_low = _md_vs.low(); |
615 char* md_low = _md_vs.low(); |
605 char* md_top = MetaspaceShared::misc_data_region()->alloc_top(); |
616 char* md_top = MetaspaceShared::misc_data_region()->alloc_top(); |
606 char* md_end = _md_vs.high(); |
617 char* md_end = _md_vs.high(); |
607 char* mc_low = _mc_vs.low(); |
618 char* mc_low = _mc_vs.low(); |
608 char* mc_top = MetaspaceShared::misc_code_region()->alloc_top(); |
619 char* mc_top = MetaspaceShared::misc_code_region()->alloc_top(); |
609 char* mc_end = _mc_vs.high(); |
620 char* mc_end = _mc_vs.high(); |
|
621 char* od_low = _od_vs.low(); |
|
622 char* od_top = MetaspaceShared::optional_data_region()->alloc_top(); |
|
623 char* od_end = _od_vs.high(); |
610 |
624 |
611 // Reserve space for the list of Klass*s whose vtables are used |
625 // Reserve space for the list of Klass*s whose vtables are used |
612 // for patching others as needed. |
626 // for patching others as needed. |
613 |
627 |
614 void** vtbl_list = (void**)md_top; |
628 void** vtbl_list = (void**)md_top; |
659 // Allocated size of each space (may not be all occupied) |
673 // Allocated size of each space (may not be all occupied) |
660 const size_t ro_alloced = ro_space->capacity_bytes_slow(Metaspace::NonClassType); |
674 const size_t ro_alloced = ro_space->capacity_bytes_slow(Metaspace::NonClassType); |
661 const size_t rw_alloced = rw_space->capacity_bytes_slow(Metaspace::NonClassType); |
675 const size_t rw_alloced = rw_space->capacity_bytes_slow(Metaspace::NonClassType); |
662 const size_t md_alloced = md_end-md_low; |
676 const size_t md_alloced = md_end-md_low; |
663 const size_t mc_alloced = mc_end-mc_low; |
677 const size_t mc_alloced = mc_end-mc_low; |
|
678 const size_t od_alloced = od_end-od_low; |
664 const size_t total_alloced = ro_alloced + rw_alloced + md_alloced + mc_alloced |
679 const size_t total_alloced = ro_alloced + rw_alloced + md_alloced + mc_alloced |
665 + ss_bytes; |
680 + ss_bytes + od_alloced; |
666 |
681 |
667 // Occupied size of each space. |
682 // Occupied size of each space. |
668 const size_t ro_bytes = ro_space->used_bytes_slow(Metaspace::NonClassType); |
683 const size_t ro_bytes = ro_space->used_bytes_slow(Metaspace::NonClassType); |
669 const size_t rw_bytes = rw_space->used_bytes_slow(Metaspace::NonClassType); |
684 const size_t rw_bytes = rw_space->used_bytes_slow(Metaspace::NonClassType); |
670 const size_t md_bytes = size_t(md_top - md_low); |
685 const size_t md_bytes = size_t(md_top - md_low); |
671 const size_t mc_bytes = size_t(mc_top - mc_low); |
686 const size_t mc_bytes = size_t(mc_top - mc_low); |
|
687 const size_t od_bytes = size_t(od_top - od_low); |
672 |
688 |
673 // Percent of total size |
689 // Percent of total size |
674 const size_t total_bytes = ro_bytes + rw_bytes + md_bytes + mc_bytes + ss_bytes; |
690 const size_t total_bytes = ro_bytes + rw_bytes + md_bytes + mc_bytes + ss_bytes + od_bytes; |
675 const double ro_t_perc = ro_bytes / double(total_bytes) * 100.0; |
691 const double ro_t_perc = ro_bytes / double(total_bytes) * 100.0; |
676 const double rw_t_perc = rw_bytes / double(total_bytes) * 100.0; |
692 const double rw_t_perc = rw_bytes / double(total_bytes) * 100.0; |
677 const double md_t_perc = md_bytes / double(total_bytes) * 100.0; |
693 const double md_t_perc = md_bytes / double(total_bytes) * 100.0; |
678 const double mc_t_perc = mc_bytes / double(total_bytes) * 100.0; |
694 const double mc_t_perc = mc_bytes / double(total_bytes) * 100.0; |
679 const double ss_t_perc = ss_bytes / double(total_bytes) * 100.0; |
695 const double ss_t_perc = ss_bytes / double(total_bytes) * 100.0; |
|
696 const double od_t_perc = od_bytes / double(total_bytes) * 100.0; |
680 |
697 |
681 // Percent of fullness of each space |
698 // Percent of fullness of each space |
682 const double ro_u_perc = ro_bytes / double(ro_alloced) * 100.0; |
699 const double ro_u_perc = ro_bytes / double(ro_alloced) * 100.0; |
683 const double rw_u_perc = rw_bytes / double(rw_alloced) * 100.0; |
700 const double rw_u_perc = rw_bytes / double(rw_alloced) * 100.0; |
684 const double md_u_perc = md_bytes / double(md_alloced) * 100.0; |
701 const double md_u_perc = md_bytes / double(md_alloced) * 100.0; |
685 const double mc_u_perc = mc_bytes / double(mc_alloced) * 100.0; |
702 const double mc_u_perc = mc_bytes / double(mc_alloced) * 100.0; |
|
703 const double od_u_perc = od_bytes / double(od_alloced) * 100.0; |
686 const double total_u_perc = total_bytes / double(total_alloced) * 100.0; |
704 const double total_u_perc = total_bytes / double(total_alloced) * 100.0; |
687 |
705 |
688 #define fmt_space "%s space: " SIZE_FORMAT_W(9) " [ %4.1f%% of total] out of " SIZE_FORMAT_W(9) " bytes [%5.1f%% used] at " INTPTR_FORMAT |
706 #define fmt_space "%s space: " SIZE_FORMAT_W(9) " [ %4.1f%% of total] out of " SIZE_FORMAT_W(9) " bytes [%5.1f%% used] at " INTPTR_FORMAT |
689 tty->print_cr(fmt_space, "ro", ro_bytes, ro_t_perc, ro_alloced, ro_u_perc, p2i(ro_space->bottom())); |
707 tty->print_cr(fmt_space, "ro", ro_bytes, ro_t_perc, ro_alloced, ro_u_perc, p2i(ro_space->bottom())); |
690 tty->print_cr(fmt_space, "rw", rw_bytes, rw_t_perc, rw_alloced, rw_u_perc, p2i(rw_space->bottom())); |
708 tty->print_cr(fmt_space, "rw", rw_bytes, rw_t_perc, rw_alloced, rw_u_perc, p2i(rw_space->bottom())); |
691 tty->print_cr(fmt_space, "md", md_bytes, md_t_perc, md_alloced, md_u_perc, p2i(md_low)); |
709 tty->print_cr(fmt_space, "md", md_bytes, md_t_perc, md_alloced, md_u_perc, p2i(md_low)); |
692 tty->print_cr(fmt_space, "mc", mc_bytes, mc_t_perc, mc_alloced, mc_u_perc, p2i(mc_low)); |
710 tty->print_cr(fmt_space, "mc", mc_bytes, mc_t_perc, mc_alloced, mc_u_perc, p2i(mc_low)); |
693 tty->print_cr(fmt_space, "st", ss_bytes, ss_t_perc, ss_bytes, 100.0, p2i(ss_low)); |
711 tty->print_cr(fmt_space, "st", ss_bytes, ss_t_perc, ss_bytes, 100.0, p2i(ss_low)); |
|
712 tty->print_cr(fmt_space, "od", od_bytes, od_t_perc, od_alloced, od_u_perc, p2i(od_low)); |
694 tty->print_cr("total : " SIZE_FORMAT_W(9) " [100.0%% of total] out of " SIZE_FORMAT_W(9) " bytes [%5.1f%% used]", |
713 tty->print_cr("total : " SIZE_FORMAT_W(9) " [100.0%% of total] out of " SIZE_FORMAT_W(9) " bytes [%5.1f%% used]", |
695 total_bytes, total_alloced, total_u_perc); |
714 total_bytes, total_alloced, total_u_perc); |
696 |
715 |
697 // Update the vtable pointers in all of the Klass objects in the |
716 // Update the vtable pointers in all of the Klass objects in the |
698 // heap. They should point to newly generated vtable. |
717 // heap. They should point to newly generated vtable. |
1066 |
1087 |
1067 char* _ro_base = NULL; |
1088 char* _ro_base = NULL; |
1068 char* _rw_base = NULL; |
1089 char* _rw_base = NULL; |
1069 char* _md_base = NULL; |
1090 char* _md_base = NULL; |
1070 char* _mc_base = NULL; |
1091 char* _mc_base = NULL; |
|
1092 char* _od_base = NULL; |
1071 |
1093 |
1072 // Map each shared region |
1094 // Map each shared region |
1073 if ((_ro_base = mapinfo->map_region(ro)) != NULL && |
1095 if ((_ro_base = mapinfo->map_region(ro)) != NULL && |
1074 mapinfo->verify_region_checksum(ro) && |
1096 mapinfo->verify_region_checksum(ro) && |
1075 (_rw_base = mapinfo->map_region(rw)) != NULL && |
1097 (_rw_base = mapinfo->map_region(rw)) != NULL && |
1076 mapinfo->verify_region_checksum(rw) && |
1098 mapinfo->verify_region_checksum(rw) && |
1077 (_md_base = mapinfo->map_region(md)) != NULL && |
1099 (_md_base = mapinfo->map_region(md)) != NULL && |
1078 mapinfo->verify_region_checksum(md) && |
1100 mapinfo->verify_region_checksum(md) && |
1079 (_mc_base = mapinfo->map_region(mc)) != NULL && |
1101 (_mc_base = mapinfo->map_region(mc)) != NULL && |
1080 mapinfo->verify_region_checksum(mc) && |
1102 mapinfo->verify_region_checksum(mc) && |
|
1103 (_od_base = mapinfo->map_region(od)) != NULL && |
|
1104 mapinfo->verify_region_checksum(od) && |
1081 (image_alignment == (size_t)max_alignment()) && |
1105 (image_alignment == (size_t)max_alignment()) && |
1082 mapinfo->validate_classpath_entry_table()) { |
1106 mapinfo->validate_classpath_entry_table()) { |
1083 // Success (no need to do anything) |
1107 // Success (no need to do anything) |
1084 return true; |
1108 return true; |
1085 } else { |
1109 } else { |