Refactor: Remove unused features and functions, and move most allocator operations to a global namespace. (#750)
* Factor out explicit Config type Instead of using snmalloc::Alloc::Config, expose snmalloc::Config, which is then used to derive the allocator type. * Move globalalloc to front end. * Remove unneed template parameter from global snmalloc functions. * Remove SNMALLOC_PASS_THROUGH VeronaRT now has an abstraction layer which can easily replace the allocator. Having such a complex integration still in snmalloc does not make sense. * Take some global functions off of local alloc. * Drop comparison overloads on atomic Capptr. Performing a comparison on two atomic ptr is a complex operation, and should not be implicit. The memory model order and such things needs to be considered by the caller. * Remove function_ref and use templates The implementation prefers to use templates over the function_ref. This now only exists in the Pal for a currently unused feature. * Removing function_ref reduces stl needs. * Remove use of __is_convertible to support older g++ * Inline function that is only used once. * Remove unused function * Restrict ThreadAlloc usage to globalalloc This commit introduces various inline functions on snmalloc:: that perform allocation/deallocation using the thread local allocator. They remove all usage from a particular test. * Move cheri checks to own file. * Refactor is_owned checks. * Move alloc_size and check_size to globalalloc. * Minor simplification of dealloc path * Fix up is_owned to take a config * Improve usage of scoped allocator. * Handle Config_ in globalalloc.
This commit is contained in:
committed by
GitHub
parent
6d50141e35
commit
5f7baef755
@@ -35,7 +35,7 @@ void shape(size_t size)
|
||||
// the memcpys. constexpr size_t alignment = 16; offset = (my_random() %
|
||||
// size / alignment) * alignment;
|
||||
Shape s;
|
||||
s.object = ThreadAlloc::get().alloc(rsize);
|
||||
s.object = snmalloc::alloc(rsize);
|
||||
s.dst = static_cast<unsigned char*>(s.object) + offset;
|
||||
// Bring into cache the destination of the copy.
|
||||
memset(s.dst, 0xFF, size);
|
||||
@@ -47,7 +47,7 @@ void unshape()
|
||||
{
|
||||
for (auto& s : allocs)
|
||||
{
|
||||
ThreadAlloc::get().dealloc(s.object);
|
||||
snmalloc::dealloc(s.object);
|
||||
}
|
||||
allocs.clear();
|
||||
}
|
||||
@@ -68,7 +68,7 @@ void test(
|
||||
Memcpy mc,
|
||||
std::vector<std::pair<size_t, std::chrono::nanoseconds>>& stats)
|
||||
{
|
||||
auto src = ThreadAlloc::get().alloc(size);
|
||||
auto src = snmalloc::alloc(size);
|
||||
shape(size);
|
||||
for (size_t i = 0; i < 10; i++)
|
||||
{
|
||||
@@ -77,7 +77,7 @@ void test(
|
||||
auto time = m.get_time();
|
||||
stats.push_back({size, time});
|
||||
}
|
||||
ThreadAlloc::get().dealloc(src);
|
||||
snmalloc::dealloc(src);
|
||||
unshape();
|
||||
}
|
||||
|
||||
@@ -108,7 +108,6 @@ void memcpy_platform_checked(void* dst, const void* src, size_t size)
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
opt::Opt opt(argc, argv);
|
||||
#ifndef SNMALLOC_PASS_THROUGH
|
||||
bool full_test = opt.has("--full_test");
|
||||
|
||||
// size_t size = 0;
|
||||
@@ -182,8 +181,5 @@ int main(int argc, char** argv)
|
||||
stats_platform.clear();
|
||||
stats_platform_checked.clear();
|
||||
}
|
||||
#else
|
||||
snmalloc::UNUSED(opt);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user