41 const intptr_t kSmallObjectSize = 4 *
kWordSize;
42 const intptr_t kMediumObjectSize = 16 *
kWordSize;
43 const intptr_t kLargeObjectSize = 8 *
KB;
44 uword blob = region->start();
46 free_list->
Free(blob, region->size());
54 uword small_object =
Allocate(free_list, kSmallObjectSize, is_protected);
55 EXPECT_EQ(blob, small_object);
57 Free(free_list, small_object, kSmallObjectSize, is_protected);
58 small_object =
Allocate(free_list, kSmallObjectSize, is_protected);
59 EXPECT_EQ(blob, small_object);
61 uword small_object2 =
Allocate(free_list, kSmallObjectSize, is_protected);
62 EXPECT_EQ(blob + kSmallObjectSize, small_object2);
63 uword med_object =
Allocate(free_list, kMediumObjectSize, is_protected);
64 EXPECT_EQ(small_object2 + kSmallObjectSize, med_object);
66 uword large_object =
Allocate(free_list, kLargeObjectSize, is_protected);
67 EXPECT_EQ(med_object + kMediumObjectSize, large_object);
69 uword small_object3 =
Allocate(free_list, kSmallObjectSize, is_protected);
70 EXPECT_EQ(large_object + kLargeObjectSize, small_object3);
72 Free(free_list, large_object, kLargeObjectSize, is_protected);
73 uword small_object4 =
Allocate(free_list, kSmallObjectSize, is_protected);
74 EXPECT_EQ(large_object, small_object4);
77 Allocate(free_list, kLargeObjectSize - kSmallObjectSize, is_protected);
78 EXPECT_EQ(small_object4 + kSmallObjectSize, large_object);
80 uword large_object2 =
Allocate(free_list, kLargeObjectSize, is_protected);
81 EXPECT_EQ(small_object3 + kSmallObjectSize, large_object2);
198 std::unique_ptr<FreeList> free_list(
new FreeList());
202 true,
false,
"test"));
203 const intptr_t remainder_size = page / 2;
205 void*
const other_code =
206 reinterpret_cast<void*
>(blob->start() + alloc_size + remainder_size);
210#if defined(HOST_ARCH_X64) || defined(HOST_ARCH_IA32)
211 const uint8_t ret[1] = {0xC3};
212#elif defined(HOST_ARCH_ARM)
213 const uint8_t ret[4] = {0x1e, 0xff, 0x2f, 0xe1};
214#elif defined(HOST_ARCH_ARM64)
215 const uint8_t ret[4] = {0xc0, 0x03, 0x5f, 0xd6};
216#elif defined(HOST_ARCH_RISCV32) || defined(HOST_ARCH_RISCV64)
217 const uint8_t ret[2] = {0x82, 0x80};
219#error "Unknown architecture."
221 memcpy(other_code, ret,
sizeof(ret));
223 free_list->Free(blob->start(), alloc_size + remainder_size);
225 Allocate(free_list.get(), alloc_size,
true);
228 reinterpret_cast<void (*)()
>(other_code)();