Refactor checks to improve codegen.

This commit is contained in:
Matthew Parkinson
2021-03-17 18:41:56 +00:00
committed by Matthew Parkinson
parent 0983f1837b
commit ed615eade9
4 changed files with 73 additions and 89 deletions

View File

@@ -139,10 +139,9 @@ namespace snmalloc
# ifndef NDEBUG
if (next != nullptr)
{
if (unlikely(different_slab(prev, next)))
{
error("Heap corruption - free list corrupted!");
}
check_client(
!different_slab(prev, next),
"Heap corruption - free list corrupted!");
}
# endif
prev = address_cast(curr);
@@ -162,10 +161,8 @@ namespace snmalloc
void move_next()
{
#ifdef CHECK_CLIENT
if (unlikely(different_slab(prev, curr)))
{
error("Heap corruption - free list corrupted!");
}
check_client(
!different_slab(prev, curr), "Heap corruption - free list corrupted!");
#endif
update_cursor(curr->read_next(get_prev()));
}
@@ -221,6 +218,14 @@ namespace snmalloc
return front.get_curr() == nullptr;
}
/**
* Returns current head without affecting the iterator.
*/
void* peek()
{
return front.get_curr();
}
/**
* Moves the iterator on, and returns the current value.
*/
@@ -258,7 +263,7 @@ namespace snmalloc
*/
void* peek_head()
{
return front.get_curr();
return peek();
}
/**