Calling convention-调用约定
In computer science, a calling convention is an implementation-level (low-level) scheme for how subroutines receive parameters from their caller and how they return a result. Differences in various implementations include where parameters, return values, return addresses and scope links are placed, and how the tasks of preparing for a function call and restoring the environment afterward are divided between the caller and the callee.
Calling conventions may be related to a particular programming language's evaluation strategy but most often are not considered part of it (or vice versa), as the evaluation strategy is usually defined on a higher abstraction level and seen as a part of the language rather than as a low-level implementation detail of a particular language's compiler.
Variations[edit]
Calling conventions may differ in:
- Where parameters, return values and return addresses are placed (in registers, on the call stack, a mix of both, or in other memory structures)
- The order in which actual arguments for formal parameters are passed (or the parts of a large or complex argument)
- How a (possibly long or complex) return value is delivered from the callee back to the caller (on the stack, in a register, or within the heap)
- How the task of setting up for and cleaning up after a function call is divided between the caller and the callee
- Whether and how metadata describing the arguments is passed
- Where the previous value of the frame pointer is stored, which is used to restore the frame pointer when the routine ends (in the stack frame, or in some register)
- Where any static scope links for the routine's non-local data access are placed (typically at one or more positions in the stack frame, but sometimes in a general register, or, for some architectures, in special-purpose registers)
- How local variables are allocated can sometimes also be part of the calling convention (when the caller allocates for the callee)
In some cases, differences also include the following:
- Conventions on which registers may be directly used by the callee, without being preserved (otherwise regarded as an ABI detail)
- Which registers are considered to be volatile and, if volatile, need not be restored by the callee (often regarded as an ABI detail)
Language variation[edit]
Threaded code[edit]
Threaded code places all the responsibility for setting up for and cleaning up after a function call on the called code. The calling code does nothing but list the subroutines to be called. This puts all the function setup and cleanup code in one place—the prolog and epilog of the function—rather than in the many places that function is called. This makes threaded code the most compact calling convention.
Threaded code passes all arguments on the stack. All return values are returned on the stack. This makes naive implementations slower than calling conventions that keep more values in registers. However, threaded code implementations that cache several of the top stack values in registers—in particular, the return address—are usually faster than subroutine calling conventions that always push and pop the return address to the stack.[1][2][3]
https://en.wikipedia.org/wiki/Calling_convention
Calling convention-调用约定的更多相关文章
- C/C++/动态链接库DLL中函数的调用约定与名称修饰
参见:http://blog.twofei.com/cc/impl/calling-convension.html 调用约定(Calling Convention)是指在程序设计语言中为了实现函数调用 ...
- X86调用约定 calling convention
http://zh.wikipedia.org/wiki/X86%E8%B0%83%E7%94%A8%E7%BA%A6%E5%AE%9A 这里描述了在x86芯片架构上的调用约定(calling con ...
- C/C++:函数的调用约定(Calling Convention)和名称修饰(Decorated Name)以及两者不匹配引起的问题
转自:http://blog.csdn.net/zskof/article/details/3475182 注:C++有着与C不同的名称修饰,主要是为了解决重载(overload):调用约定则影响函数 ...
- C++调用约定和名字约定
C++调用约定和名字约定 转自http://www.cppblog.com/mzty/archive/2007/04/20/22349.html 调用约定:__cdecl __fastcall与 __ ...
- DLL中调用约定和名称修饰(一)
DLL中调用约定和名称修饰(一) 调用约定(Calling Convention)是指在程序设计语言中为了实现函数调用而建立的一种协议.这种协议规定了该语言的函数中的参数传送方式.参数是否可变和由谁来 ...
- Delphi调用约定
Register Calling Convention Ojbect Pascal的默认调用约定为register,寄存器调用约定会将前三个参数依次放入eax,edx,ecx,返回值是eax(根据类型 ...
- VC内存溢出一例 –- 调用约定不一致 (_CRT_DEBUGGER_HOOK(_CRT_DEBUGGER_GSFAILURE)
VC (_CRT_DEBUGGER_HOOK(_CRT_DEBUGGER_GSFAILURE) 问题记录 VC内存溢出一例 –- 调用约定不一致 (_CRT_DEBUGGER_HOOK(_CRT_DE ...
- 从栈不平衡问题 理解 calling convention
最近在开发的过程中遇到了几个很诡异的问题,造成了栈不平衡从而导致程序崩溃. 经过几经排查发现是和调用规约(calling convention)相关的问题,特此分享出来. 首先,讲一下什么是调用规约. ...
- 调用约定__cdecl __fastcall与__stdcall
__cdecl __fastcall与__stdcall,三者都是调用约定(Calling convention),它决定以下内容:1)函数参数的压栈顺序,2)由调用者还是被调用者把参数弹出栈,3)以 ...
- C&C++ Calling Convention
tkorays(tkorays@hotmail.com) 调用约定(Calling Convention) 是计算机编程中一个比较底层的设计,它主要涉及: 函数参数通过寄存器传递还是栈? 函数参数从左 ...
随机推荐
- python小项目之头像右上角加数字
pillow介绍 一.Image类的属性:1.Format 2.Mode 3.Size 4.Palette 5.Info 二.类的函数:1.New 2.Open 3.Ble ...
- 使用 Travis-CI 的五个理由
I use the service of travis-ci now for a year. In that time the continuous integration has often poi ...
- [Reading] Asking while Reading
Asking while Reading ——读Java垃圾收集器与内存分配策略 Java与C++之间有一堵由内存动态分配和垃圾收集技术所围成的“高墙”,墙外面的人想进去,墙里面的人却想出来. 为什么 ...
- centos 7 防火墙配置
centos 7里的防火墙使用的是firewall. 之前问过一个运维大牛,selinux的位置有点尴尬,说他们在工作中一般都会在第一时间关闭掉.我记得当时自己假设网站的时候就被这个坑了大半晚上.这个 ...
- Build rpm example:zram
rpmbuild #ll zram-1.0.0 total 32 -rw-r--r-- 1 root root 948 Aug 21 16:44 Makefile -rw-r--r-- 1 root ...
- [学习笔记] CS131 Computer Vision: Foundations and Applications:Lecture 1 课程介绍
课程大纲:http://vision.stanford.edu/teaching/cs131_fall1718/syllabus.html 课程定位: 课程交叉: what is (computer) ...
- oracle数据库安装教程以及问题和解决方法
一,oracle数据库的下载和安装 1,在oracle官网上下载oracle安装包,运行setup.exe. 2,点击取消“我希望同构My Oracle Support接受安全更新”,以防后患. 3, ...
- 再识Quartz
在之前的项目中使用过Quartz,但都是基于XML配置定义任务的.目前一个项目应用需要对任务进行创建.暂停.删除等动态管理.所以再次在网上翻了翻,再来好好重新认识下Quartz. 名词解释: sche ...
- OO第一单元总结__多项式求导问题
作业一.含幂函数的简单多项式的求导 (1)基于度量的程序结构分析 1. 统计信息图: 2. 结构信息图: 3. 复杂度分析 基本复杂度(Essential Complexity (ev(G)).模块设 ...
- android startservice无法启动服务
1.android startservice无法启动服务 之前MainActivity.java中启动service源代码如下: private void startMyService() { //启 ...