Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is an execution frame?

In C#, what is an execution frame (also related to this I have heard of activation frame). IIRC it is a slot where method parameters go but cannot remember all of the details.

Thanks

like image 577
GurdeepS Avatar asked Mar 05 '10 23:03

GurdeepS


People also ask

What is execution frame in Python?

A code block is executed in an execution frame. A frame contains some administrative information (used for debugging) and determines where and how execution continues after the code block's execution has completed.

What is an execution frame in relation to a function?

"Execution frame" is a term that is used in interpreted languages, Python in particular. That's a very different execution model from C#. The closest equivalent is a scope block in a C# method, a chunk of code that is is bracketed with curly braces.


2 Answers

"Execution frame" is a term that is used in interpreted languages, Python in particular. That's a very different execution model from C#. The closest equivalent is a scope block in a C# method, a chunk of code that is is bracketed with curly braces. Although a Python execution frame could also extend to the body of a function, now it's equivalent to a stack frame in C#. Which is another term for an activation frame.

The C# compiler recognizes declarations that are local to a scope block in C#. The runtime doesn't, it only recognizes a stack frame that's active for the life of the entire method. The difference is trivially papered-over by the compiler by simply declaring the sum of all local variables in all scope blocks as the activation frame. That's a luxury that a Python interpreter cannot afford.

like image 161
Hans Passant Avatar answered Oct 27 '22 01:10

Hans Passant


I believe you're referring to a stack frame - in which case the answer is not specific to C# or indeed to any particular language, but rather to the platform that your program is executing on. From the Wikipedia article on the Call Stack:

A call stack is composed of stack frames (sometimes called activation records). These are machine dependent data structures containing subroutine state information. Each stack frame corresponds to a call to a subroutine which has not yet terminated with a return.

See also this answer to a previous question for an excellent description of the stack, including stack frames.

like image 39
razlebe Avatar answered Oct 26 '22 23:10

razlebe