Question: In Section 8.2.2 we noted that in a language with dynamic arrays and a value model of variables, records could have fields whose size is
In Section 8.2.2 we noted that in a language with dynamic arrays and a value model of variables, records could have fields whose size is not known at compile time. To accommodate these, we suggested using a dope vector for the record, to track the offsets of the fields. Suppose instead that we want to maintain a static offset for each field. Can we devise an alternative strategy inspired by the stack frame layout of Figure 8.7, and divide each record into a fixed-size part and a variable-size part? What problems would we need to address?
![sp- Ada: -- procedure foo(size : integer) is M : array (1..size, 1..size) of long float; Variable-size M part of the frame begin Temporaries ... end foo; Local Pointer to M variables Dope vector Fixed-size part of the frame // C99: void foo (int size) { Bookkeeping double M[size] [size];](https://dsd5zvtm8ll6.cloudfront.net/si.question.images/images/question_images/1606/2/1/1/3275fbcd6ff812ba1606211327427.jpg)
sp- Ada: -- procedure foo(size : integer) is M : array (1..size, 1..size) of long float; Variable-size M part of the frame begin Temporaries ... end foo; Local Pointer to M variables Dope vector Fixed-size part of the frame // C99: void foo (int size) { Bookkeeping double M[size] [size]; Return address fp- Arguments and returns
Step by Step Solution
3.26 Rating (155 Votes )
There are 3 Steps involved in it
The fixed and variablepart strategy for stack frames depends on the fact that the stack fra... View full answer
Get step-by-step solutions from verified subject matter experts
