Call Stack
Definition / 定义
调用栈:程序运行时用来管理函数(或方法)调用顺序的一块内存结构。每次调用函数会创建一个“栈帧(stack frame)”并压入栈中;函数返回时对应栈帧弹出。它常用于保存返回地址、参数、局部变量等信息。也常用来指“栈追踪/调用链”(例如错误信息里的调用顺序)。
Pronunciation / 发音
/ˈkɔːl stæk/
Examples / 例句
The call stack shows which function is running now.
调用栈会显示当前正在运行的是哪个函数。
When the program crashed, the debugger printed a call stack that traced the error back through several nested function calls.
程序崩溃时,调试器打印出一份调用栈,沿着多层嵌套的函数调用把错误追溯到源头。
Etymology / 词源
“Call stack”由 call(调用) + stack(栈) 组成:call 表示“调用某个函数/过程”,stack 指“后进先出(LIFO)”的数据结构。组合起来就形象地表达了“函数调用按栈的方式进出”的运行机制。该术语随现代编程语言与操作系统的普及而广泛使用。
Related Words / 相关词
Literary Works / 著名作品
- Computer Systems: A Programmer’s Perspective(Randal E. Bryant, David R. O’Hallaron)——讲解过程调用、栈帧与调用栈在体系结构层面的实现
- The C Programming Language(Brian W. Kernighan, Dennis M. Ritchie)——涉及函数调用与栈相关概念(虽不总以“call stack”作为固定词组呈现)
- Structure and Interpretation of Computer Programs(Harold Abelson, Gerald Jay Sussman)——讨论过程调用与求值模型,常引出对调用栈/控制栈的理解
- Debugging: The 9 Indispensable Rules for Finding Even the Most Elusive Software and Hardware Problems(David J. Agans)——调试实践中经常使用“stack trace / call stack”来定位错误