mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-14 17:28:07 +00:00
correctly compute size_to_zero for new blocks
This commit is contained in:
+17
-11
@@ -101,6 +101,16 @@ arena_push(Arena *arena, U64 size, U64 align, B32 zero)
|
|||||||
U64 pos_pre = AlignPow2(current->pos, align);
|
U64 pos_pre = AlignPow2(current->pos, align);
|
||||||
U64 pos_pst = pos_pre + size;
|
U64 pos_pst = pos_pre + size;
|
||||||
|
|
||||||
|
// TODO: Newly allocated arenas already have zeroed commited pages,
|
||||||
|
// so this unnecessarily zeroes them again.
|
||||||
|
//
|
||||||
|
// rjf: compute the size we need to zero
|
||||||
|
U64 size_to_zero = 0;
|
||||||
|
if(zero)
|
||||||
|
{
|
||||||
|
size_to_zero = Min(current->cmt, pos_pst) - pos_pre;
|
||||||
|
}
|
||||||
|
|
||||||
// rjf: chain, if needed
|
// rjf: chain, if needed
|
||||||
if(current->res < pos_pst && !(arena->flags & ArenaFlag_NoChain))
|
if(current->res < pos_pst && !(arena->flags & ArenaFlag_NoChain))
|
||||||
{
|
{
|
||||||
@@ -141,6 +151,12 @@ arena_push(Arena *arena, U64 size, U64 align, B32 zero)
|
|||||||
.flags = current->flags,
|
.flags = current->flags,
|
||||||
.allocation_site_file = current->allocation_site_file,
|
.allocation_site_file = current->allocation_site_file,
|
||||||
.allocation_site_line = current->allocation_site_line);
|
.allocation_site_line = current->allocation_site_line);
|
||||||
|
|
||||||
|
size_to_zero = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
size_to_zero = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
new_block->base_pos = current->base_pos + current->res;
|
new_block->base_pos = current->base_pos + current->res;
|
||||||
@@ -151,13 +167,6 @@ arena_push(Arena *arena, U64 size, U64 align, B32 zero)
|
|||||||
pos_pst = pos_pre + size;
|
pos_pst = pos_pre + size;
|
||||||
}
|
}
|
||||||
|
|
||||||
// rjf: compute the size we need to zero
|
|
||||||
U64 size_to_zero = 0;
|
|
||||||
if(zero)
|
|
||||||
{
|
|
||||||
size_to_zero = Min(current->cmt, pos_pst) - pos_pre;
|
|
||||||
}
|
|
||||||
|
|
||||||
// rjf: commit new pages, if needed
|
// rjf: commit new pages, if needed
|
||||||
if(current->cmt < pos_pst)
|
if(current->cmt < pos_pst)
|
||||||
{
|
{
|
||||||
@@ -185,10 +194,7 @@ arena_push(Arena *arena, U64 size, U64 align, B32 zero)
|
|||||||
result = (U8 *)current+pos_pre;
|
result = (U8 *)current+pos_pre;
|
||||||
current->pos = pos_pst;
|
current->pos = pos_pst;
|
||||||
AsanUnpoisonMemoryRegion(result, size);
|
AsanUnpoisonMemoryRegion(result, size);
|
||||||
if(size_to_zero != 0)
|
MemoryZero(result, size_to_zero);
|
||||||
{
|
|
||||||
MemoryZero(result, size_to_zero);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if PROFILE_TELEMETRY
|
#if PROFILE_TELEMETRY
|
||||||
|
|||||||
Reference in New Issue
Block a user