# HG changeset patch # User stuefe # Date 1572347457 -3600 # Node ID 7678903a348f9e317652ed6373edece37395c347 # Parent d888a9d9f9a51ff9181f6e350dd118a220c504bd Add workaround for 8233019 diff -r d888a9d9f9a5 -r 7678903a348f src/hotspot/share/memory/metaspace/settings.hpp --- 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(); diff -r d888a9d9f9a5 -r 7678903a348f src/hotspot/share/memory/metaspace/spaceManager.cpp --- 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; }