< prev index next >

src/hotspot/share/memory/filemap.cpp

Print this page
rev 52634 : 8214118: HeapRegions marked as archive even if CDS mapping fails
Reviewed-by:

@@ -1094,21 +1094,21 @@
     char* base = os::map_memory(_fd, _full_path, si->_file_offset,
                                 addr, regions[i].byte_size(), si->_read_only,
                                 si->_allow_exec);
     if (base == NULL || base != addr) {
       // dealloc the regions from java heap
-      dealloc_archive_heap_regions(regions, region_num);
+      dealloc_archive_heap_regions(regions, region_num, is_open_archive);
       log_info(cds)("UseSharedSpaces: Unable to map at required address in java heap. "
                     INTPTR_FORMAT ", size = " SIZE_FORMAT " bytes",
                     p2i(addr), regions[i].byte_size());
       return false;
     }
   }
 
   if (!verify_mapped_heap_regions(first, region_num)) {
     // dealloc the regions from java heap
-    dealloc_archive_heap_regions(regions, region_num);
+    dealloc_archive_heap_regions(regions, region_num, is_open_archive);
     log_info(cds)("UseSharedSpaces: mapped heap regions are corrupt");
     return false;
   }
 
   // the shared heap data is mapped successfully

@@ -1169,14 +1169,14 @@
                                                   num_open_archive_heap_ranges);
   }
 }
 
 // dealloc the archive regions from java heap
-void FileMapInfo::dealloc_archive_heap_regions(MemRegion* regions, int num) {
+void FileMapInfo::dealloc_archive_heap_regions(MemRegion* regions, int num, bool is_open) {
   if (num > 0) {
     assert(regions != NULL, "Null archive ranges array with non-zero count");
-    G1CollectedHeap::heap()->dealloc_archive_regions(regions, num);
+    G1CollectedHeap::heap()->dealloc_archive_regions(regions, num, is_open);
   }
 }
 #endif // INCLUDE_CDS_JAVA_HEAP
 
 bool FileMapInfo::verify_region_checksum(int i) {

@@ -1426,12 +1426,14 @@
       }
     }
     // Dealloc the archive heap regions only without unmapping. The regions are part
     // of the java heap. Unmapping of the heap regions are managed by GC.
     map_info->dealloc_archive_heap_regions(open_archive_heap_ranges,
-                                           num_open_archive_heap_ranges);
+                                           num_open_archive_heap_ranges,
+                                           true);
     map_info->dealloc_archive_heap_regions(closed_archive_heap_ranges,
-                                           num_closed_archive_heap_ranges);
+                                           num_closed_archive_heap_ranges,
+                                           false);
   } else if (DumpSharedSpaces) {
     fail_stop("%s", msg);
   }
 }
< prev index next >