src/hotspot/share/memory/filemap.cpp
changeset 59282 f5f129bfa403
parent 59235 0f41ac6bb9dd
--- a/src/hotspot/share/memory/filemap.cpp	Tue Nov 26 10:00:33 2019 +0100
+++ b/src/hotspot/share/memory/filemap.cpp	Fri Nov 22 17:45:48 2019 -0800
@@ -1385,14 +1385,6 @@
 
   }
 
-  DEBUG_ONLY(if (addr_delta == 0 && ArchiveRelocationMode == 1) {
-      // This is for simulating mmap failures at the requested address. We do it here (instead
-      // of MetaspaceShared::map_archives) so we can thoroughly test the code for failure handling
-      // (releasing all allocated resource, etc).
-      log_info(cds)("ArchiveRelocationMode == 1: always map archive(s) at an alternative address");
-      return MAP_ARCHIVE_MMAP_FAILURE;
-    });
-
   header()->set_mapped_base_address(header()->requested_base_address() + addr_delta);
   if (addr_delta != 0 && !relocate_pointers(addr_delta)) {
     return MAP_ARCHIVE_OTHER_FAILURE;
@@ -1446,12 +1438,14 @@
     MemTracker::record_virtual_memory_type((address)requested_addr, mtClassShared);
   }
 
-  if (MetaspaceShared::use_windows_memory_mapping() && addr_delta != 0) {
+  if (MetaspaceShared::use_windows_memory_mapping() && rs.is_reserved()) {
     // This is the second time we try to map the archive(s). We have already created a ReservedSpace
     // that covers all the FileMapRegions to ensure all regions can be mapped. However, Windows
     // can't mmap into a ReservedSpace, so we just os::read() the data. We're going to patch all the
     // regions anyway, so there's no benefit for mmap anyway.
     if (!read_region(i, requested_addr, size)) {
+      log_info(cds)("Failed to read %s shared space into reserved space at " INTPTR_FORMAT,
+                    shared_region_name[i], p2i(requested_addr));
       return MAP_ARCHIVE_OTHER_FAILURE; // oom or I/O error.
     }
   } else {
@@ -1459,7 +1453,8 @@
                                 requested_addr, size, si->read_only(),
                                 si->allow_exec());
     if (base != requested_addr) {
-      log_info(cds)("Unable to map %s shared space at required address.", shared_region_name[i]);
+      log_info(cds)("Unable to map %s shared space at " INTPTR_FORMAT,
+                    shared_region_name[i], p2i(requested_addr));
       _memory_mapping_failed = true;
       return MAP_ARCHIVE_MMAP_FAILURE;
     }
@@ -1468,7 +1463,7 @@
   si->set_mapped_base(requested_addr);
 
   if (!rs.is_reserved()) {
-    // When mapping on Windows with (addr_delta == 0), we don't reserve the address space for the regions
+    // When mapping on Windows for the first attempt, we don't reserve the address space for the regions
     // (Windows can't mmap into a ReservedSpace). In this case, NMT requires we call it after
     // os::map_memory has succeeded.
     assert(MetaspaceShared::use_windows_memory_mapping(), "Windows memory mapping only");