APP下载

高阶代码消除性能比较框架的设计与实现

2016-11-01赵迪华保健朱洪军

计算机应用 2016年9期
关键词:定义效率语言

赵迪 华保健 朱洪军

摘要:

函数式语言编译中,闭包变换和函数消除是广泛采用的高阶代码消除方法。为了提高函数式语言的运行效率,针对函数式语言编译阶段的高阶代码消除过程对目标代码效率的影响,設计并实现了一种函数式语言编译框架。该框架采用了菱形的架构,平行地使用了闭包变换与函数消除两种高阶代码消除方法。设计了一种具有代表性的函数式语言——FUN语言,并以FUN语言为基础,给出了比较框架的一个完整实现。通过该系统,对闭包变换与函数消除的效率影响进行对比实验,选取具有典型特征的测试例,分别从生成代码的规模和运行效率方面对闭包变换与函数消除两种方法的结果进行比较。实验结果表明,与闭包变换相比,使用函数消除方式所得的目标代码量更少,最多可减少33.76%的目标代码量;并且运行效率更高,最多可提高69.51%。

关键词:

编译框架;函数式语言;高阶代码;闭包变换;函数消除

中图分类号:

TP311.5

文献标志码:A

Abstract:

In functional programming language compilation, closure conversion and defunctionalization are two widely used higherorder code eliminating methods. To improve the operational efficiency of functional programming languages, focusing on the higherorder code eliminating phase, a compiler frame to compare the performance of code generated by closure conversion and defunctionalization was proposed. Both closure conversion and defunctionalization were used in parallel in the comparing frame with a diamond structure. A functional programming language named FUN and a compiling system for FUN based on the comparing frame was proposed. Experiment is conducted on the system to compare the two methods. The outputs were compared in performance and quantity of code.Comparison experiments of closure conversion and defunctionalization were conducted on the proposed system by using typical use cases, and the experimental results were compared in code quantity and operation efficiency. The result suggests that compared with closure conversion, defunctionalization can produce shorter and faster target code; the amount of code can be decreased by up to 33.76% and performance can be improved by up to 69.51%.

英文关键词Key words:

compiler frame; functional programming language; higherorder code; closure conversion; defunctionalization

0引言

函数式语言的发展历史最早可以追溯到Church & Rosser提出的λ演算。1950年代早期,McCarthy研究并开发了第一个函数式语言LISP,至今仍被使用[1]。近年来,随着软件系统的复杂化,函数式语言凭借支持高阶函数、具有较好的并行性等优点被广泛研究和应用。例如Twitter目前使用Scala语言[2],WhatsApp使用了Erlang[3]等。此外,在分布式计算、机器学习、大数据处理等研究与商业应用的热点领域中也大量使用了函数式语言[4-6]。例如,目前流行的开源集群计算框架Apache Spark就是使用Scala实现的[7]。……

登录APP查看全文

猜你喜欢

定义效率语言
提升朗读教学效率的几点思考
语言是刀
让语言描写摇曳多姿
成功的定义
我有我语言
跟踪导练(一)2
“钱”、“事”脱节效率低
修辞学的重大定义
山的定义
提高讲解示范效率的几点感受