804 char *addr = region_addr(idx); |
804 char *addr = region_addr(idx); |
805 char *base = os::remap_memory(_fd, _full_path, si->_file_offset, |
805 char *base = os::remap_memory(_fd, _full_path, si->_file_offset, |
806 addr, size, false /* !read_only */, |
806 addr, size, false /* !read_only */, |
807 si->_allow_exec); |
807 si->_allow_exec); |
808 close(); |
808 close(); |
|
809 // These have to be errors because the shared region is now unmapped. |
809 if (base == NULL) { |
810 if (base == NULL) { |
810 fail_continue("Unable to remap shared readonly space (errno=%d).", errno); |
811 log_error(cds)("Unable to remap shared readonly space (errno=%d).", errno); |
811 return false; |
812 vm_exit(1); |
812 } |
813 } |
813 if (base != addr) { |
814 if (base != addr) { |
814 fail_continue("Unable to remap shared readonly space at required address."); |
815 log_error(cds)("Unable to remap shared readonly space (errno=%d).", errno); |
815 return false; |
816 vm_exit(1); |
816 } |
817 } |
817 si->_read_only = false; |
818 si->_read_only = false; |
818 return true; |
819 return true; |
819 } |
820 } |
820 |
821 |
847 size_t used = si->_used; |
848 size_t used = si->_used; |
848 size_t alignment = os::vm_allocation_granularity(); |
849 size_t alignment = os::vm_allocation_granularity(); |
849 size_t size = align_up(used, alignment); |
850 size_t size = align_up(used, alignment); |
850 char *requested_addr = region_addr(i); |
851 char *requested_addr = region_addr(i); |
851 |
852 |
852 // If a tool agent is in use (debugging enabled), we must map the address space RW |
853 #ifdef _WINDOWS |
853 if (JvmtiExport::can_modify_any_class() || JvmtiExport::can_walk_any_space()) { |
854 // Windows cannot remap read-only shared memory to read-write when required for |
|
855 // RedefineClasses, which is also used by JFR. Always map windows regions as RW. |
|
856 si->_read_only = false; |
|
857 #else |
|
858 // If a tool agent is in use (debugging enabled), or JFR, we must map the address space RW |
|
859 if (JvmtiExport::can_modify_any_class() || JvmtiExport::can_walk_any_space() || |
|
860 Arguments::has_jfr_option()) { |
854 si->_read_only = false; |
861 si->_read_only = false; |
855 } |
862 } |
|
863 #endif // _WINDOWS |
856 |
864 |
857 // map the contents of the CDS archive in this memory |
865 // map the contents of the CDS archive in this memory |
858 char *base = os::map_memory(_fd, _full_path, si->_file_offset, |
866 char *base = os::map_memory(_fd, _full_path, si->_file_offset, |
859 requested_addr, size, si->_read_only, |
867 requested_addr, size, si->_read_only, |
860 si->_allow_exec); |
868 si->_allow_exec); |
865 #ifdef _WINDOWS |
873 #ifdef _WINDOWS |
866 // This call is Windows-only because the memory_type gets recorded for the other platforms |
874 // This call is Windows-only because the memory_type gets recorded for the other platforms |
867 // in method FileMapInfo::reserve_shared_memory(), which is not called on Windows. |
875 // in method FileMapInfo::reserve_shared_memory(), which is not called on Windows. |
868 MemTracker::record_virtual_memory_type((address)base, mtClassShared); |
876 MemTracker::record_virtual_memory_type((address)base, mtClassShared); |
869 #endif |
877 #endif |
870 |
|
871 |
878 |
872 if (!verify_region_checksum(i)) { |
879 if (!verify_region_checksum(i)) { |
873 return NULL; |
880 return NULL; |
874 } |
881 } |
875 |
882 |