142 }
143
144 static void test(void (*function)(ZForwarding*), uint32_t size) {
145 // Create page
146 const ZVirtualMemory vmem(0, ZPageSizeSmall);
147 const ZPhysicalMemory pmem(ZPhysicalMemorySegment(0, ZPageSizeSmall));
148 ZPage page(ZPageTypeSmall, vmem, pmem);
149
150 page.reset();
151
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 size_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);
|
142 }
143
144 static void test(void (*function)(ZForwarding*), uint32_t size) {
145 // Create page
146 const ZVirtualMemory vmem(0, ZPageSizeSmall);
147 const ZPhysicalMemory pmem(ZPhysicalMemorySegment(0, ZPageSizeSmall));
148 ZPage page(ZPageTypeSmall, vmem, pmem);
149
150 page.reset();
151
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 size_t live_bytes = live_objects * object_size;
162 page.inc_live(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);
|