函数活动记录
来源:互联网 发布:天谕业刹女捏脸数据 编辑:程序博客网 时间:2024/05/01 01:42
Suppose procedure P (the caller) calls procedure Q (the callee). The arguments to Q are contained within the stack frame for P. In addition, when P calls Q, the return address within P where the program should resume execution when it returns from Q is pushed on the stack, forming the end of P’s stack frame. The stack frame for Q starts with the saved value of the frame pointer (i.e., %ebp). followed by copies of any other saved register values.
Procedure Q also uses the stack for any local variables that cannot be stored in registers. This can occur for the following reasons:
1. There are not enough registers to hold all of the local data.
2. Some of the local variables are arrays or structures and hence must be accessed by array or structure references.
3. The address operator ‘&’ is applied to one of the local variables, and hence we must be able to generate an address for it.
Finally, Q will use the stack frame for storing arguments to any procedures it calls.
As described earlier, the stack grows toward lower addresses and the stack pointer %esp points to the top element of the stack. Data can be stored on and retrieved from the stack using the pushl and popl instructions. Space for data with no specified initial value can be allocated on the stack by simply decrementing the stack pointer by an appropriate amount. Similarly, space can be deallocated by incrementing the stack pointer.
活动记录:过程的一次执行所需要的信息用一块连续的存储区来管理,这块存储区叫做活动记录。
活动记录的各个域的用途:
1、临时数据域:如计算表达式出现的中间结果,若寄存器不足以存放所有这些中间结果时,可以把它们存放在临时数据域中
2、局部数据域:保存局部于过程执行的数据
3、机器状态域:保存刚好在过程调用前的机器状态信息,包括机器计数器的值和控制从这个过程返回必须恢复的机器寄存器的值
4、控制链:用来指向调用者的活动记录,控制链也称动态链
5、参数域:用来存放调用过程提供的实在参数
6、返回值域:用来存放被调用过程返回给调用过程的值
活动记录其实比没有包含过程一次执行所需的全部信息,比方说非局部数据就不在活动记录中,另外,过程运行时生成的动态变量也不在活动记录中,对它们通常采用堆式分配
- 函数活动记录
- 函数调用栈与活动记录
- 函数调用栈与活动记录
- 活动记录
- 活动记录
- C语言活动记录
- 什么是活动记录模式?
- 学习小组活动记录
- Active Record 活动记录
- ActiveRecord活动记录类
- 活动记录 Active Record
- 红包活动实战记录
- C 函数被调用时发生了什么:过程活动记录
- 运行时数据结构-活动记录
- 4. PHP之活动记录
- 记录今天mysql导出活动
- 【贪心算法】:活动记录问题
- 异步函数 活动对象
- CodeSmith基础(一)
- .NET中栈和堆的比较(一)
- 详解多播和广播
- CodeSmith基础(二)
- 程序员怎样找到自己的核心竞争力
- 函数活动记录
- 弱智的MSN
- 获取某个表的列名类型和长度
- The first time to here.
- 中午休息,无聊的系统管理,热备还是很有意思
- C++ 返回值类型与引用类型的区别
- asp代码封装技术
- .NET Oracle连接字符串
- JAVA中Date转换大全!(自己收集和写出来的)