152 const size_t object_size = 16; 153 const uintptr_t object = page.alloc_object(object_size); 154 155 ZGlobalSeqNum++; 156 157 bool dummy = false; 158 page.mark_object(ZAddress::marked(object), dummy, dummy); 159 160 const uint32_t live_objects = size; 161 const uint32_t live_bytes = live_objects * object_size; 162 page.inc_live_atomic(live_objects, live_bytes); 163 164 // Setup forwarding 165 ZForwarding* const forwarding = ZForwarding::create(&page); 166 167 // Actual test function 168 (*function)(forwarding); 169 170 // Teardown forwarding 171 ZForwarding::destroy(forwarding); 172 173 // Teardown page 174 page.physical_memory().clear(); 175 } 176 177 // Run the given function with a few different input values. 178 static void test(void (*function)(ZForwarding*)) { 179 test(function, 1); 180 test(function, 2); 181 test(function, 3); 182 test(function, 4); 183 test(function, 7); 184 test(function, 8); 185 test(function, 1023); 186 test(function, 1024); 187 test(function, 1025); 188 } 189 }; 190 191 TEST_F(ZForwardingTest, setup) { 192 test(&ZForwardingTest::setup); 193 } 194 | 152 const size_t object_size = 16; 153 const uintptr_t object = page.alloc_object(object_size); 154 155 ZGlobalSeqNum++; 156 157 bool dummy = false; 158 page.mark_object(ZAddress::marked(object), dummy, dummy); 159 160 const uint32_t live_objects = size; 161 const uint32_t live_bytes = live_objects * object_size; 162 page.inc_live_atomic(live_objects, live_bytes); 163 164 // Setup forwarding 165 ZForwarding* const forwarding = ZForwarding::create(&page); 166 167 // Actual test function 168 (*function)(forwarding); 169 170 // Teardown forwarding 171 ZForwarding::destroy(forwarding); 172 } 173 174 // Run the given function with a few different input values. 175 static void test(void (*function)(ZForwarding*)) { 176 test(function, 1); 177 test(function, 2); 178 test(function, 3); 179 test(function, 4); 180 test(function, 7); 181 test(function, 8); 182 test(function, 1023); 183 test(function, 1024); 184 test(function, 1025); 185 } 186 }; 187 188 TEST_F(ZForwardingTest, setup) { 189 test(&ZForwardingTest::setup); 190 } 191 |