< prev index next >

src/hotspot/share/memory/filemap.cpp

Print this page

@@ -657,11 +657,11 @@
 
 // Memory map a region in the address space.
 static const char* shared_region_name[] = { "MiscData", "ReadWrite", "ReadOnly", "MiscCode", "OptionalData",
                                             "String1", "String2", "OpenArchive1", "OpenArchive2" };
 
-char* FileMapInfo::map_region(int i) {
+char* FileMapInfo::map_region(int i, char** top_ret) {
   assert(!MetaspaceShared::is_heap_region(i), "sanity");
   struct FileMapInfo::FileMapHeader::space_info* si = &_header->_space[i];
   size_t used = si->_used;
   size_t alignment = os::vm_allocation_granularity();
   size_t size = align_up(used, alignment);

@@ -684,10 +684,16 @@
   // This call is Windows-only because the memory_type gets recorded for the other platforms
   // in method FileMapInfo::reserve_shared_memory(), which is not called on Windows.
   MemTracker::record_virtual_memory_type((address)base, mtClassShared);
 #endif
 
+
+  if (!verify_region_checksum(i)) {
+    return NULL;
+  }
+
+  *top_ret = base + size;
   return base;
 }
 
 static MemRegion *string_ranges = NULL;
 static MemRegion *open_archive_heap_ranges = NULL;

@@ -1038,31 +1044,10 @@
     _paths_misc_info = NULL;
   }
   return status;
 }
 
-// The following method is provided to see whether a given pointer
-// falls in the mapped shared metadata space.
-// Param:
-// p, The given pointer
-// Return:
-// True if the p is within the mapped shared space, otherwise, false.
-bool FileMapInfo::is_in_shared_space(const void* p) {
-  for (int i = 0; i < MetaspaceShared::num_non_heap_spaces; i++) {
-    char *base;
-    if (_header->_space[i]._used == 0) {
-      continue;
-    }
-    base = _header->region_addr(i);
-    if (p >= base && p < base + _header->_space[i]._used) {
-      return true;
-    }
-  }
-
-  return false;
-}
-
 // Check if a given address is within one of the shared regions
 bool FileMapInfo::is_in_shared_region(const void* p, int idx) {
   assert(idx == MetaspaceShared::ro ||
          idx == MetaspaceShared::rw ||
          idx == MetaspaceShared::mc ||
< prev index next >