< prev index next >

test/hotspot/gtest/gc/shared/test_oopStorage.cpp

Print this page
rev 50951 : imported patch rename_AllocateList
rev 50954 : imported patch rename_allocate_list
rev 50955 : imported patch rename_allocate_mutex

@@ -50,27 +50,27 @@
 
 // Access storage internals.
 class OopStorage::TestAccess : public AllStatic {
 public:
   typedef OopStorage::Block Block;
-  typedef OopStorage::AllocateList AllocateList;
+  typedef OopStorage::AllocationList AllocationList;
   typedef OopStorage::ActiveArray ActiveArray;
 
   static ActiveArray& active_array(const OopStorage& storage) {
     return *storage._active_array;
   }
 
-  static AllocateList& allocate_list(OopStorage& storage) {
-    return storage._allocate_list;
+  static AllocationList& allocation_list(OopStorage& storage) {
+    return storage._allocation_list;
   }
 
-  static const AllocateList& allocate_list(const OopStorage& storage) {
-    return storage._allocate_list;
+  static const AllocationList& allocation_list(const OopStorage& storage) {
+    return storage._allocation_list;
   }
 
-  static Mutex* allocate_mutex(const OopStorage& storage) {
-    return storage._allocate_mutex;
+  static Mutex* allocation_mutex(const OopStorage& storage) {
+    return storage._allocation_mutex;
   }
 
   static bool reduce_deferred_updates(OopStorage& storage) {
     return storage.reduce_deferred_updates();
   }

@@ -107,40 +107,40 @@
 
 // The "Oop" prefix is to avoid collision with similar opto names when
 // building with precompiled headers, or for consistency with that
 // workaround.  There really should be an opto namespace.
 typedef TestAccess::Block OopBlock;
-typedef TestAccess::AllocateList AllocateList;
+typedef TestAccess::AllocationList AllocationList;
 typedef TestAccess::ActiveArray ActiveArray;
 
 // Using EXPECT_EQ can't use NULL directly. Otherwise AIX build breaks.
 const OopBlock* const NULL_BLOCK = NULL;
 
-static size_t list_length(const AllocateList& list) {
+static size_t list_length(const AllocationList& list) {
   size_t result = 0;
   for (const OopBlock* block = list.chead();
        block != NULL;
        block = list.next(*block)) {
     ++result;
   }
   return result;
 }
 
-static void clear_list(AllocateList& list) {
+static void clear_list(AllocationList& list) {
   OopBlock* next;
   for (OopBlock* block = list.head(); block != NULL; block = next) {
     next = list.next(*block);
     list.unlink(*block);
   }
 }
 
-static bool is_list_empty(const AllocateList& list) {
+static bool is_list_empty(const AllocationList& list) {
   return list.chead() == NULL;
 }
 
 static bool process_deferred_updates(OopStorage& storage) {
-  MutexLockerEx ml(TestAccess::allocate_mutex(storage), Mutex::_no_safepoint_check_flag);
+  MutexLockerEx ml(TestAccess::allocation_mutex(storage), Mutex::_no_safepoint_check_flag);
   bool result = false;
   while (TestAccess::reduce_deferred_updates(storage)) {
     result = true;
   }
   return result;

@@ -153,11 +153,11 @@
     process_deferred_updates(storage);
   }
 }
 
 static size_t empty_block_count(const OopStorage& storage) {
-  const AllocateList& list = TestAccess::allocate_list(storage);
+  const AllocationList& list = TestAccess::allocation_list(storage);
   size_t count = 0;
   for (const OopBlock* block = list.ctail();
        (block != NULL) && block->is_empty();
        ++count, block = list.prev(*block))
   {}

@@ -181,11 +181,11 @@
 class OopStorageTest : public ::testing::Test {
 public:
   OopStorageTest();
   ~OopStorageTest();
 
-  Mutex _allocate_mutex;
+  Mutex _allocation_mutex;
   Mutex _active_mutex;
   OopStorage _storage;
 
   static const int _active_rank = Mutex::leaf - 1;
   static const int _allocate_rank = Mutex::leaf;

@@ -193,23 +193,23 @@
   class CountingIterateClosure;
   template<bool is_const> class VM_CountAtSafepoint;
 };
 
 OopStorageTest::OopStorageTest() :
-  _allocate_mutex(_allocate_rank,
-                  "test_OopStorage_allocate",
+  _allocation_mutex(_allocate_rank,
+                    "test_OopStorage_allocation",
                   false,
                   Mutex::_safepoint_check_never),
   _active_mutex(_active_rank,
                 "test_OopStorage_active",
                 false,
                 Mutex::_safepoint_check_never),
-  _storage("Test Storage", &_allocate_mutex, &_active_mutex)
+  _storage("Test Storage", &_allocation_mutex, &_active_mutex)
 { }
 
 OopStorageTest::~OopStorageTest() {
-  clear_list(TestAccess::allocate_list(_storage));
+  clear_list(TestAccess::allocation_list(_storage));
 }
 
 class OopStorageTestWithAllocation : public OopStorageTest {
 public:
   OopStorageTestWithAllocation();

@@ -241,14 +241,14 @@
 
 private:
   OopStorage* _storage;
 };
 
-static bool is_allocate_list_sorted(const OopStorage& storage) {
-  // The allocate_list isn't strictly sorted.  Rather, all empty
+static bool is_allocation_list_sorted(const OopStorage& storage) {
+  // The allocation_list isn't strictly sorted.  Rather, all empty
   // blocks are segregated to the end of the list.
-  const AllocateList& list = TestAccess::allocate_list(storage);
+  const AllocationList& list = TestAccess::allocation_list(storage);
   const OopBlock* block = list.ctail();
   for ( ; (block != NULL) && block->is_empty(); block = list.prev(*block)) {}
   for ( ; block != NULL; block = list.prev(*block)) {
     if (block->is_empty()) {
       return false;

@@ -267,23 +267,23 @@
   return total_count;
 }
 
 TEST_VM_F(OopStorageTest, allocate_one) {
   EXPECT_EQ(0u, active_count(_storage));
-  EXPECT_TRUE(is_list_empty(TestAccess::allocate_list(_storage)));
+  EXPECT_TRUE(is_list_empty(TestAccess::allocation_list(_storage)));
 
   oop* ptr = _storage.allocate();
   EXPECT_TRUE(ptr != NULL);
   EXPECT_EQ(1u, _storage.allocation_count());
 
   EXPECT_EQ(1u, active_count(_storage));
   EXPECT_EQ(1u, _storage.block_count());
-  EXPECT_EQ(1u, list_length(TestAccess::allocate_list(_storage)));
+  EXPECT_EQ(1u, list_length(TestAccess::allocation_list(_storage)));
 
   EXPECT_EQ(0u, empty_block_count(_storage));
 
-  const OopBlock* block = TestAccess::allocate_list(_storage).chead();
+  const OopBlock* block = TestAccess::allocation_list(_storage).chead();
   EXPECT_NE(block, (OopBlock*)NULL);
   EXPECT_EQ(block, active_head(_storage));
   EXPECT_FALSE(TestAccess::block_is_empty(*block));
   EXPECT_FALSE(TestAccess::block_is_full(*block));
   EXPECT_EQ(1u, TestAccess::block_allocation_count(*block));

@@ -291,15 +291,15 @@
   release_entry(_storage, ptr);
   EXPECT_EQ(0u, _storage.allocation_count());
 
   EXPECT_EQ(1u, active_count(_storage));
   EXPECT_EQ(1u, _storage.block_count());
-  EXPECT_EQ(1u, list_length(TestAccess::allocate_list(_storage)));
+  EXPECT_EQ(1u, list_length(TestAccess::allocation_list(_storage)));
 
   EXPECT_EQ(1u, empty_block_count(_storage));
 
-  const OopBlock* new_block = TestAccess::allocate_list(_storage).chead();
+  const OopBlock* new_block = TestAccess::allocation_list(_storage).chead();
   EXPECT_EQ(block, new_block);
   EXPECT_EQ(block, active_head(_storage));
   EXPECT_TRUE(TestAccess::block_is_empty(*block));
   EXPECT_FALSE(TestAccess::block_is_full(*block));
   EXPECT_EQ(0u, TestAccess::block_allocation_count(*block));

@@ -307,15 +307,15 @@
 
 TEST_VM_F(OopStorageTest, allocation_count) {
   static const size_t max_entries = 1000;
   oop* entries[max_entries];
 
-  AllocateList& allocate_list = TestAccess::allocate_list(_storage);
+  AllocationList& allocation_list = TestAccess::allocation_list(_storage);
 
   EXPECT_EQ(0u, active_count(_storage));
   EXPECT_EQ(0u, _storage.block_count());
-  EXPECT_TRUE(is_list_empty(allocate_list));
+  EXPECT_TRUE(is_list_empty(allocation_list));
 
   size_t allocated = 0;
   for ( ; allocated < max_entries; ++allocated) {
     EXPECT_EQ(allocated, _storage.allocation_count());
     if (active_count(_storage) != 0) {

@@ -324,138 +324,138 @@
       const OopBlock& block = *TestAccess::active_array(_storage).at(0);
       EXPECT_EQ(allocated, TestAccess::block_allocation_count(block));
       if (TestAccess::block_is_full(block)) {
         break;
       } else {
-        EXPECT_FALSE(is_list_empty(allocate_list));
-        EXPECT_EQ(&block, allocate_list.chead());
+        EXPECT_FALSE(is_list_empty(allocation_list));
+        EXPECT_EQ(&block, allocation_list.chead());
       }
     }
     entries[allocated] = _storage.allocate();
   }
 
   EXPECT_EQ(allocated, _storage.allocation_count());
   EXPECT_EQ(1u, active_count(_storage));
   EXPECT_EQ(1u, _storage.block_count());
-  EXPECT_TRUE(is_list_empty(allocate_list));
+  EXPECT_TRUE(is_list_empty(allocation_list));
   const OopBlock& block = *TestAccess::active_array(_storage).at(0);
   EXPECT_TRUE(TestAccess::block_is_full(block));
   EXPECT_EQ(allocated, TestAccess::block_allocation_count(block));
 
   for (size_t i = 0; i < allocated; ++i) {
     release_entry(_storage, entries[i]);
     size_t remaining = allocated - (i + 1);
     EXPECT_EQ(remaining, TestAccess::block_allocation_count(block));
     EXPECT_EQ(remaining, _storage.allocation_count());
-    EXPECT_FALSE(is_list_empty(allocate_list));
+    EXPECT_FALSE(is_list_empty(allocation_list));
   }
 }
 
 TEST_VM_F(OopStorageTest, allocate_many) {
   static const size_t max_entries = 1000;
   oop* entries[max_entries];
 
-  AllocateList& allocate_list = TestAccess::allocate_list(_storage);
+  AllocationList& allocation_list = TestAccess::allocation_list(_storage);
 
   EXPECT_EQ(0u, empty_block_count(_storage));
 
   entries[0] = _storage.allocate();
   ASSERT_TRUE(entries[0] != NULL);
   EXPECT_EQ(1u, active_count(_storage));
   EXPECT_EQ(1u, _storage.block_count());
-  EXPECT_EQ(1u, list_length(allocate_list));
+  EXPECT_EQ(1u, list_length(allocation_list));
   EXPECT_EQ(0u, empty_block_count(_storage));
 
   const OopBlock* block = TestAccess::active_array(_storage).at(0);
   EXPECT_EQ(1u, TestAccess::block_allocation_count(*block));
-  EXPECT_EQ(block, allocate_list.chead());
+  EXPECT_EQ(block, allocation_list.chead());
 
   for (size_t i = 1; i < max_entries; ++i) {
     entries[i] = _storage.allocate();
     EXPECT_EQ(i + 1, _storage.allocation_count());
     ASSERT_TRUE(entries[i] != NULL);
     EXPECT_EQ(0u, empty_block_count(_storage));
 
     if (block == NULL) {
-      ASSERT_FALSE(is_list_empty(allocate_list));
-      EXPECT_EQ(1u, list_length(allocate_list));
-      block = allocate_list.chead();
+      ASSERT_FALSE(is_list_empty(allocation_list));
+      EXPECT_EQ(1u, list_length(allocation_list));
+      block = allocation_list.chead();
       EXPECT_EQ(1u, TestAccess::block_allocation_count(*block));
       EXPECT_EQ(block, active_head(_storage));
     } else if (TestAccess::block_is_full(*block)) {
-      EXPECT_TRUE(is_list_empty(allocate_list));
+      EXPECT_TRUE(is_list_empty(allocation_list));
       block = NULL;
     } else {
-      EXPECT_FALSE(is_list_empty(allocate_list));
-      EXPECT_EQ(block, allocate_list.chead());
+      EXPECT_FALSE(is_list_empty(allocation_list));
+      EXPECT_EQ(block, allocation_list.chead());
       EXPECT_EQ(block, active_head(_storage));
     }
   }
 
   if (block != NULL) {
     EXPECT_NE(0u, TestAccess::block_allocation_count(*block));
-    EXPECT_FALSE(is_list_empty(allocate_list));
-    EXPECT_EQ(block, allocate_list.chead());
+    EXPECT_FALSE(is_list_empty(allocation_list));
+    EXPECT_EQ(block, allocation_list.chead());
     EXPECT_EQ(block, active_head(_storage));
   }
 
   for (size_t i = 0; i < max_entries; ++i) {
     release_entry(_storage, entries[i]);
-    EXPECT_TRUE(is_allocate_list_sorted(_storage));
+    EXPECT_TRUE(is_allocation_list_sorted(_storage));
     EXPECT_EQ(max_entries - (i + 1), total_allocation_count(_storage));
   }
 
-  EXPECT_EQ(active_count(_storage), list_length(allocate_list));
+  EXPECT_EQ(active_count(_storage), list_length(allocation_list));
   EXPECT_EQ(active_count(_storage), _storage.block_count());
   EXPECT_EQ(active_count(_storage), empty_block_count(_storage));
-  for (const OopBlock* block = allocate_list.chead();
+  for (const OopBlock* block = allocation_list.chead();
        block != NULL;
-       block = allocate_list.next(*block)) {
+       block = allocation_list.next(*block)) {
     EXPECT_TRUE(TestAccess::block_is_empty(*block));
   }
 }
 
 TEST_VM_F(OopStorageTestWithAllocation, random_release) {
   static const size_t step = 11;
   ASSERT_NE(0u, _max_entries % step); // max_entries and step are mutually prime
 
   EXPECT_EQ(0u, empty_block_count(_storage));
 
-  AllocateList& allocate_list = TestAccess::allocate_list(_storage);
+  AllocationList& allocation_list = TestAccess::allocation_list(_storage);
 
   EXPECT_EQ(_max_entries, total_allocation_count(_storage));
-  EXPECT_GE(1u, list_length(allocate_list));
+  EXPECT_GE(1u, list_length(allocation_list));
 
   // Release all entries in "random" order.
   size_t released = 0;
   for (size_t i = 0; released < _max_entries; i = (i + step) % _max_entries) {
     if (_entries[i] != NULL) {
       release_entry(_storage, _entries[i]);
       _entries[i] = NULL;
       ++released;
       EXPECT_EQ(_max_entries - released, total_allocation_count(_storage));
-      EXPECT_TRUE(is_allocate_list_sorted(_storage));
+      EXPECT_TRUE(is_allocation_list_sorted(_storage));
     }
   }
 
-  EXPECT_EQ(active_count(_storage), list_length(allocate_list));
+  EXPECT_EQ(active_count(_storage), list_length(allocation_list));
   EXPECT_EQ(active_count(_storage), _storage.block_count());
   EXPECT_EQ(0u, total_allocation_count(_storage));
-  EXPECT_EQ(list_length(allocate_list), empty_block_count(_storage));
+  EXPECT_EQ(list_length(allocation_list), empty_block_count(_storage));
 }
 
 TEST_VM_F(OopStorageTestWithAllocation, random_allocate_release) {
   static const size_t release_step = 11;
   static const size_t allocate_step = 5;
   ASSERT_NE(0u, _max_entries % release_step); // max_entries and step are mutually prime
 
   EXPECT_EQ(0u, empty_block_count(_storage));
 
-  AllocateList& allocate_list = TestAccess::allocate_list(_storage);
+  AllocationList& allocation_list = TestAccess::allocation_list(_storage);
 
   EXPECT_EQ(_max_entries, total_allocation_count(_storage));
-  EXPECT_GE(1u, list_length(allocate_list));
+  EXPECT_GE(1u, list_length(allocation_list));
 
   // Release all entries in "random" order, "randomly" interspersed
   // with additional allocations.
   size_t released = 0;
   size_t total_released = 0;

@@ -464,24 +464,24 @@
       release_entry(_storage, _entries[i]);
       _entries[i] = NULL;
       ++released;
       ++total_released;
       EXPECT_EQ(_max_entries - released, total_allocation_count(_storage));
-      EXPECT_TRUE(is_allocate_list_sorted(_storage));
+      EXPECT_TRUE(is_allocation_list_sorted(_storage));
       if (total_released % allocate_step == 0) {
         _entries[i] = _storage.allocate();
         --released;
         EXPECT_EQ(_max_entries - released, total_allocation_count(_storage));
-        EXPECT_TRUE(is_allocate_list_sorted(_storage));
+        EXPECT_TRUE(is_allocation_list_sorted(_storage));
       }
     }
   }
 
-  EXPECT_EQ(active_count(_storage), list_length(allocate_list));
+  EXPECT_EQ(active_count(_storage), list_length(allocation_list));
   EXPECT_EQ(active_count(_storage), _storage.block_count());
   EXPECT_EQ(0u, total_allocation_count(_storage));
-  EXPECT_EQ(list_length(allocate_list), empty_block_count(_storage));
+  EXPECT_EQ(list_length(allocation_list), empty_block_count(_storage));
 }
 
 template<bool sorted>
 class OopStorageTestBlockRelease : public OopStorageTestWithAllocation {
 public:

@@ -1198,23 +1198,23 @@
 };
 
 const size_t OopStorageBlockCollectionTest::nvalues;
 const void* const OopStorageBlockCollectionTest::_pseudo_owner[] = {};
 
-class OopStorageAllocateListTest : public OopStorageBlockCollectionTest {};
+class OopStorageAllocationListTest : public OopStorageBlockCollectionTest {};
 
-TEST_F(OopStorageAllocateListTest, empty_list) {
-  AllocateList list;
+TEST_F(OopStorageAllocationListTest, empty_list) {
+  AllocationList list;
 
   EXPECT_TRUE(is_list_empty(list));
   EXPECT_EQ(NULL_BLOCK, list.head());
   EXPECT_EQ(NULL_BLOCK, list.chead());
   EXPECT_EQ(NULL_BLOCK, list.ctail());
 }
 
-TEST_F(OopStorageAllocateListTest, push_back) {
-  AllocateList list;
+TEST_F(OopStorageAllocationListTest, push_back) {
+  AllocationList list;
 
   for (size_t i = 0; i < nvalues; ++i) {
     list.push_back(*values[i]);
     EXPECT_FALSE(is_list_empty(list));
     EXPECT_EQ(list.ctail(), values[i]);

@@ -1239,12 +1239,12 @@
   EXPECT_EQ(NULL_BLOCK, block);
 
   clear_list(list);
 }
 
-TEST_F(OopStorageAllocateListTest, push_front) {
-  AllocateList list;
+TEST_F(OopStorageAllocationListTest, push_front) {
+  AllocationList list;
 
   for (size_t i = 0; i < nvalues; ++i) {
     list.push_front(*values[i]);
     EXPECT_FALSE(is_list_empty(list));
     EXPECT_EQ(list.head(), values[i]);

@@ -1269,26 +1269,26 @@
   EXPECT_EQ(NULL_BLOCK, block);
 
   clear_list(list);
 }
 
-class OopStorageAllocateListTestWithList : public OopStorageAllocateListTest {
+class OopStorageAllocationListTestWithList : public OopStorageAllocationListTest {
 public:
-  OopStorageAllocateListTestWithList() : list() {
+  OopStorageAllocationListTestWithList() : list() {
     for (size_t i = 0; i < nvalues; ++i) {
       list.push_back(*values[i]);
     }
   }
 
-  ~OopStorageAllocateListTestWithList() {
+  ~OopStorageAllocationListTestWithList() {
     clear_list(list);
   }
 
-  AllocateList list;
+  AllocationList list;
 };
 
-TEST_F(OopStorageAllocateListTestWithList, unlink_front) {
+TEST_F(OopStorageAllocationListTestWithList, unlink_front) {
   EXPECT_EQ(list.chead(), values[0]);
   EXPECT_EQ(list.ctail(), values[nvalues - 1]);
 
   list.unlink(*values[0]);
   EXPECT_EQ(NULL_BLOCK, list.next(*values[0]));

@@ -1302,11 +1302,11 @@
     block = list.next(*block);
   }
   EXPECT_EQ(NULL_BLOCK, block);
 }
 
-TEST_F(OopStorageAllocateListTestWithList, unlink_back) {
+TEST_F(OopStorageAllocationListTestWithList, unlink_back) {
   EXPECT_EQ(list.chead(), values[0]);
 
   list.unlink(*values[nvalues - 1]);
   EXPECT_EQ(NULL_BLOCK, list.next(*values[nvalues - 1]));
   EXPECT_EQ(NULL_BLOCK, list.prev(*values[nvalues - 1]));

@@ -1319,11 +1319,11 @@
     block = list.next(*block);
   }
   EXPECT_EQ(NULL_BLOCK, block);
 }
 
-TEST_F(OopStorageAllocateListTestWithList, unlink_middle) {
+TEST_F(OopStorageAllocationListTestWithList, unlink_middle) {
   EXPECT_EQ(list.chead(), values[0]);
 
   size_t index = nvalues / 2;
 
   list.unlink(*values[index]);

@@ -1342,12 +1342,12 @@
     block = list.next(*block);
   }
   EXPECT_EQ(NULL_BLOCK, block);
 }
 
-TEST_F(OopStorageAllocateListTest, single) {
-  AllocateList list;
+TEST_F(OopStorageAllocationListTest, single) {
+  AllocationList list;
 
   list.push_back(*values[0]);
   EXPECT_EQ(NULL_BLOCK, list.next(*values[0]));
   EXPECT_EQ(NULL_BLOCK, list.prev(*values[0]));
   EXPECT_EQ(list.chead(), values[0]);
< prev index next >