1 /*
   2  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
   3  * ORACLE PROPRIETARY/CONFIDENTIAL.  Use is subject to license terms.
   4  */
   5 
   6 #include "precompiled.hpp"
   7 #include "gc/z/zLiveMap.inline.hpp"
   8 #include "unittest.hpp"
   9 
  10 class ZLiveMapTest : public ::testing::Test {
  11 protected:
  12   static void strongly_live_for_large_zpage() {
  13     // Large ZPages only have room for one object.
  14     ZLiveMap livemap(1);
  15 
  16     bool inc_live;
  17     uintptr_t object = 0u;
  18 
  19     // Mark the object strong.
  20     livemap.set_atomic(object, false /* finalizable */, inc_live);
  21 
  22     // Check that both bits are in the same segment.
  23     ASSERT_EQ(livemap.index_to_segment(0), livemap.index_to_segment(1));
  24 
  25     // Check that the object was marked.
  26     ASSERT_TRUE(livemap.get(0));
  27 
  28     // Check that the object was strongly marked.
  29     ASSERT_TRUE(livemap.get(1));
  30 
  31     ASSERT_TRUE(inc_live);
  32   }
  33 };
  34 
  35 TEST_F(ZLiveMapTest, strongly_live_for_large_zpage) {
  36   strongly_live_for_large_zpage();
  37 }