Refactor is_start_of_object

This commit is contained in:
Matthew Parkinson
2021-04-30 15:41:41 +01:00
committed by Matthew Parkinson
parent 5198821905
commit f0ebbebf74
2 changed files with 4 additions and 6 deletions

View File

@@ -1140,7 +1140,7 @@ namespace snmalloc
sizeclass_t sizeclass)
{
check_client(
Metaslab::is_start_of_object(Slab::get_meta(slab), address_cast(p_ret)),
Slab::get_meta(slab)->is_start_of_object(address_cast(p_ret)),
"Not deallocating start of an object");
small_dealloc_start(super, slab, p_auth, p_ret, sizeclass);

View File

@@ -152,12 +152,10 @@ namespace snmalloc
return pointer_align_down<SUPERSLAB_SIZE, Slab>(p.as_void()) == p;
}
template<capptr_bounds B>
SNMALLOC_FAST_PATH static bool
is_start_of_object(CapPtr<Metaslab, B> self, address_t p)
SNMALLOC_FAST_PATH bool is_start_of_object(address_t p)
{
return is_multiple_of_sizeclass(
self->sizeclass(), SLAB_SIZE - (p - address_align_down<SLAB_SIZE>(p)));
sizeclass(), SLAB_SIZE - (p - address_align_down<SLAB_SIZE>(p)));
}
/**
@@ -187,7 +185,7 @@ namespace snmalloc
self->set_full(meta);
auto p = remove_cache_friendly_offset(n, self->sizeclass());
SNMALLOC_ASSERT(is_start_of_object(self, address_cast(p)));
SNMALLOC_ASSERT(self->is_start_of_object(address_cast(p)));
self->debug_slab_invariant(meta, entropy);