Nesting the class inside a function generates bad code in Debug (#584).
Unnesting seems to fix this.
This commit is contained in:
Matthew Parkinson 2023-02-03 14:24:02 +00:00 коммит произвёл GitHub
Родитель 6be63b1ea8
Коммит 627653afdb
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 25 добавлений и 25 удалений

Просмотреть файл

@ -411,40 +411,40 @@ namespace snmalloc
return (s - 1) >> MIN_ALLOC_BITS;
}
constexpr smallsizeclass_t size_to_sizeclass(size_t size)
constexpr size_t sizeclass_lookup_size =
sizeclass_lookup_index(MAX_SMALL_SIZECLASS_SIZE);
/**
* This struct is used to statically initialise a table for looking up
* the correct sizeclass.
*/
struct SizeClassLookup
{
constexpr size_t sizeclass_lookup_size =
sizeclass_lookup_index(MAX_SMALL_SIZECLASS_SIZE);
sizeclass_compress_t table[sizeclass_lookup_size] = {{}};
/**
* This struct is used to statically initialise a table for looking up
* the correct sizeclass.
*/
struct SizeClassLookup
constexpr SizeClassLookup()
{
sizeclass_compress_t table[sizeclass_lookup_size] = {{}};
constexpr SizeClassLookup()
size_t curr = 1;
for (sizeclass_compress_t sizeclass = 0;
sizeclass < NUM_SMALL_SIZECLASSES;
sizeclass++)
{
size_t curr = 1;
for (sizeclass_compress_t sizeclass = 0;
sizeclass < NUM_SMALL_SIZECLASSES;
sizeclass++)
for (; curr <= sizeclass_metadata.fast_small(sizeclass).size;
curr += 1 << MIN_ALLOC_BITS)
{
for (; curr <= sizeclass_metadata.fast_small(sizeclass).size;
curr += 1 << MIN_ALLOC_BITS)
{
auto i = sizeclass_lookup_index(curr);
if (i == sizeclass_lookup_size)
break;
table[i] = sizeclass;
}
auto i = sizeclass_lookup_index(curr);
if (i == sizeclass_lookup_size)
break;
table[i] = sizeclass;
}
}
};
}
};
constexpr SizeClassLookup sizeclass_lookup = SizeClassLookup();
constexpr SizeClassLookup sizeclass_lookup = SizeClassLookup();
constexpr smallsizeclass_t size_to_sizeclass(size_t size)
{
auto index = sizeclass_lookup_index(size);
if (index < sizeclass_lookup_size)
{