Fixes for Windows x64 stuefe-new-metaspace-branch
authorstuefe
Thu, 12 Sep 2019 07:57:00 +0200
branchstuefe-new-metaspace-branch
changeset 58099 5aeb07390c74
parent 58085 a5f523f2ff91
child 58107 69c38b90014c
Fixes for Windows x64
src/hotspot/share/memory/metaspace/chunkManager.hpp
src/hotspot/share/memory/metaspace/commitMask.cpp
src/hotspot/share/memory/metaspace/metachunk.hpp
src/hotspot/share/memory/metaspace/rootChunkArea.cpp
src/hotspot/share/memory/metaspace/rootChunkArea.hpp
src/hotspot/share/memory/metaspace/settings.cpp
src/hotspot/share/memory/metaspace/spaceManager.hpp
src/hotspot/share/memory/metaspace/virtualSpaceList.cpp
test/hotspot/gtest/metaspace/metaspaceTestsCommon.cpp
test/hotspot/gtest/metaspace/metaspaceTestsCommon.hpp
test/hotspot/gtest/metaspace/test_commitmask.cpp
test/hotspot/gtest/metaspace/test_spacemanager.cpp
test/hotspot/gtest/metaspace/test_virtualspacenode.cpp
--- a/src/hotspot/share/memory/metaspace/chunkManager.hpp	Wed Sep 11 17:36:28 2019 +0200
+++ b/src/hotspot/share/memory/metaspace/chunkManager.hpp	Thu Sep 12 07:57:00 2019 +0200
@@ -34,7 +34,7 @@
 namespace metaspace {
 
 class VirtualSpaceList;
-class cm_stats_t;
+struct cm_stats_t;
 
 // class ChunkManager
 //
--- a/src/hotspot/share/memory/metaspace/commitMask.cpp	Wed Sep 11 17:36:28 2019 +0200
+++ b/src/hotspot/share/memory/metaspace/commitMask.cpp	Thu Sep 12 07:57:00 2019 +0200
@@ -29,6 +29,7 @@
 
 #include "memory/metaspace/commitMask.hpp"
 #include "memory/metaspace/metaspaceCommon.hpp"
+#include "memory/metaspace/settings.hpp"
 #include "runtime/stubRoutines.hpp"
 
 #include "utilities/align.hpp"
@@ -61,10 +62,6 @@
   assert_is_aligned(_base, _words_per_bit * BytesPerWord);
   assert_is_aligned(_word_size, _words_per_bit);
 
-  if (slow) {
-    assert(CanUseSafeFetch32, "We need SafeFetch for this test.");
-  }
-
   if (do_touch_test) {
     for (idx_t i = 0; i < size(); i ++) {
       const MetaWord* const p = _base + (i * _words_per_bit);
@@ -77,7 +74,7 @@
           // Note: results may differ between platforms. On Linux, this should be true since
           // we uncommit memory by setting protection to PROT_NONE. We may have to look if
           // this works as expected on other platforms.
-          if (CanUseSafeFetch32() && TEST_UNCOMMITTED_REGION) {
+          if (TEST_UNCOMMITTED_REGION && CanUseSafeFetch32()) {
             assert(os::is_readable_pointer(p) == false,
                    "index %u, pointer " PTR_FORMAT ", should not be accessible.",
                    (unsigned)i, p2i(p));
--- a/src/hotspot/share/memory/metaspace/metachunk.hpp	Wed Sep 11 17:36:28 2019 +0200
+++ b/src/hotspot/share/memory/metaspace/metachunk.hpp	Thu Sep 12 07:57:00 2019 +0200
@@ -391,11 +391,11 @@
   // Returns size, in words, of committed space of all chunks in all list.
   // Note: walks lists.
   size_t total_committed_word_size() const {
-    size_t l = 0;
+    size_t sum = 0;
     for (chklvl_t l = chklvl::LOWEST_CHUNK_LEVEL; l <= chklvl::HIGHEST_CHUNK_LEVEL; l ++) {
-      l += list_for_level(l)->committed_word_size();
+      sum += list_for_level(l)->committed_word_size();
     }
-    return l;
+    return sum;
   }
 
   DEBUG_ONLY(void verify(bool slow) const;)
--- a/src/hotspot/share/memory/metaspace/rootChunkArea.cpp	Wed Sep 11 17:36:28 2019 +0200
+++ b/src/hotspot/share/memory/metaspace/rootChunkArea.cpp	Thu Sep 12 07:57:00 2019 +0200
@@ -541,7 +541,7 @@
 // a given memory range. Memory range must be a multiple of root chunk size.
 RootChunkAreaLUT::RootChunkAreaLUT(const MetaWord* base, size_t word_size)
   : _base(base),
-    _num(word_size / chklvl::MAX_CHUNK_WORD_SIZE),
+    _num((int)(word_size / chklvl::MAX_CHUNK_WORD_SIZE)),
     _arr(NULL)
 {
   assert_is_aligned(word_size, chklvl::MAX_CHUNK_WORD_SIZE);
--- a/src/hotspot/share/memory/metaspace/rootChunkArea.hpp	Wed Sep 11 17:36:28 2019 +0200
+++ b/src/hotspot/share/memory/metaspace/rootChunkArea.hpp	Thu Sep 12 07:57:00 2019 +0200
@@ -155,7 +155,7 @@
   // area this address falls into.
   int index_by_address(const MetaWord* p) const {
     DEBUG_ONLY(check_pointer(p);)
-    int idx = (p - base()) / chklvl::MAX_CHUNK_WORD_SIZE;
+    int idx = (int)((p - base()) / chklvl::MAX_CHUNK_WORD_SIZE);
     assert(idx >= 0 && idx < _num, "Sanity");
     return idx;
   }
--- a/src/hotspot/share/memory/metaspace/settings.cpp	Wed Sep 11 17:36:28 2019 +0200
+++ b/src/hotspot/share/memory/metaspace/settings.cpp	Thu Sep 12 07:57:00 2019 +0200
@@ -31,6 +31,7 @@
 #include "logging/logStream.hpp"
 
 #include "memory/metaspace/chunkLevel.hpp"
+#include "memory/metaspace/settings.hpp"
 
 #include "utilities/globalDefinitions.hpp"
 #include "utilities/debug.hpp"
--- a/src/hotspot/share/memory/metaspace/spaceManager.hpp	Wed Sep 11 17:36:28 2019 +0200
+++ b/src/hotspot/share/memory/metaspace/spaceManager.hpp	Thu Sep 12 07:57:00 2019 +0200
@@ -39,7 +39,7 @@
 
 namespace metaspace {
 
-class sm_stats_t;
+struct sm_stats_t;
 
 // The SpaceManager:
 // - keeps a list of chunks-in-use by the class loader, as well as a current chunk used
--- a/src/hotspot/share/memory/metaspace/virtualSpaceList.cpp	Wed Sep 11 17:36:28 2019 +0200
+++ b/src/hotspot/share/memory/metaspace/virtualSpaceList.cpp	Thu Sep 12 07:57:00 2019 +0200
@@ -168,7 +168,7 @@
       if (_first_node == vsn) {
         _first_node = next_vsn;
       }
-      DEBUG_ONLY(vsn = (VirtualSpaceNode*)0xdeadbeef;)
+      DEBUG_ONLY(vsn = (VirtualSpaceNode*)((uintptr_t)(0xdeadbeef));)
       if (prev_vsn != NULL) {
         prev_vsn->set_next(next_vsn);
       }
--- a/test/hotspot/gtest/metaspace/metaspaceTestsCommon.cpp	Wed Sep 11 17:36:28 2019 +0200
+++ b/test/hotspot/gtest/metaspace/metaspaceTestsCommon.cpp	Thu Sep 12 07:57:00 2019 +0200
@@ -29,6 +29,9 @@
 
 #include "utilities/globalDefinitions.hpp"
 
+#ifdef _WIN32
+#include <psapi.h>
+#endif
 
 void calc_random_range(size_t outer_range_len, range_t* out, size_t alignment) {
 
--- a/test/hotspot/gtest/metaspace/metaspaceTestsCommon.hpp	Wed Sep 11 17:36:28 2019 +0200
+++ b/test/hotspot/gtest/metaspace/metaspaceTestsCommon.hpp	Thu Sep 12 07:57:00 2019 +0200
@@ -83,18 +83,18 @@
 // A little mockup to mimick and test the CommitMask in various tests
 
 class TestMap {
-  const int _len;
+  const size_t _len;
   char* _arr;
 public:
-  TestMap(int len) : _len(len), _arr(NULL) {
+  TestMap(size_t len) : _len(len), _arr(NULL) {
     _arr = NEW_C_HEAP_ARRAY(char, len, mtInternal);
     memset(_arr, 0, _len);
   }
   ~TestMap() { FREE_C_HEAP_ARRAY(char, _arr); }
 
-  int get_num_set(int from, int to) const {
+  int get_num_set(size_t from, size_t to) const {
     int result = 0;
-    for(int i = from; i < to; i ++) {
+    for(size_t i = from; i < to; i ++) {
       if (_arr[i] > 0) {
         result ++;
       }
@@ -102,13 +102,13 @@
     return result;
   }
 
-  int get_num_set() const { return get_num_set(0, _len); }
+  size_t get_num_set() const { return get_num_set(0, _len); }
 
-  void set_range(int from, int to) {
+  void set_range(size_t from, size_t to) {
     memset(_arr + from, 1, to - from);
   }
 
-  void clear_range(int from, int to) {
+  void clear_range(size_t from, size_t to) {
     memset(_arr + from, 0, to - from);
   }
 
--- a/test/hotspot/gtest/metaspace/test_commitmask.cpp	Wed Sep 11 17:36:28 2019 +0200
+++ b/test/hotspot/gtest/metaspace/test_commitmask.cpp	Thu Sep 12 07:57:00 2019 +0200
@@ -24,7 +24,9 @@
 
 
 #include "precompiled.hpp"
-#include "metaspace/metaspaceTestsCommon.hpp"
+#include "runtime/os.hpp"
+
+#include "metaspaceTestsCommon.hpp"
 
 static int get_random(int limit) { return os::random() % limit; }
 
@@ -43,8 +45,8 @@
   // Return a random sub range within [_base.._base + word_size),
   // aligned to granule size
   const MetaWord* calc_random_subrange(size_t* p_word_size) {
-    size_t l1 = get_random(_word_size);
-    size_t l2 = get_random(_word_size);
+    size_t l1 = get_random((int)_word_size);
+    size_t l2 = get_random((int)_word_size);
     if (l1 > l2) {
       size_t l = l1;
       l1 = l2;
--- a/test/hotspot/gtest/metaspace/test_spacemanager.cpp	Wed Sep 11 17:36:28 2019 +0200
+++ b/test/hotspot/gtest/metaspace/test_spacemanager.cpp	Thu Sep 12 07:57:00 2019 +0200
@@ -117,7 +117,7 @@
 
 
     size_t words_allocated() const        { return _words_allocated; }
-    size_t num_allocations() const        { return _num_allocations; }
+    int num_allocations() const           { return _num_allocations; }
 
     int index() const                     { return _index; }
 
@@ -573,7 +573,7 @@
 static RandSizeGenerator rgen_1K_no_outliers(1, 128);
 
 // generates sizes between 1 and 256 words, small chance of large outliers
-static RandSizeGenerator rgen_1K_some_huge_outliers(1, 256, 0.05, MAX_CHUNK_WORD_SIZE / 64, MAX_CHUNK_WORD_SIZE / 2);
+static RandSizeGenerator rgen_1K_some_huge_outliers(1, 256, 0.05f, MAX_CHUNK_WORD_SIZE / 64, MAX_CHUNK_WORD_SIZE / 2);
 
 // generates medium sized sizes
 static RandSizeGenerator rgen_32K_no_outliers(128, 0x4000);
--- a/test/hotspot/gtest/metaspace/test_virtualspacenode.cpp	Wed Sep 11 17:36:28 2019 +0200
+++ b/test/hotspot/gtest/metaspace/test_virtualspacenode.cpp	Thu Sep 12 07:57:00 2019 +0200
@@ -410,7 +410,7 @@
     // To capture split-off chunks. Note: it is okay to use this here as a temp object.
     MetachunkListCluster freelist;
 
-    const int granules_per_root_chunk = c->word_size() / Settings::commit_granule_words();
+    const int granules_per_root_chunk = (int)(c->word_size() / Settings::commit_granule_words());
 
     for (int granules_to_commit = 0; granules_to_commit < granules_per_root_chunk; granules_to_commit ++) {