632 char* requested_addr = _header->region_addr(0);
633
634 size_t size = FileMapInfo::shared_spaces_size();
635
636 // Reserve the space first, then map otherwise map will go right over some
637 // other reserved memory (like the code cache).
638 ReservedSpace rs(size, os::vm_allocation_granularity(), false, requested_addr);
639 if (!rs.is_reserved()) {
640 fail_continue("Unable to reserve shared space at required address "
641 INTPTR_FORMAT, p2i(requested_addr));
642 return rs;
643 }
644 // the reserved virtual memory is for mapping class data sharing archive
645 MemTracker::record_virtual_memory_type((address)rs.base(), mtClassShared);
646
647 return rs;
648 }
649
650 // Memory map a region in the address space.
651 static const char* shared_region_name[] = { "ReadOnly", "ReadWrite", "MiscData", "MiscCode",
652 "String1", "String2" };
653
654 char* FileMapInfo::map_region(int i) {
655 assert(!MetaspaceShared::is_string_region(i), "sanity");
656 struct FileMapInfo::FileMapHeader::space_info* si = &_header->_space[i];
657 size_t used = si->_used;
658 size_t alignment = os::vm_allocation_granularity();
659 size_t size = align_size_up(used, alignment);
660 char *requested_addr = _header->region_addr(i);
661
662 // If a tool agent is in use (debugging enabled), we must map the address space RW
663 if (JvmtiExport::can_modify_any_class() || JvmtiExport::can_walk_any_space()) {
664 si->_read_only = false;
665 }
666
667 // map the contents of the CDS archive in this memory
668 char *base = os::map_memory(_fd, _full_path, si->_file_offset,
669 requested_addr, size, si->_read_only,
670 si->_allow_exec);
671 if (base == NULL || base != requested_addr) {
672 fail_continue("Unable to map %s shared space at required address.", shared_region_name[i]);
|
632 char* requested_addr = _header->region_addr(0);
633
634 size_t size = FileMapInfo::shared_spaces_size();
635
636 // Reserve the space first, then map otherwise map will go right over some
637 // other reserved memory (like the code cache).
638 ReservedSpace rs(size, os::vm_allocation_granularity(), false, requested_addr);
639 if (!rs.is_reserved()) {
640 fail_continue("Unable to reserve shared space at required address "
641 INTPTR_FORMAT, p2i(requested_addr));
642 return rs;
643 }
644 // the reserved virtual memory is for mapping class data sharing archive
645 MemTracker::record_virtual_memory_type((address)rs.base(), mtClassShared);
646
647 return rs;
648 }
649
650 // Memory map a region in the address space.
651 static const char* shared_region_name[] = { "ReadOnly", "ReadWrite", "MiscData", "MiscCode",
652 "String1", "String2", "OptionalData" };
653
654 char* FileMapInfo::map_region(int i) {
655 assert(!MetaspaceShared::is_string_region(i), "sanity");
656 struct FileMapInfo::FileMapHeader::space_info* si = &_header->_space[i];
657 size_t used = si->_used;
658 size_t alignment = os::vm_allocation_granularity();
659 size_t size = align_size_up(used, alignment);
660 char *requested_addr = _header->region_addr(i);
661
662 // If a tool agent is in use (debugging enabled), we must map the address space RW
663 if (JvmtiExport::can_modify_any_class() || JvmtiExport::can_walk_any_space()) {
664 si->_read_only = false;
665 }
666
667 // map the contents of the CDS archive in this memory
668 char *base = os::map_memory(_fd, _full_path, si->_file_offset,
669 requested_addr, size, si->_read_only,
670 si->_allow_exec);
671 if (base == NULL || base != requested_addr) {
672 fail_continue("Unable to map %s shared space at required address.", shared_region_name[i]);
|