4 ms·
> That is a pretty major difference with wide-ranging effects on program performance right there. It really isn't. The only difference is that in the second ca
by wizeman 6y ago
> That is a pretty major difference with wide-ranging effects on program performance right there.
It really isn't. The only difference is that in the second case you have to call mmap() at the beginning of your program to allocate stack space and then change the stack pointer to point to it, the rest of the execution would remain the same.
> That is a pretty major difference with wide-ranging effects on program performance right there.
> And once you do, that memory becomes functionally privileged from the perspective of your allocation strategy.
So you're saying that the transformation you mentioned gives you better error messages at the expense of performance, because now instead of using the stack, you have to keep allocating a stack-like structure on the heap?
If so, that's not entirely true, as you can have the same error messages without doing this transformation (that's why some kernels and runtimes can detect stack overflow and even resize the stack), so the only observable functional difference is that you replace a simple stack-like allocation mechanism with one that is slower without much benefit.
And it would still be a bit disingenuous to say that the transformation would make your program use constant stack space, as if replacing stack space with heap space somehow makes stack usage on a recursive function irrelevant...