hotspot/src/share/vm/gc/shared/blockOffsetTable.hpp
changeset 35469 17ea1b453dd5
parent 35461 1068dcb8d315
--- a/hotspot/src/share/vm/gc/shared/blockOffsetTable.hpp	Sun Jan 10 20:02:50 2016 -0500
+++ b/hotspot/src/share/vm/gc/shared/blockOffsetTable.hpp	Mon Jan 11 09:14:01 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -46,6 +46,34 @@
 
 class ContiguousSpace;
 
+class BOTConstants : public AllStatic {
+public:
+  static const uint LogN = 9;
+  static const uint LogN_words = LogN - LogHeapWordSize;
+  static const uint N_bytes = 1 << LogN;
+  static const uint N_words = 1 << LogN_words;
+  // entries "e" of at least N_words mean "go back by Base^(e-N_words)."
+  // All entries are less than "N_words + N_powers".
+  static const uint LogBase = 4;
+  static const uint Base = (1 << LogBase);
+  static const uint N_powers = 14;
+
+  static size_t power_to_cards_back(uint i) {
+    return (size_t)1 << (LogBase * i);
+  }
+  static size_t power_to_words_back(uint i) {
+    return power_to_cards_back(i) * N_words;
+  }
+  static size_t entry_to_cards_back(u_char entry) {
+    assert(entry >= N_words, "Precondition");
+    return power_to_cards_back(entry - N_words);
+  }
+  static size_t entry_to_words_back(u_char entry) {
+    assert(entry >= N_words, "Precondition");
+    return power_to_words_back(entry - N_words);
+  }
+};
+
 //////////////////////////////////////////////////////////////////////////
 // The BlockOffsetTable "interface"
 //////////////////////////////////////////////////////////////////////////
@@ -109,13 +137,6 @@
   friend class VMStructs;
 
  private:
-  enum SomePrivateConstants {
-    LogN = 9,
-    LogN_words = LogN - LogHeapWordSize,
-    N_bytes = 1 << LogN,
-    N_words = 1 << LogN_words
-  };
-
   bool _init_to_zero;
 
   // The reserved region covered by the shared array.
@@ -163,7 +184,7 @@
     check_reducing_assertion(reducing);
     assert(index < _vs.committed_size(), "index out of range");
     assert(high >= low, "addresses out of order");
-    assert(pointer_delta(high, low) <= N_words, "offset too large");
+    assert(pointer_delta(high, low) <= BOTConstants::N_words, "offset too large");
     assert(!reducing || _offset_array[index] >=  (u_char)pointer_delta(high, low),
            "Not reducing");
     _offset_array[index] = (u_char)pointer_delta(high, low);
@@ -174,7 +195,7 @@
     assert(index_for(right - 1) < _vs.committed_size(),
            "right address out of range");
     assert(left  < right, "Heap addresses out of order");
-    size_t num_cards = pointer_delta(right, left) >> LogN_words;
+    size_t num_cards = pointer_delta(right, left) >> BOTConstants::LogN_words;
 
     fill_range(index_for(left), num_cards, offset);
   }
@@ -191,7 +212,7 @@
   void check_offset_array(size_t index, HeapWord* high, HeapWord* low) const {
     assert(index < _vs.committed_size(), "index out of range");
     assert(high >= low, "addresses out of order");
-    assert(pointer_delta(high, low) <= N_words, "offset too large");
+    assert(pointer_delta(high, low) <= BOTConstants::N_words, "offset too large");
     assert(_offset_array[index] == pointer_delta(high, low),
            "Wrong offset");
   }
@@ -206,7 +227,7 @@
   // to be reserved.
 
   size_t compute_size(size_t mem_region_words) {
-    size_t number_of_slots = (mem_region_words / N_words) + 1;
+    size_t number_of_slots = (mem_region_words / BOTConstants::N_words) + 1;
     return ReservedSpace::allocation_align_size_up(number_of_slots);
   }
 
@@ -248,7 +269,6 @@
 //////////////////////////////////////////////////////////////////////////
 class BlockOffsetArray: public BlockOffsetTable {
   friend class VMStructs;
-  friend class G1BlockOffsetTablePart; // temp. until we restructure and cleanup
  protected:
   // The following enums are used by do_block_internal() below
   enum Action {
@@ -258,31 +278,6 @@
                         // (see verify_single_block()).
   };
 
-  enum SomePrivateConstants {
-    N_words = BlockOffsetSharedArray::N_words,
-    LogN    = BlockOffsetSharedArray::LogN,
-    // entries "e" of at least N_words mean "go back by Base^(e-N_words)."
-    // All entries are less than "N_words + N_powers".
-    LogBase = 4,
-    Base = (1 << LogBase),
-    N_powers = 14
-  };
-
-  static size_t power_to_cards_back(uint i) {
-    return (size_t)1 << (LogBase * i);
-  }
-  static size_t power_to_words_back(uint i) {
-    return power_to_cards_back(i) * N_words;
-  }
-  static size_t entry_to_cards_back(u_char entry) {
-    assert(entry >= N_words, "Precondition");
-    return power_to_cards_back(entry - N_words);
-  }
-  static size_t entry_to_words_back(u_char entry) {
-    assert(entry >= N_words, "Precondition");
-    return power_to_words_back(entry - N_words);
-  }
-
   // The shared array, which is shared with other BlockOffsetArray's
   // corresponding to different spaces within a generation or span of
   // memory.
@@ -344,7 +339,7 @@
       assert(_array->is_card_boundary(new_end),
              "new _end would not be a card boundary");
       // set all the newly added cards
-      _array->set_offset_array(_end, new_end, N_words);
+      _array->set_offset_array(_end, new_end, BOTConstants::N_words);
     }
     _end = new_end;  // update _end
   }