|
|
|
(used for memory allocated through pointers and references) |
|
(used for management of function calls) |
Run-Time Stack is divided into chunks of memory called
Activation Records , each dedicated to a function call that occured
during the execution time and managed by LIFO strategy. The structure of
an activation record is as follows :
|
|
|
|
|
(encoded info. about the system at the moment of the call) |
|
(copies of the actual arguments for "value parameters", copies of the addresses of the actual arguments for "reference parameters") |
|
|
For instance, the quicksort algorithm working on the array
5, 12, 3, 2, 9, 12, 8, 7, 11, 4 gets invoked first as qs(0,9) to sort the
entire array, which triggers recursive calls and corresponding activation
records as follows:
|
AR for qs(0,9) |
After qs(0,9) makes a call to qs(0,5) the stack looks
as follows :
| AR for qs(0,5) | ||||||||||||
|
AR for qs(0,9) |