< prev index next >

test/hotspot/gtest/gc/z/test_zForwarding.cpp

Print this page


   1 /*
   2  * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */


 123       ASSERT_EQ(entry.from_index(), from_index) << CAPTURE(size);
 124       ASSERT_EQ(entry.to_offset(), from_index) << CAPTURE(size);
 125     }
 126 
 127     // Verify empty odd indices
 128     //
 129     // This check could be done on a larger range of sequence numbers,
 130     // but currently entries_to_populate is used.
 131     for (size_t i = 0; i < entries_to_populate; i++) {
 132       uintptr_t from_index = SequenceToFromIndex::odd(i);
 133 
 134       ZForwardingEntry entry = forwarding->find(from_index);
 135 
 136       ASSERT_FALSE(entry.populated()) << CAPTURE2(from_index, size);
 137     }
 138   }
 139 
 140   static void test(void (*function)(ZForwarding*), uint32_t size) {
 141     // Create page
 142     const ZVirtualMemory vmem(0, ZPageSizeSmall);
 143     const ZPhysicalMemory pmem(ZPhysicalMemorySegment(0, ZPageSizeSmall));
 144     ZPage page(ZPageTypeSmall, vmem, pmem);
 145 
 146     page.reset();
 147 
 148     const size_t object_size = 16;
 149     const uintptr_t object = page.alloc_object(object_size);
 150 
 151     ZGlobalSeqNum++;
 152 
 153     bool dummy = false;
 154     page.mark_object(ZAddress::marked(object), dummy, dummy);
 155 
 156     const uint32_t live_objects = size;
 157     const size_t live_bytes = live_objects * object_size;
 158     page.inc_live(live_objects, live_bytes);
 159 
 160     // Setup forwarding
 161     ZForwarding* const forwarding = ZForwarding::create(&page);
 162 
 163     // Actual test function


   1 /*
   2  * Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */


 123       ASSERT_EQ(entry.from_index(), from_index) << CAPTURE(size);
 124       ASSERT_EQ(entry.to_offset(), from_index) << CAPTURE(size);
 125     }
 126 
 127     // Verify empty odd indices
 128     //
 129     // This check could be done on a larger range of sequence numbers,
 130     // but currently entries_to_populate is used.
 131     for (size_t i = 0; i < entries_to_populate; i++) {
 132       uintptr_t from_index = SequenceToFromIndex::odd(i);
 133 
 134       ZForwardingEntry entry = forwarding->find(from_index);
 135 
 136       ASSERT_FALSE(entry.populated()) << CAPTURE2(from_index, size);
 137     }
 138   }
 139 
 140   static void test(void (*function)(ZForwarding*), uint32_t size) {
 141     // Create page
 142     const ZVirtualMemory vmem(0, ZPageSizeSmall);
 143     const ZPhysicalMemory pmem(ZPhysicalMemorySegment(0, ZPageSizeSmall, true));
 144     ZPage page(ZPageTypeSmall, vmem, pmem);
 145 
 146     page.reset();
 147 
 148     const size_t object_size = 16;
 149     const uintptr_t object = page.alloc_object(object_size);
 150 
 151     ZGlobalSeqNum++;
 152 
 153     bool dummy = false;
 154     page.mark_object(ZAddress::marked(object), dummy, dummy);
 155 
 156     const uint32_t live_objects = size;
 157     const size_t live_bytes = live_objects * object_size;
 158     page.inc_live(live_objects, live_bytes);
 159 
 160     // Setup forwarding
 161     ZForwarding* const forwarding = ZForwarding::create(&page);
 162 
 163     // Actual test function


< prev index next >