< prev index next >

test/hotspot/gtest/gc/g1/test_g1BiasedArray.cpp

Print this page
rev 60593 : 8252035: G1: Clean up G1CollectedHeap::*reserved* methods
Reviewed-by:


  26 #include "unittest.hpp"
  27 
  28 class TestMappedArray : public G1BiasedMappedArray<int> {
  29 public:
  30   virtual int default_value() const {
  31     return 0xBAADBABE;
  32   }
  33   int* my_address_mapped_to(HeapWord* address) {
  34     return address_mapped_to(address);
  35   }
  36 };
  37 
  38 TEST_VM(G1BiasedArray, simple) {
  39   const size_t REGION_SIZE_IN_WORDS = 512;
  40   const size_t NUM_REGIONS = 20;
  41   // Any value that is non-zero
  42   HeapWord* fake_heap =
  43           (HeapWord*) LP64_ONLY(0xBAAA00000) NOT_LP64(0xBA000000);
  44 
  45   TestMappedArray array;
  46   array.initialize(fake_heap, fake_heap + REGION_SIZE_IN_WORDS * NUM_REGIONS,
  47           REGION_SIZE_IN_WORDS * HeapWordSize);
  48   const int DEFAULT_VALUE = array.default_value();
  49 
  50   // Check address calculation (bounds)
  51   ASSERT_EQ(fake_heap, array.bottom_address_mapped())
  52           << "bottom mapped address should be "
  53           << p2i(array.bottom_address_mapped())
  54           << ", but is "
  55           << p2i(fake_heap);
  56   ASSERT_EQ(fake_heap + REGION_SIZE_IN_WORDS * NUM_REGIONS,
  57           array.end_address_mapped());
  58 
  59   int* bottom = array.my_address_mapped_to(fake_heap);
  60   ASSERT_EQ((void*) bottom, (void*) array.base());
  61   int* end = array.my_address_mapped_to(fake_heap +
  62           REGION_SIZE_IN_WORDS * NUM_REGIONS);
  63   ASSERT_EQ((void*) end, (void*) (array.base() + array.length()));
  64   // The entire array should contain default value elements
  65   for (int* current = bottom; current < end; current++) {
  66     ASSERT_EQ(DEFAULT_VALUE, *current);
  67   }




  26 #include "unittest.hpp"
  27 
  28 class TestMappedArray : public G1BiasedMappedArray<int> {
  29 public:
  30   virtual int default_value() const {
  31     return 0xBAADBABE;
  32   }
  33   int* my_address_mapped_to(HeapWord* address) {
  34     return address_mapped_to(address);
  35   }
  36 };
  37 
  38 TEST_VM(G1BiasedArray, simple) {
  39   const size_t REGION_SIZE_IN_WORDS = 512;
  40   const size_t NUM_REGIONS = 20;
  41   // Any value that is non-zero
  42   HeapWord* fake_heap =
  43           (HeapWord*) LP64_ONLY(0xBAAA00000) NOT_LP64(0xBA000000);
  44 
  45   TestMappedArray array;
  46   MemRegion range(fake_heap, fake_heap + REGION_SIZE_IN_WORDS * NUM_REGIONS);
  47   array.initialize(range, REGION_SIZE_IN_WORDS * HeapWordSize);
  48   const int DEFAULT_VALUE = array.default_value();
  49 
  50   // Check address calculation (bounds)
  51   ASSERT_EQ(fake_heap, array.bottom_address_mapped())
  52           << "bottom mapped address should be "
  53           << p2i(array.bottom_address_mapped())
  54           << ", but is "
  55           << p2i(fake_heap);
  56   ASSERT_EQ(fake_heap + REGION_SIZE_IN_WORDS * NUM_REGIONS,
  57           array.end_address_mapped());
  58 
  59   int* bottom = array.my_address_mapped_to(fake_heap);
  60   ASSERT_EQ((void*) bottom, (void*) array.base());
  61   int* end = array.my_address_mapped_to(fake_heap +
  62           REGION_SIZE_IN_WORDS * NUM_REGIONS);
  63   ASSERT_EQ((void*) end, (void*) (array.base() + array.length()));
  64   // The entire array should contain default value elements
  65   for (int* current = bottom; current < end; current++) {
  66     ASSERT_EQ(DEFAULT_VALUE, *current);
  67   }


< prev index next >