0% found this document useful (0 votes)
3 views4 pages

Module 4 Suggestion Questions

The document contains a series of suggestion questions related to activation records, memory allocation, and code production techniques in programming. It covers topics such as the layout of activation records, the differences between stack-based and heap-based allocation, and various optimization strategies for code generation. Additionally, it includes practical exercises for generating machine commands and assessing performance impacts of different programming constructs.

Uploaded by

Aryanil Roy
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views4 pages

Module 4 Suggestion Questions

The document contains a series of suggestion questions related to activation records, memory allocation, and code production techniques in programming. It covers topics such as the layout of activation records, the differences between stack-based and heap-based allocation, and various optimization strategies for code generation. Additionally, it includes practical exercises for generating machine commands and assessing performance impacts of different programming constructs.

Uploaded by

Aryanil Roy
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

MODULE 4 SUGGESTION QUESTIONS

2 Marks

1.​ Show the layout of an activation record including appropriate components.


2.​ Contrast caller-saved and callee-saved registers within activation records, using
illustrations.
3.​ Assess the pros and cons of stack-based versus heap-based allocation for function
invocations.
4.​ Develop an activation record format for a recursive factorial procedure and explain your
choices.
5.​ Describe the function of the control link and access link in activation records, using a
sample code snippet.
6.​ Illustrate the method for a function to reach non-local variables without any nesting.
7.​ Examine the function of static and dynamic links in reaching non-local data for nested
functions.
8.​ Assess whether access links or displays provide better performance for non-local
variable access and explain the reason.
9.​ Suggest a method to handle non-local variable access in a language featuring deep
function nesting.
10.​Depict with a figure how references to non-local variables are handled via static chains.
11.​Generate a series of basic machine commands for calculating x = a + b * c.
12.​Examine the impact of varying evaluation sequences (left-to-right versus right-to-left) in
code production for math expressions.
13.​Assess the performance of register-oriented machines compared to stack-oriented
machines in code production.
14.​Suggest a register assignment approach for producing machine code from a
three-address instruction sequence.
15.​Show code production for the statement A[i] = B[j] + c, given an array stored in memory.
16.​Show common subexpression removal using a fitting example.
17.​Examine how constant propagation shrinks the generated code volume, with an
illustration.
18.​Assess the contribution of unused code removal to enhancing program performance.
19.​Suggest a technique to improve loop-invariant operations in a multi-level loop setup.
20.​Show algebraic transformation by refining the expression x = (a * 1) + (b * 0).
21.​Illustrate the interplay between activation records and code production during recursive
procedure runtime.
22.​Examine the challenges of machine-independent optimizations for array operations
within loops.
23.​Assess the performance of code before and after strength reduction on x = x * 2.
24.​Develop a code production method for logical expressions using short-circuit logic.
25.​Suggest an integrated strategy combining activation records, code production, and
optimizations for a recursive procedure with inner loops.
5 marks
1.​ Describe the format and role of an activation record. Show its application in a
recursive procedure illustration.
2.​ Contrast stack-based allocation with heap-based allocation regarding function
invocations and memory handling.
3.​ Assess the importance of control link and access link in overseeing function calls.
Which is more crucial for recursion? Provide reasoning.
4.​ Develop an activation record arrangement for a procedure including inputs, local
items, temporary values, and output results.
5.​ Show with an illustration how non-local variables are reached in functions lacking
nesting.
6.​ Examine the operation of static chains for reaching non-local variables in nested
functions.
7.​ Assess the performance of access links versus display tables for non-local
variable access. Which would you choose for programs with deep nesting?
8.​ Suggest a technique to implement non-local variable access in a language with
various nesting depths. Back it up with a figure.
9.​ Generate machine commands for the math expression x = (a + b) * (c – d).
10.​Examine the influence of evaluation sequence (left-to-right versus right-to-left) on
machine code production for math expressions.
11.​Assess the advantages and drawbacks of stack-oriented versus register-oriented
machines in code production.
12.​Develop a code production method for the array statement A[i] = B[j] + c,
assuming row-major memory layout.
13.​Show the use of constant propagation on a math expression with a suitable
illustration.
14.​Examine how common subexpression removal boosts code performance. Give
an example of code before and after refinement.
15.​Assess the effect of loop-invariant code shifting on runtime for multi-level loops.
16.​Suggest a refined version of this code using strength reduction:

for (i = 1; i <= n; i++)


x = x * 2;

17.​Show with an illustration how activation records connect with code production in
recursive procedure runtime.
18.​Examine the issues in applying machine-independent optimizations to array
calculations inside loops.
19.​Assess the performance variations of code before and after unused code
removal. Use a brief code sample to demonstrate.
20.​Suggest a system that merges activation records, non-local variable access, and
optimization methods for effective code production in nested recursive functions.
10 marks

1.​ Describe thoroughly the format of an activation record. Develop an


activation record arrangement for a recursive factorial procedure and
follow how records are handled on the stack at runtime.
2.​ Contrast the operation of dynamic link and static link in activation records.
Examine their contribution to recursion and nested function invocations.
3.​ Assess the benefits and constraints of stack-based allocation versus fixed
allocation. Support with illustrations where stack-based allocation excels.
4.​ Develop an activation record format for a language that handles inputs,
local items, temporary values, output results, and nested functions. Show
with a figure.
5.​ Show with an illustration how non-local variables are reached in functions
without nesting. Include stack figures.
6.​ Examine the process of static chains for reaching non-local variables in
nested functions. Demonstrate its operation with a sample code.
7.​ Assess and contrast the performance of static chains and displays for
non-local variable access. Discuss cases where one outperforms the
other.
8.​ Suggest and develop a technique for effective non-local variable access
in a structure with deep nested functions. Back it with figures and sample
code.
9.​ Generate machine commands for the math expression x = (a + b) * (c – d)
on a register-oriented system. Describe the operation sequence.
10.​Examine the influence of operand evaluation sequence (left-to-right
versus right-to-left) on machine code production for x = a – b – c. Provide
a detailed walkthrough.
11.​Assess the runtime variations between stack-oriented and
register-oriented machines for code production. Support with an example
calculation.
12.​Develop a machine code production method for multi-dimensional array
statement A[i][j] = B[i][j] + C, under row-major memory setup.
13.​Show the use of constant propagation and common subexpression
removal on this code:

x = 2 * 3;
y = x + z * 5;
w = 6 + z * 5;

14.​Examine the impact of loop-invariant code shifting on this program. Show


the refined version.

for (i = 1; i <= n; i++) {


x = a * b;
y[i] = x + i;
}

15.​Suggest and develop a refined code for this loop using strength reduction
and unused code removal:

for (i = 1; i <= n; i++) {


x = i * 8;
y = y + 0;
}

You might also like