Manage heap's stack for recursive functions at run time #11708
Replies: 3 comments
-
I'm not quite sure what the intention of this issue is. Providing a more specific description what problem you want to solve and putting your code into a ```C
That said However, when people talk about memory management they usually refer to heap memory - in a multi threaded environment. |
Beta Was this translation helpful? Give feedback.
-
I did reformat the layout. with three backticks. The idea is to use a heap allocated stack only for recursive function calls, and then revert back on original stack after the recursive chain of calls is completed. I know that calling functions in recursive loop is not a good programming practice , but this task & PoC were created based on this Discord's request/proposal https://discord.com/channels/592103645835821068/713909145899630632/748578143413207172 because other language is able to perform such trick. -fsplit-stack When code compiled with -fsplit-stack calls code compiled without -fsplit-stack, there may not be much stack space available for the latter code to run. If compiling all code, including library code, with -fsplit-stack is not an option, then the linker can fix up these calls so that the code compiled without -fsplit-stack always has a large stack. Support for this is implemented in the gold linker in GNU binutils release 2.21 and later. |
Beta Was this translation helpful? Give feedback.
-
-fsplit-stack Also this trick with 2 stacks could be useful for future "-autofree" V's compiler flag aka automatic memory management. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
A small proof of concept code written in C and Assembly in order to manage heap allocated stack for recursive functions.
Beta Was this translation helpful? Give feedback.
All reactions