Made Remote deallocation work on 32bit
The design of Remote used the top bits of the allocator id to encode the sizeclass of the deallocation. On 32bit, or on a platform that uses all the bits we cannot use these bits for a sizeclass. This commit uses the bottom bit of the allocator id (which is guaranteed to be 0), to indicate if the object is the minimum allocation size. If it is not the minimum allocation size the subsequent byte is used to encode the sizeclass. The code uses constexpr to decide which strategy to use.
This commit is contained in:
@@ -521,9 +521,7 @@ namespace snmalloc
|
||||
this->size += sizeclass_to_size(sizeclass);
|
||||
|
||||
Remote* r = (Remote*)p;
|
||||
r->set_sizeclass(sizeclass);
|
||||
assert(r->sizeclass() == sizeclass);
|
||||
r->set_target_id(target_id);
|
||||
r->set_sizeclass_and_target_id(target_id, sizeclass);
|
||||
assert(r->sizeclass() == sizeclass);
|
||||
assert(r->target_id() == target_id);
|
||||
|
||||
@@ -588,10 +586,6 @@ namespace snmalloc
|
||||
}
|
||||
};
|
||||
|
||||
static_assert(
|
||||
sizeof(Remote) <= MIN_ALLOC_SIZE,
|
||||
"Need to be able to cast any small alloc to Remote");
|
||||
|
||||
SlabList small_classes[NUM_SMALL_CLASSES];
|
||||
DLList<Mediumslab> medium_classes[NUM_MEDIUM_CLASSES];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user