Replacing function parameters by global variables
Replacing function parameters by global variables
复制标题
用全局变量替换函数参数
DOI:
10.1145/99370.99374
复制
发表时间:
1989
影响因子:
2.5
通讯作者:
P. Sestoft
中科院分区:
文献类型:
--
作者:
P. Sestoft
We investigate when function parameters can be safely replaced by global variables. This replacement is called globalization. The objective of globalization is to reduce the time and space cost of stack (or heap) allocation of function parameters when possible. We present an automatic interference analysis that decides whether a given function parameter may safely be globalized. The analysis is based on formal operational semantics to facilitate correctness proofs. The main contribution of this work is to introduce the concepts of definition-use path, path semantics, interference, and definition-use grammar. A definition-use path is a linear recording of the definitions and uses of variables during a computation. The path semantics of a language prescribes the path for a computation and is an extension of the operational semantics. Interference in a path means that the value of a variable becomes modified (by a redefinition) before its last use. A non-interfering variable is globalizable. A definition-use grammar is constructed from a program and the path semantics, and derives a superset of all possible paths for the program. The interference analysis is d. one by an analysis of the grammar, and it safely approximates the “exact” interference in the program. Finally, the globalization transformation uses the results of the interference analysis. The techniques apply to both first order and higher order languages with strict (ie, call by value) semantics and variables with non-composite data values. We compare our technique to those used in related work reported in the litertitnre.Permission to copy without fee a11 or part of this material is granted provided that the copies are not made or distributed for direct commercial advantage, the ACM copyright notice and the title of the publication and its date appear, and notice is given that copying is by permission of the Association for Computing Machinery. To copy otherwise, or to republish, requires a fee and/or specific permission.