Home

[This page is auto-generated; please prefer to read the article’s PDF Form.]



[Prev]   [Up]   [Next]   

Memory for Virtual-Calls

Generally, when a method like recur() keeps calling itself, it will also need to remember the memory state for each call on the call-stack. This state includes the local variables and input arguments. Each call on the call-stack also needs to remember where it should resume its execution when the called function returns. When we simulate the recursion on our stack, we too will need to associate some memory state for each virtual-call. We will refer to this memory as the vc_frame (“virtual call stack frame”) of that virtual-call. Similar to the program-stack’s frames, these frames will be pushed on the vc_stack to simulate a recursive virtual-call, and popped from it when the virtual-call returns. So, at any point, the top of vc_stack contains the vc_frame for the current executing virtual-call, the frames below it correspond to the earlier virtual-calls in their calling order. The bottom-most frame corresponds to the initial call of recur_stack() itself.

[Prev]   [Up]   [Next]