Callee-save registers in continuation-passing style

Callee-save registers in continuation-passing style
复制标题

被调用者以连续传递方式保存寄存器

DOI:
--
复制
发表时间:
1992
期刊:
LISP and Symbolic Computation
影响因子:
--
通讯作者:
Zhong Shao
Zhong Shao
中科院分区:
--
文献类型:
--
作者:
A. Appel;Zhong Shao

文献摘要

被引文献

相似文献

延续传递风格(CPS)是一种用于编译和优化的良好抽象表示形式:它具有清晰的语义且易于操作。我们研究CPS如何在源语言过程调用中表达寄存器的保存和恢复。在大多数基于CPS的编译器中,调用过程的上下文被保存在一个“延续闭包”中——一个作为参数传递给被调用函数的单一变量。这个闭包是一个包含延续中所有自由变量绑定的记录;也就是说,保存调用者“调用后”所需值的寄存器被写入闭包中的内存,并在调用后取回。 考虑传统编译器使用的过程调用机制。特别是,保存调用后所需值的寄存器必须被保存并稍后恢复。保存寄存器的责任可以由调用者承担(“调用者保存”约定),也可以由被调用函数承担(“被调用者保存”)。在实践中,为了优化内存流量,编译器发现设置一些调用者保存寄存器和一些被调用者保存寄存器是有用的。 传递一个指向包含调用后所需所有变量(即延续闭包)的记录的指针的“传统”基于CPS的编译器,使用的是调用者保存约定。我们解释如何在延续传递风格中表达被调用者保存寄存器,并给出测量结果,展示执行时间由此得到的改善。
Continuation-passing style (CPS) is a good abstract representation to use for compilation and optimization: it has a clean semantics and is easily manipulated. We examine how CPS expresses the saving and restoring of registers in source-language procedure calls. In most CPS-based compilers, the context of the calling procedure is saved in a “continuation closure”—a single variable that is passed as an argument to the function being called. This closure is a record containing bindings of all the free variables of the continuation; that is, registers that hold values needed by the caller “after the call” are written to memory in the closure, and fetched back after the call.Consider the procedure-call mechanisms used by conventional compilers. In particular, registers holding values needed after the call must be saved and later restored. The responsibility for saving registers can lie with the caller (a “caller-saves” convention) or with the called function (“callee-saves”). In practice, to optimize memory traffic, compilers find it useful to have some caller-saves registers and some callee-saves.“Conventional” CPS-based compilers that pass a pointer to a record containing all the variables needed after the call (i.e., the continuation closure), are using a caller-saves convention. We explain how to express callee-save registers in Continuation-Passing Style, and give measurements showing the resulting improvement in execution time.