Runtime compilation of runtime-constructed code is becoming standard practice in libraries, DSLs, and database management systems. Since compilation is expensive, systems that are sensitive to compile times such as relational database query compilers compile only hot code and interprets the rest with a much slower interpreter. We present a code generation technique that lowers an AST to binary code by stitching together code from a large library of binary AST node implementations. We call the implementations stencils because they have holes where values must be inserted during code generation. We show how to construct such a stencil library and describe the copy-and-patch technique that generates optimized binary code. The result is a code generator with negligible cost: it produces code from an AST in less time than it takes to construct the AST. Compared to LLVM, compilation is two orders of magnitude faster than -O0 and three orders of magnitude faster than higher optimization levels. The generated code runs an order of magnitude faster than interpretation and runs even faster than LLVM -O0. Thus, copy-and-patch can effectively replace both interpreters and LLVM -O0, making code generation more effective in compile-time sensitive applications.


翻译:运行时间构建代码的运行时间编译正在成为图书馆、 DSL 和数据库管理系统的标准做法。 由于编译费用昂贵, 系统对于编辑时间非常敏感, 如关系数据库查询汇编器等系统只编辑热代码, 并且用慢得多的翻译器来解释其余的代码。 我们展示了一种代码生成技术, 将二进制的 AST 编译为二进制代码, 将二进制 AST 节点执行的大型图书馆的代码缝合在一起。 我们调用执行系统 Stencils, 因为它们有在代码生成过程中必须插入值的洞洞。 我们展示了如何构建这样的 高级库, 并描述生成优化二进制代码的复制和批次技术。 结果是一个代码生成器, 其成本微不足道: 它生成一个 AST 的代码比构建 AST 所需的时间要少得多。 与 LLVM 执行程序相比, 编成两个数量级比 - O0 和三个数量级要快, 比最优化级别还要快。 生成的代码比 LLVM - O0 运行速度要快, 速度更快。 因此, 复制和 patch 能够有效地编辑两个翻译和LLLVM 的版本。

0
下载
关闭预览

相关内容

【2020新书】Web应用安全,331页pdf
专知会员服务
23+阅读 · 2020年10月24日
【Google】平滑对抗训练,Smooth Adversarial Training
专知会员服务
46+阅读 · 2020年7月4日
【新书】Python编程基础,669页pdf
专知会员服务
186+阅读 · 2019年10月10日
计算机视觉最佳实践、代码示例和相关文档
专知会员服务
17+阅读 · 2019年10月9日
【SIGGRAPH2019】TensorFlow 2.0深度学习计算机图形学应用
专知会员服务
39+阅读 · 2019年10月9日
MIT新书《强化学习与最优控制》
专知会员服务
270+阅读 · 2019年10月9日
GAN新书《生成式深度学习》,Generative Deep Learning,379页pdf
专知会员服务
196+阅读 · 2019年9月30日
Transferring Knowledge across Learning Processes
CreateAMind
25+阅读 · 2019年5月18日
已删除
将门创投
5+阅读 · 2019年4月4日
Call for Participation: Shared Tasks in NLPCC 2019
中国计算机学会
5+阅读 · 2019年3月22日
Unsupervised Learning via Meta-Learning
CreateAMind
41+阅读 · 2019年1月3日
Hierarchical Imitation - Reinforcement Learning
CreateAMind
19+阅读 · 2018年5月25日
carla 体验效果 及代码
CreateAMind
7+阅读 · 2018年2月3日
Adversarial Variational Bayes: Unifying VAE and GAN 代码
CreateAMind
7+阅读 · 2017年10月4日
Auto-Encoding GAN
CreateAMind
7+阅读 · 2017年8月4日
Arxiv
0+阅读 · 2021年1月17日
Arxiv
7+阅读 · 2018年3月21日
Arxiv
5+阅读 · 2017年11月30日
VIP会员
相关VIP内容
【2020新书】Web应用安全,331页pdf
专知会员服务
23+阅读 · 2020年10月24日
【Google】平滑对抗训练,Smooth Adversarial Training
专知会员服务
46+阅读 · 2020年7月4日
【新书】Python编程基础,669页pdf
专知会员服务
186+阅读 · 2019年10月10日
计算机视觉最佳实践、代码示例和相关文档
专知会员服务
17+阅读 · 2019年10月9日
【SIGGRAPH2019】TensorFlow 2.0深度学习计算机图形学应用
专知会员服务
39+阅读 · 2019年10月9日
MIT新书《强化学习与最优控制》
专知会员服务
270+阅读 · 2019年10月9日
GAN新书《生成式深度学习》,Generative Deep Learning,379页pdf
专知会员服务
196+阅读 · 2019年9月30日
相关资讯
Transferring Knowledge across Learning Processes
CreateAMind
25+阅读 · 2019年5月18日
已删除
将门创投
5+阅读 · 2019年4月4日
Call for Participation: Shared Tasks in NLPCC 2019
中国计算机学会
5+阅读 · 2019年3月22日
Unsupervised Learning via Meta-Learning
CreateAMind
41+阅读 · 2019年1月3日
Hierarchical Imitation - Reinforcement Learning
CreateAMind
19+阅读 · 2018年5月25日
carla 体验效果 及代码
CreateAMind
7+阅读 · 2018年2月3日
Adversarial Variational Bayes: Unifying VAE and GAN 代码
CreateAMind
7+阅读 · 2017年10月4日
Auto-Encoding GAN
CreateAMind
7+阅读 · 2017年8月4日
Top
微信扫码咨询专知VIP会员