Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

2. (15 Points) For each of the following actions, state whether it happens at co

ID: 3571459 • Letter: 2

Question

2. (15 Points) For each of the following actions, state whether it happens at compiler construction time (i.e., when developing the compiler) compile time (i.e., when compiling or linking a program) run-time (i.e. when executing the code generated by the compiler) For example, evaluating an arithmetic expression will mostly occur at run-time (but can occur at compile time if all operands have known constant values). Consider only normal scenarios for these actions. a. Compute address of a local variable. This happens at run-time. This is the only time where a variable is finally being used and assigned its place in the stack, for example. b. Elimination of a common sub-expression This happens at compile-time. Here is where optimization will become handy c. Choose in which area of memory (static data, heap, or stack) a variable will be stored This takes place at run-time

Explanation / Answer

Compute address of a local variable
   This happens at run time. This is the only time where a variable is finally being used and assigned its place in stack
Answer- The above statement is true. Local and dynamically allocated variables have addresses that are not known by the compiler when the source file is compiled.
       This happens at the run time.


Elimination of a common sub-expression
   this happens at compile-time. here is where optimization will become handy.
Answer- The above statement is true. At compile time the compiler looks for the instance where the    value evaluates to the same value every time, it replaces them
       with single variable with the computed value.

Choose in which area of memory (static data, heap, or stack) a variable will be stored.
   This takes place at run-time.
Answer- The above statement is false. The assignment of the variable is done at compile time.

Note: Please feel free to ask question.queries. God bless you!

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote