equal
deleted
inserted
replaced
705 char* addr = (char*)string_ranges[i].start(); |
705 char* addr = (char*)string_ranges[i].start(); |
706 char* base = os::map_memory(_fd, _full_path, si->_file_offset, |
706 char* base = os::map_memory(_fd, _full_path, si->_file_offset, |
707 addr, string_ranges[i].byte_size(), si->_read_only, |
707 addr, string_ranges[i].byte_size(), si->_read_only, |
708 si->_allow_exec); |
708 si->_allow_exec); |
709 if (base == NULL || base != addr) { |
709 if (base == NULL || base != addr) { |
|
710 // dealloc the string regions from java heap |
|
711 dealloc_string_regions(); |
710 fail_continue("Unable to map shared string space at required address."); |
712 fail_continue("Unable to map shared string space at required address."); |
711 return false; |
713 return false; |
712 } |
714 } |
713 } |
715 } |
714 |
716 |
715 if (!verify_string_regions()) { |
717 if (!verify_string_regions()) { |
|
718 // dealloc the string regions from java heap |
|
719 dealloc_string_regions(); |
716 fail_continue("Shared string regions are corrupt"); |
720 fail_continue("Shared string regions are corrupt"); |
717 return false; |
721 return false; |
718 } |
722 } |
719 |
723 |
720 // the shared string data is mapped successfully |
724 // the shared string data is mapped successfully |
743 } |
747 } |
744 return true; |
748 return true; |
745 } |
749 } |
746 |
750 |
747 void FileMapInfo::fixup_string_regions() { |
751 void FileMapInfo::fixup_string_regions() { |
|
752 #if INCLUDE_ALL_GCS |
748 // If any string regions were found, call the fill routine to make them parseable. |
753 // If any string regions were found, call the fill routine to make them parseable. |
749 // Note that string_ranges may be non-NULL even if no ranges were found. |
754 // Note that string_ranges may be non-NULL even if no ranges were found. |
750 if (num_ranges != 0) { |
755 if (num_ranges != 0) { |
751 assert(string_ranges != NULL, "Null string_ranges array with non-zero count"); |
756 assert(string_ranges != NULL, "Null string_ranges array with non-zero count"); |
752 G1CollectedHeap::heap()->fill_archive_regions(string_ranges, num_ranges); |
757 G1CollectedHeap::heap()->fill_archive_regions(string_ranges, num_ranges); |
753 } |
758 } |
|
759 #endif |
754 } |
760 } |
755 |
761 |
756 bool FileMapInfo::verify_region_checksum(int i) { |
762 bool FileMapInfo::verify_region_checksum(int i) { |
757 if (!VerifySharedSpaces) { |
763 if (!VerifySharedSpaces) { |
758 return true; |
764 return true; |
791 if (!os::unmap_memory(addr, size)) { |
797 if (!os::unmap_memory(addr, size)) { |
792 fail_stop("Unable to unmap shared space."); |
798 fail_stop("Unable to unmap shared space."); |
793 } |
799 } |
794 } |
800 } |
795 |
801 |
796 void FileMapInfo::unmap_string_regions() { |
802 // dealloc the archived string region from java heap |
797 for (int i = MetaspaceShared::first_string; |
803 void FileMapInfo::dealloc_string_regions() { |
798 i < MetaspaceShared::first_string + MetaspaceShared::max_strings; i++) { |
804 #if INCLUDE_ALL_GCS |
799 struct FileMapInfo::FileMapHeader::space_info* si = &_header->_space[i]; |
805 if (num_ranges > 0) { |
800 size_t used = si->_used; |
806 assert(string_ranges != NULL, "Null string_ranges array with non-zero count"); |
801 if (used > 0) { |
807 G1CollectedHeap::heap()->dealloc_archive_regions(string_ranges, num_ranges); |
802 size_t size = align_size_up(used, os::vm_allocation_granularity()); |
808 } |
803 char* addr = (char*)((void*)oopDesc::decode_heap_oop_not_null( |
809 #endif |
804 (narrowOop)si->_addr._offset)); |
|
805 if (!os::unmap_memory(addr, size)) { |
|
806 fail_stop("Unable to unmap shared space."); |
|
807 } |
|
808 } |
|
809 } |
|
810 } |
810 } |
811 |
811 |
812 void FileMapInfo::assert_mark(bool check) { |
812 void FileMapInfo::assert_mark(bool check) { |
813 if (!check) { |
813 if (!check) { |
814 fail_stop("Mark mismatch while restoring from shared file."); |
814 fail_stop("Mark mismatch while restoring from shared file."); |
965 if (addr != NULL && !MetaspaceShared::is_string_region(i)) { |
965 if (addr != NULL && !MetaspaceShared::is_string_region(i)) { |
966 map_info->unmap_region(i); |
966 map_info->unmap_region(i); |
967 map_info->_header->_space[i]._addr._base = NULL; |
967 map_info->_header->_space[i]._addr._base = NULL; |
968 } |
968 } |
969 } |
969 } |
970 map_info->unmap_string_regions(); |
970 // Dealloc the string regions only without unmapping. The string regions are part |
|
971 // of the java heap. Unmapping of the heap regions are managed by GC. |
|
972 map_info->dealloc_string_regions(); |
971 } else if (DumpSharedSpaces) { |
973 } else if (DumpSharedSpaces) { |
972 fail_stop("%s", msg); |
974 fail_stop("%s", msg); |
973 } |
975 } |
974 } |
976 } |