作者l314 (红虫)
看板CSSE
标题[问题] 请问calling convention..
时间Sun Jun 24 08:17:19 2007
请问一下calling convention,
caller save register及callee save register,与下面这些叙述有什麽关联吗?
pascal convention 规定:三数传递次序由左而右,stack frame 的清理由被呼叫端(
callee)负责。
c convention 规定:三数传递次序由右而左,stack frame 的清理由呼叫端(caller)
负责。
由於 pascal convention 规定 stack frame 的清理由被呼叫端(callee)负责,因此如
对同一函式呼叫一千次,其 stack frame cleanup routine只需一份(位於 callee 内,
由编译器加入)。
由於 c convention 规定 stack frame 的清理由呼叫端(caller)负责,因此对同一个
函式呼叫一千次,其 stack frame cleanup routine需 1000 份(位於呼叫点,由编译器
加入)。
因此,采用 pascal calling convention,对於降低程式码大小(并因而增加执行速度)
,在某些情况下很有帮助。这是为什麽早期 Windows 系统内部几乎完全采用 pascal
calling convention 的原因。
但是 pascall convention 不支援「个数不定之引数」。例如 printf()的引数个数不一
定,那就一定得使用 c calling convention。
还有下面这句,我也不太懂它的意思..
If a procedure is called n times, then the portion of the calling sequence in
the various callers is generated n times. However, the portion of the callee
is shared by calls, so it is generated just once. Hence, it is desirable to
put as much of the calling sequence into the callee as possible.
最後请问calling convention与call by value, call by reference, call by name..
又有什麽关联呢?
请问小弟我是不是什麽核心观念没弄清楚,所以才会产生前述的混淆..
请板上前辈指点一下..谢谢..
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.119.201.20