Currently, realloc is invoked every time the machine stack is saved. If two variables were used to keep track of the allocated machine stack size and the currently used stack size, then a realloc call would only need to be incurred if used_stack_size > allocated_stack_size.
A POC can be seen below, but it does not work (I haven't had time to debug why, yet):
Currently,
realloc
is invoked every time the machine stack is saved. If two variables were used to keep track of the allocated machine stack size and the currently used stack size, then a realloc call would only need to be incurred ifused_stack_size > allocated_stack_size
.A POC can be seen below, but it does not work (I haven't had time to debug why, yet):