首页> 外文期刊>Computer languages >Optimizing the stack size of recursive functions
【24h】

Optimizing the stack size of recursive functions

机译:优化递归函数的堆栈大小

获取原文
获取原文并翻译 | 示例
           

摘要

For memory constrained environments, optimization for program size is often as important as, if not more important than, optimization for execution speed. Commonly, compilers try to reduce the code segment but neglect the stack segment, although the stack can significantly grow during the execution of recursive functions because a separate activation record is required for each recursive call.rnIf a formal parameter or local variable is dead at all recursive calls, then it can be declared global so that only one instance exists independent of the recursion depth. We found that in 70% of our benchmark functions, it is possible to reduce the stack size by declaring formal parameters and local variables global. Often, live ranges of formal parameters and local variables can be split at recursive calls through program transformations. These splitting transformations allowed us to further optimize the stack size of all our benchmark functions. If all formal parameters and local variables can be declared global, then such functions may be transformable into iterations. This was possible for all such benchmark functions.
机译:对于内存受限的环境,程序大小的优化通常与执行速度的优化同等重要。通常,编译器会尝试减少代码段,而忽略堆栈段,尽管在递归函数执行期间堆栈会显着增长,因为每次递归调用都需要单独的激活记录。rn如果形式参数或局部变量完全失效递归调用,则可以将其声明为全局,以便仅存在一个实例,而与递归深度无关。我们发现在70%的基准功能中,可以通过声明形式参数和全局局部变量来减小堆栈大小。通常,可以在递归调用中通过程序转换拆分形式参数和局部变量的有效范围。这些拆分转换使我们可以进一步优化所有基准功能的堆栈大小。如果所有形式参数和局部变量都可以声明为全局变量,则此类函数可以转换为迭代。对于所有此类基准功能,这都是可能的。

著录项

相似文献

  • 外文文献
  • 中文文献
  • 专利
获取原文

客服邮箱:kefu@zhangqiaokeyan.com

京公网安备:11010802029741号 ICP备案号:京ICP备15016152号-6 六维联合信息科技 (北京) 有限公司©版权所有
  • 客服微信

  • 服务号