@@ -2178,21 +2178,35 @@ bool FileMapInfo::map_heap_region_impl() {
21782178 // Map the archived heap data. No need to call MemTracker::record_virtual_memory_type()
21792179 // for mapped region as it is part of the reserved java heap, which is already recorded.
21802180 char * addr = (char *)_mapped_heap_memregion.start ();
2181- char * base = map_memory (_fd, _full_path, r->file_offset (),
2182- addr, _mapped_heap_memregion.byte_size (), r->read_only (),
2183- r->allow_exec ());
2184- if (base == nullptr || base != addr) {
2185- dealloc_heap_region ();
2186- log_info (cds)(" UseSharedSpaces: Unable to map at required address in java heap. "
2187- INTPTR_FORMAT " , size = " SIZE_FORMAT " bytes" ,
2188- p2i (addr), _mapped_heap_memregion.byte_size ());
2189- return false ;
2190- }
2181+ char * base;
21912182
2192- if (VerifySharedSpaces && !r->check_region_crc (base)) {
2193- dealloc_heap_region ();
2194- log_info (cds)(" UseSharedSpaces: mapped heap region is corrupt" );
2195- return false ;
2183+ if (MetaspaceShared::use_windows_memory_mapping ()) {
2184+ if (!read_region (MetaspaceShared::hp, addr,
2185+ align_up (_mapped_heap_memregion.byte_size (), os::vm_page_size ()),
2186+ /* do_commit = */ true )) {
2187+ dealloc_heap_region ();
2188+ log_error (cds)(" Failed to read archived heap region into " INTPTR_FORMAT, p2i (addr));
2189+ return false ;
2190+ }
2191+ // Checks for VerifySharedSpaces is already done inside read_region()
2192+ base = addr;
2193+ } else {
2194+ base = map_memory (_fd, _full_path, r->file_offset (),
2195+ addr, _mapped_heap_memregion.byte_size (), r->read_only (),
2196+ r->allow_exec ());
2197+ if (base == nullptr || base != addr) {
2198+ dealloc_heap_region ();
2199+ log_info (cds)(" UseSharedSpaces: Unable to map at required address in java heap. "
2200+ INTPTR_FORMAT " , size = " SIZE_FORMAT " bytes" ,
2201+ p2i (addr), _mapped_heap_memregion.byte_size ());
2202+ return false ;
2203+ }
2204+
2205+ if (VerifySharedSpaces && !r->check_region_crc (base)) {
2206+ dealloc_heap_region ();
2207+ log_info (cds)(" UseSharedSpaces: mapped heap region is corrupt" );
2208+ return false ;
2209+ }
21962210 }
21972211
21982212 r->set_mapped_base (base);
0 commit comments