src/hotspot/share/memory/metaspace/leftOverBins.inline.hpp
branchstuefe-new-metaspace-branch
changeset 59238 6ce12ce00d3e
parent 59155 b537e6386306
--- a/src/hotspot/share/memory/metaspace/leftOverBins.inline.hpp	Fri Nov 01 10:28:15 2019 +0100
+++ b/src/hotspot/share/memory/metaspace/leftOverBins.inline.hpp	Sat Nov 23 11:05:16 2019 +0100
@@ -27,6 +27,7 @@
 #define SHARE_MEMORY_METASPACE_LEFTOVERBINS_INLINE_HPP
 
 #include "memory/allocation.hpp"
+#include "memory/metaspace/blockListArray.inline.hpp"
 #include "memory/metaspace/leftOverBins.hpp"
 #include "utilities/debug.hpp"
 #include "utilities/globalDefinitions.hpp"
@@ -35,108 +36,6 @@
 namespace metaspace {
 
 
-// Starting at (including) pos, find the position of the next 1 bit.
-// Return -1 if not found.
-int BinMap::find_next_set_bit(int pos) const {
-  if (get_bit(pos)) {
-    return pos;
-  }
-  mask_type m2 = _mask;
-  int pos2 = pos + 1;
-  m2 >>= pos2;
-  if (m2 > 0) {
-    while ((m2 & (mask_type)1) == 0) {
-      m2 >>= 1;
-      pos2 ++;
-    }
-    return pos2;
-  }
-  return -1;
-}
-
-///////////////////////////////////////
-
-template <size_t min_word_size, size_t spread, int num_bins>
-void Bins<min_word_size, spread, num_bins>::put(MetaWord* p, size_t word_size) {
-  assert(word_size >= minimal_word_size() && word_size < maximal_word_size(), "Invalid word size");
-  block_t* b = (block_t*)p;
-  int bno = bin_for_size(word_size);
-  assert(bno >= 0 && bno < num_bins, "Sanity");
-  assert(b != _bins[bno], "double add?");
-  b->next = _bins[bno];
-  b->size = word_size;
-  _bins[bno] = b;
-  _mask.set_bit(bno);
-}
-
-template <size_t min_word_size, size_t spread, int num_bins>
-block_t* Bins<min_word_size, spread, num_bins>::get(size_t word_size) {
-  // Adjust size for spread (we need the bin number which guarantees word_size).
-  word_size += (spread - 1);
-  if (word_size >= maximal_word_size()) {
-    return NULL;
-  }
-  int bno = bin_for_size(word_size);
-  bno = _mask.find_next_set_bit(bno);
-  if (bno != -1) {
-    assert(bno >= 0 && bno < num_bins, "Sanity");
-    assert(_bins[bno] != NULL, "Sanity");
-    block_t* b = _bins[bno];
-    _bins[bno] = b->next;
-    if (_bins[bno] == NULL) {
-      _mask.clr_bit(bno);
-    }
-    return b;
-  }
-  return NULL;
-}
-
-#ifdef ASSERT
-template <size_t min_word_size, size_t spread, int num_bins>
-void Bins<min_word_size, spread, num_bins>::verify() const {
-  for (int i = 0; i < num_bins; i ++) {
-    assert(_mask.get_bit(i) == (_bins[i] != NULL), "Sanity");
-    const size_t min_size = minimal_word_size_in_bin(i);
-    const size_t max_size = maximal_word_size_in_bin(i);
-    for(block_t* b = _bins[i]; b != NULL; b = b->next) {
-      assert(b->size >= min_size && b->size < max_size, "Sanity");
-    }
-  }
-}
-#endif // ASSERT
-
-
-template <size_t min_word_size, size_t spread, int num_bins>
-void Bins<min_word_size, spread, num_bins>::statistics(block_stats_t* stats) const {
-  for (int i = 0; i < num_bins; i ++) {
-    for(block_t* b = _bins[i]; b != NULL; b = b->next) {
-      stats->num_blocks ++;
-      stats->word_size += b->size;
-    }
-  }
-}
-
-template <size_t min_word_size, size_t spread, int num_bins>
-void Bins<min_word_size, spread, num_bins>::print(outputStream* st) const {
-  bool first = true;
-  for (int i = 0; i < num_bins; i ++) {
-    int n = 0;
-    for(block_t* b = _bins[i]; b != NULL; b = b->next) {
-      n ++;
-    }
-    if (n > 0) {
-      if (!first) {
-        st->print(", ");
-      } else {
-        first = false;
-      }
-      st->print(SIZE_FORMAT "=%d", minimal_word_size_in_bin(i), n);
-    }
-  }
-}
-
-
-
 ///////////////////////////////////////
 
 // Take the topmost block from the large block reserve list