0

过程激活时间是否是编译时间的一部分,从而执行函数调用的准备工作?

或者它是实际调用函数时运行时的一部分?

(虽然不确定,但我正在考虑第二种选择)

4

1 回答 1

1

You are probably referring to how a function is called. I assume you want to know how arguments are passed, copied, etc.

Each function has a "calling convention" that specifies how the function is to be called. This is the process whereby the program places arguments on the stack, saves the current location of the instruction in the calling function, and jumps to the called function's first instruction. In addition the calling convention specifies how to return back to the calling function and how the return value is saved. How this is done will be platform specific and depend on the calling convention in use for a given function.

Based on the calling convention, code is emitted by the compiler to perform the correct steps to call the function. This code would be executed at runtime to perform the call. You can read more about x86's calling conventions on wikipedia here x86 calling conventions.

于 2011-05-03T13:38:06.237 回答