Chapter 6: Runtime System

Justification for Displays

. Suppose procedure at depth j calls procedure at depth i

. Case j < i then i = j + 1

- called procedure is nested within the caller

- first j elements of display need not be changed

- set d[i] to the new activation record

. Case j = i

- enclosing procedure at depthes 1.i-1 are same and are left un- disturbed

- old value of d[i] is saved and d[i] points to the new record

- display is correct as first i-1 records are not disturbed

Suppose procedure at depth j calls procedure at depth i. There are two cases, depending on whether or not the called procedure is nested within the caller in the source text, as in the discussion of access links. 1. Case j < i. Then i = j + 1 and the called procedure is nested within the caller, therefore, the first j elements of display need not be changed, and we set d[i] to the new activation record. The case is illustrated in the figure in the previous slide when sort calls quicksort and also when quicksort calls partition. 2. Case j > i. The enclosing procedure at nesting depths 1,2,.i-1 of the called and calling procedures must be the same and are left un- disturbed. Here the old value of d[i] is saved in the new activation record, and d[i] is pointed to the new record. The display is maintained correctly because first the i-1 records are left as it is.