Generic go to go: dictionary-passing, monomorphisation, and hybrid

Author:

Ellis Stephen1ORCID,Zhu Shuofei2ORCID,Yoshida Nobuko1ORCID,Song Linhai2ORCID

Affiliation:

1. University of Oxford, UK

2. Pennsylvania State University, USA

Abstract

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 early 2022 includes bounded parametric polymorphism via generic types. Go 1.18 implements generic types using a 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 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 translation approaches work in practice, we benchmark five translators, Go 1.18, two existing monomorphisation translators, our dictionary-passing translator, and an 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.

Funder

EPSRC

NC-SS/EPSRC

Mozilla Foundation

Ethereum

Publisher

Association for Computing Machinery (ACM)

Subject

Safety, Risk, Reliability and Quality,Software

Reference49 articles.

1. Adding type parameterization to the Java language

2. Eric Allen and Robert Cartwright . 2002 . The Case for Run-Time Types in Generic Java . In Proceedings of the Inaugural Conference on the Principles and Practice of Programming, 2002 and Proceedings of the Second Workshop on Intermediate Representation Engineering for Virtual Machines , 2002 (PPPJ ’02/IRE ’02). National University of Ireland, Maynooth, County Kildare, IRL. 19–24. isbn:0 901519 87 1 Eric Allen and Robert Cartwright. 2002. The Case for Run-Time Types in Generic Java. In Proceedings of the Inaugural Conference on the Principles and Practice of Programming, 2002 and Proceedings of the Second Workshop on Intermediate Representation Engineering for Virtual Machines, 2002 (PPPJ ’02/IRE ’02). National University of Ireland, Maynooth, County Kildare, IRL. 19–24. isbn:0 901519 87 1

3. Christal Baier and Joost P . Katoen . 2008 . Principles of Model Checking. MIT Press , United States. isbn:978-0-262-02649-9 Christal Baier and Joost P. Katoen. 2008. Principles of Model Checking. MIT Press, United States. isbn:978-0-262-02649-9

4. Coherence of type class resolution

5. Characterizing finite Kripke structures in propositional temporal logic

Cited by 2 articles. 订阅此论文施引文献 订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献

同舟云学术

1.学者识别学者识别

2.学术分析学术分析

3.人才评估人才评估

"同舟云学术"是以全球学者为主线,采集、加工和组织学术论文而形成的新型学术文献查询和分析系统,可以对全球学者进行文献检索和人才价值评估。用户可以通过关注某些学科领域的顶尖人物而持续追踪该领域的学科进展和研究前沿。经过近期的数据扩容,当前同舟云学术共收录了国内外主流学术期刊6万余种,收集的期刊论文及会议论文总量共计约1.5亿篇,并以每天添加12000余篇中外论文的速度递增。我们也可以为用户提供个性化、定制化的学者数据。欢迎来电咨询!咨询电话:010-8811{复制后删除}0370

www.globalauthorid.com

TOP

Copyright © 2019-2024 北京同舟云网络信息技术有限公司
京公网安备11010802033243号  京ICP备18003416号-3