Merge pull request #124 from microsoft/alignment
Make Large allocations naturally aligned
This commit is contained in:
@@ -32,8 +32,12 @@ int main()
|
||||
{
|
||||
MemoryProviderStateMixin<DefaultPal> mp;
|
||||
|
||||
size_t size = 1ULL << 28;
|
||||
oe_base = mp.reserve<true>(&size, 0);
|
||||
// 28 is large enough to produce a nested allocator.
|
||||
// It is also large enough for the example to run in.
|
||||
// For 1MiB superslabs, SUPERSLAB_BITS + 4 is not big enough for the example.
|
||||
size_t large_class = 28 - SUPERSLAB_BITS;
|
||||
size_t size = 1ULL << (SUPERSLAB_BITS + large_class);
|
||||
oe_base = mp.reserve<true>(large_class);
|
||||
oe_end = (uint8_t*)oe_base + size;
|
||||
std::cout << "Allocated region " << oe_base << " - " << oe_end << std::endl;
|
||||
|
||||
|
||||
@@ -108,7 +108,8 @@ int main(int argc, char** argv)
|
||||
test_posix_memalign((size_t)-1, 0, EINVAL, true);
|
||||
test_posix_memalign(OS_PAGE_SIZE, sizeof(uintptr_t) / 2, EINVAL, true);
|
||||
|
||||
for (size_t align = sizeof(uintptr_t); align <= SUPERSLAB_SIZE; align <<= 1)
|
||||
for (size_t align = sizeof(uintptr_t); align <= SUPERSLAB_SIZE * 8;
|
||||
align <<= 1)
|
||||
{
|
||||
for (snmalloc::sizeclass_t sc = 0; sc < NUM_SIZECLASSES; sc++)
|
||||
{
|
||||
|
||||
@@ -45,8 +45,12 @@ int main()
|
||||
|
||||
MemoryProviderStateMixin<DefaultPal> mp;
|
||||
|
||||
size_t size = 1ULL << 26;
|
||||
oe_base = mp.reserve<true>(&size, 1);
|
||||
// 26 is large enough to produce a nested allocator.
|
||||
// It is also large enough for the example to run in.
|
||||
// For 1MiB superslabs, SUPERSLAB_BITS + 2 is not big enough for the example.
|
||||
size_t large_class = 26 - SUPERSLAB_BITS;
|
||||
size_t size = 1ULL << (SUPERSLAB_BITS + large_class);
|
||||
oe_base = mp.reserve<true>(large_class);
|
||||
oe_end = (uint8_t*)oe_base + size;
|
||||
std::cout << "Allocated region " << oe_base << " - " << oe_end << std::endl;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user