Add workaround for 8233019 stuefe-new-metaspace-branch
authorstuefe
Tue, 29 Oct 2019 12:10:57 +0100
branchstuefe-new-metaspace-branch
changeset 58840 7678903a348f
parent 58839 d888a9d9f9a5
child 58880 e18d2d9d1515
Add workaround for 8233019
src/hotspot/share/memory/metaspace/settings.hpp
src/hotspot/share/memory/metaspace/spaceManager.cpp
--- a/src/hotspot/share/memory/metaspace/settings.hpp	Tue Oct 29 12:07:19 2019 +0100
+++ b/src/hotspot/share/memory/metaspace/settings.hpp	Tue Oct 29 12:10:57 2019 +0100
@@ -84,6 +84,10 @@
   // Must be a multiple of and not smaller than commit granularity.
   static size_t _uncommit_on_purge_min_word_size;
 
+  // As a workaround for JDK-8233019, make it possible to forbid returning adresses
+  // whose lower 32bits are zero.
+  static const bool _do_not_return_32bit_aligned_addresses = true;
+
 public:
 
   static size_t commit_granule_bytes()                        { return _commit_granule_bytes; }
@@ -99,6 +103,7 @@
   static bool delete_nodes_on_purge()                         { return _delete_nodes_on_purge; }
   static bool uncommit_on_purge()                             { return _uncommit_on_purge; }
   static size_t uncommit_on_purge_min_word_size()             { return _uncommit_on_purge_min_word_size; }
+  static bool do_not_return_32bit_aligned_addresses()         { return _do_not_return_32bit_aligned_addresses; }
 
   static void ergo_initialize();
 
--- a/src/hotspot/share/memory/metaspace/spaceManager.cpp	Tue Oct 29 12:07:19 2019 +0100
+++ b/src/hotspot/share/memory/metaspace/spaceManager.cpp	Tue Oct 29 12:10:57 2019 +0100
@@ -127,6 +127,14 @@
   log_debug(metaspace)("SpaceManager %s: allocated new chunk " METACHUNK_FORMAT " for requested word size " SIZE_FORMAT ".",
                        _name, METACHUNK_FORMAT_ARGS(c), requested_word_size);
 
+  // Workaround for JDK-8233019: never return space allocated at a 32bit aligned address
+  if (Settings::do_not_return_32bit_aligned_addresses() &&
+      (((intptr_t)c->base()) & 0xFFFFFFFF) == 0)
+  {
+    bool ignored;
+    c->allocate(1, &ignored);
+  }
+
   return c;
 
 }