论文标题

通用GO GO:字典,单形态和混合动力

Generic Go to Go: Dictionary-Passing, Monomorphisation, and Hybrid

论文作者

Ellis, Stephen, Zhu, Shuofei, Yoshida, Nobuko, Song, Linhai

论文摘要

GO是一种流行的静态工业编程语言。为了帮助类型的安全重复使用代码,最近发布的GO版本(GO 1.18)于2022年3月15日发布,包括通过通用类型的有限参数多态性。 GO 1.18使用单形化和基于呼叫的字典词的组合(称为Hybrid)实现通用类型。这种混合方法可以看作是一种优化的单形成形式,该形式静态地基于可能的实例化生成专业的方法和类型。单层词典补充了在单形化过程中丢失的信息,并且根据程序的呼叫图进行结构。不幸的是,混合方法仍然遭受代码膨胀,汇编速度差和有限的代码覆盖范围。 在本文中,我们提出并形式化了新的非专业呼叫位点词典词典翻译。我们基于呼叫的基于呼叫的翻译为每种类型的参数创建单个词典,并在实例化的情况下进行了字典结构,从而克服了混合动力的局限性。我们使用新颖的一般性仿真来证明它是正确的。为了更好地理解不同的仿制药翻译方法在实践中的工作方式,我们基准了五个翻译器,即1.18,两个现有的单形化翻译器,我们的字典 - 通过词典翻译器和擦除翻译器。我们的发现揭示了有关GO 1.18改进的几个建议 - 特别是如何克服通用GO的表现力限制,改善编译时间并编译了GO 1.18的代码尺寸性能。

Go is a popular statically-typed industrial programming language. To aid the type safe reuse of code, the recent Go release (Go 1.18) published on 15th March 2022 includes bounded parametric polymorphism via generic types. Go 1.18 implements generic types using combination of monomorphisation and call-graph based dictionary-passing called hybrid. This hybrid approach can be viewed as an optimised form of monomorphisation that statically generates specialised methods and types based on possible instantiations. A monolithic dictionary supplements information lost during monomorphisation, and it is structured according to the program's call graph. Unfortunately, the hybrid approach still suffers from code bloat, poor compilation speed, and limited code coverage. In this paper we propose and formalise a new non-specialising call-site based dictionary-passing translation. Our call-site based translation creates individual dictionaries for each type parameter, with dictionary construction occurring in place of instantiation, overcoming the limitations of hybrid. We prove it correct using a novel and general bisimulation up to technique. To better understand how different generics translations approaches work in practice, we benchmark five translators, Go 1.18, two existing monomorphisation translators, our dictionary-passing translator, and erasure translator. Our findings reveal several suggestions for improvements for Go 1.18 -- specifically how to overcome the expressiveness limitations of generic Go, and improve compile time and compiled code size performance of Go 1.18.

扫码加入交流群

加入微信交流群

微信交流群二维码

扫码加入学术交流群,获取更多资源