changeset 52314:e53af5fa0dae

8212205: VM asserts after CDS archive has been unmapped Reviewed-by: dholmes, jiangli, hseigel, stuefe
author iklam
date Thu, 25 Oct 2018 11:23:43 -0700
parents f300b4ca2637
children 50426919edbb
files src/hotspot/share/memory/allocation.hpp src/hotspot/share/memory/filemap.cpp src/hotspot/share/memory/metaspaceShared.cpp src/hotspot/share/memory/metaspaceShared.hpp
diffstat 4 files changed, 11 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/memory/allocation.hpp	Mon Oct 29 08:34:33 2018 -0700
+++ b/src/hotspot/share/memory/allocation.hpp	Thu Oct 25 11:23:43 2018 -0700
@@ -244,7 +244,6 @@
 class MetaspaceClosure;
 
 class MetaspaceObj {
-  friend class MetaspaceShared;
   // When CDS is enabled, all shared metaspace objects are mapped
   // into a single contiguous memory block, so we can use these
   // two pointers to quickly determine if something is in the
@@ -263,6 +262,13 @@
   }
   void print_address_on(outputStream* st) const;  // nonvirtual address printing
 
+  static void set_shared_metaspace_range(void* base, void* top) {
+    _shared_metaspace_base = base;
+    _shared_metaspace_top = top;
+  }
+  static void* shared_metaspace_base() { return _shared_metaspace_base; }
+  static void* shared_metaspace_top()  { return _shared_metaspace_top;  }
+
 #define METASPACE_OBJ_TYPES_DO(f) \
   f(Class) \
   f(Symbol) \
--- a/src/hotspot/share/memory/filemap.cpp	Mon Oct 29 08:34:33 2018 -0700
+++ b/src/hotspot/share/memory/filemap.cpp	Thu Oct 25 11:23:43 2018 -0700
@@ -1355,6 +1355,8 @@
 
 // Unmap mapped regions of shared space.
 void FileMapInfo::stop_sharing_and_unmap(const char* msg) {
+  MetaspaceObj::set_shared_metaspace_range(NULL, NULL);
+
   FileMapInfo *map_info = FileMapInfo::current_info();
   if (map_info) {
     map_info->fail_continue("%s", msg);
--- a/src/hotspot/share/memory/metaspaceShared.cpp	Mon Oct 29 08:34:33 2018 -0700
+++ b/src/hotspot/share/memory/metaspaceShared.cpp	Thu Oct 25 11:23:43 2018 -0700
@@ -1957,8 +1957,7 @@
     assert(ro_top == md_base, "must be");
     assert(md_top == od_base, "must be");
 
-    MetaspaceObj::_shared_metaspace_base = (void*)mc_base;
-    MetaspaceObj::_shared_metaspace_top  = (void*)od_top;
+    MetaspaceObj::set_shared_metaspace_range((void*)mc_base, (void*)od_top);
     return true;
   } else {
     // If there was a failure in mapping any of the spaces, unmap the ones
--- a/src/hotspot/share/memory/metaspaceShared.hpp	Mon Oct 29 08:34:33 2018 -0700
+++ b/src/hotspot/share/memory/metaspaceShared.hpp	Thu Oct 25 11:23:43 2018 -0700
@@ -125,7 +125,7 @@
   static bool is_in_shared_metaspace(const void* p) {
     // If no shared metaspace regions are mapped, MetaspceObj::_shared_metaspace_{base,top} will
     // both be NULL and all values of p will be rejected quickly.
-    return (p < MetaspaceObj::_shared_metaspace_top && p >= MetaspaceObj::_shared_metaspace_base);
+    return (p < MetaspaceObj::shared_metaspace_top() && p >= MetaspaceObj::shared_metaspace_base());
   }
 
   // Return true if given address is in the shared region corresponding to the idx