Fusing method handle graphs for efficient dynamic JVM language implementations

Shijie Xu, David Bremner, Daniel Heidinga
{"title":"Fusing method handle graphs for efficient dynamic JVM language implementations","authors":"Shijie Xu, David Bremner, Daniel Heidinga","doi":"10.1145/3141871.3141874","DOIUrl":null,"url":null,"abstract":"A Method Handle (MH) in JSR 292 (Supporting Dynamically Typed Languages on the JVM) is a typed, directly executable reference to an underlying method, constructor, or field, with optional method type transformations. Multiple connected MHs make up a Method Handle Graph (MHG), which transfers an invocation at a dynamic call site to real method implementations at runtime. Despite benefits that MHGs have for dynamic JVM language implementations, MHGs challenge existing JVM optimization because a) larger MHGs at call sites incur higher graph traversal costs at runtime; and b) JIT expenses, including profiling and compilation of individual MHs, increase along with the number of MHs. This paper proposes dynamic graph fusion to compile an MHG into another equivalent but simpler MHG (e.g., fewer MHs and edges), as well as related optimization opportunities (e.g., selection policy and inline caching). Graph fusion dynamically fuses bytecodes of internal MHs on hot paths, and then substitutes these internal MHs with the instance of the newly generated bytecodes at program runtime. The implementation consists of a template system and GraphJIT. The former emits source bytecodes for individual MHs, while the latter is a JIT compiler that fuses source bytecodes from templates on the bytecode level (i.e., both source code and target code are bytecodes). With the JRuby Micro-Indy benchmark from Computer Language Benchmark Game and JavaScript Octane benchmark on Nashorn, our results show that (a) the technique can reduce execution time of Micro-Indy and Octane benchmarks by 6.28% and 7.73% on average; b) it can speed up a typical MHG’s execution by 31.53% using Ahead-Of-Time (AOT) compilation; and (c) the technique reduces the number of MH JIT compilations by 52.1%.","PeriodicalId":384671,"journal":{"name":"Proceedings of the 9th ACM SIGPLAN International Workshop on Virtual Machines and Intermediate Languages","volume":"1 1","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"2017-10-24","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"4","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"Proceedings of the 9th ACM SIGPLAN International Workshop on Virtual Machines and Intermediate Languages","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.1145/3141871.3141874","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 4

Abstract

A Method Handle (MH) in JSR 292 (Supporting Dynamically Typed Languages on the JVM) is a typed, directly executable reference to an underlying method, constructor, or field, with optional method type transformations. Multiple connected MHs make up a Method Handle Graph (MHG), which transfers an invocation at a dynamic call site to real method implementations at runtime. Despite benefits that MHGs have for dynamic JVM language implementations, MHGs challenge existing JVM optimization because a) larger MHGs at call sites incur higher graph traversal costs at runtime; and b) JIT expenses, including profiling and compilation of individual MHs, increase along with the number of MHs. This paper proposes dynamic graph fusion to compile an MHG into another equivalent but simpler MHG (e.g., fewer MHs and edges), as well as related optimization opportunities (e.g., selection policy and inline caching). Graph fusion dynamically fuses bytecodes of internal MHs on hot paths, and then substitutes these internal MHs with the instance of the newly generated bytecodes at program runtime. The implementation consists of a template system and GraphJIT. The former emits source bytecodes for individual MHs, while the latter is a JIT compiler that fuses source bytecodes from templates on the bytecode level (i.e., both source code and target code are bytecodes). With the JRuby Micro-Indy benchmark from Computer Language Benchmark Game and JavaScript Octane benchmark on Nashorn, our results show that (a) the technique can reduce execution time of Micro-Indy and Octane benchmarks by 6.28% and 7.73% on average; b) it can speed up a typical MHG’s execution by 31.53% using Ahead-Of-Time (AOT) compilation; and (c) the technique reduces the number of MH JIT compilations by 52.1%.
融合方法处理图形,实现高效的动态JVM语言实现
JSR 292(在JVM上支持动态类型语言)中的方法句柄(MH)是对底层方法、构造函数或字段的类型化、直接可执行的引用,具有可选的方法类型转换。多个连接的mh组成了一个方法句柄图(MHG),它将动态调用站点的调用传输到运行时的实际方法实现。尽管mhg对动态JVM语言实现有好处,但mhg对现有的JVM优化提出了挑战,因为a)在调用站点上较大的mhg会在运行时产生更高的图遍历成本;b) JIT费用,包括单个mhh的分析和编译,随着mhh数量的增加而增加。本文提出了动态图融合,将一个MHG编译成另一个等价但更简单的MHG(例如,更少的MHG和边),以及相关的优化机会(例如,选择策略和内联缓存)。图融合在热路径上动态融合内部mhh的字节码,然后在程序运行时用新生成的字节码实例替换这些内部mhh。该实现由模板系统和GraphJIT组成。前者为单个mh发出源字节码,而后者是一个JIT编译器,它在字节码级别上融合来自模板的源字节码(即源代码和目标代码都是字节码)。使用来自Computer Language benchmark Game的JRuby Micro-Indy基准测试和JavaScript在Nashorn上的辛烷基准测试,我们的结果表明:(a)该技术可以将Micro-Indy和辛烷基准测试的执行时间平均减少6.28%和7.73%;b)使用提前(AOT)编译可以将典型MHG的执行速度提高31.53%;(c)该技术将MH JIT编译次数减少了52.1%。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
求助全文
约1分钟内获得全文 求助全文
来源期刊
自引率
0.00%
发文量
0
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
确定
请完成安全验证×
copy
已复制链接
快去分享给好友吧!
我知道了
右上角分享
点击右上角分享
0
联系我们:info@booksci.cn Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。 Copyright © 2023 布克学术 All rights reserved.
京ICP备2023020795号-1
ghs 京公网安备 11010802042870号
Book学术文献互助
Book学术文献互助群
群 号:604180095
Book学术官方微信