TASTYTRUFFLE: Just-in-Time Specialization of Parametric Polymorphism

被引:0
作者
D'Souza, Matt [1 ]
You, James [1 ]
Lhotak, Ondrej [1 ]
Prokopec, Aleksandar [2 ]
机构
[1] Univ Waterloo, Waterloo, ON N2L 3G1, Canada
[2] Oracle Labs, Zurich, Switzerland
来源
PROCEEDINGS OF THE ACM ON PROGRAMMING LANGUAGES-PACMPL | 2023年 / 7卷 / OOPSLA期
基金
加拿大自然科学与工程研究理事会;
关键词
parametric polymorphism; specialization; reified types; just-in-time compiler; Truffle; Scala; LANGUAGE; IMPLEMENTATION;
D O I
10.1145/3622853
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
Parametric polymorphism allows programmers to express algorithms independently of the types of values that they operate on. The approach used to implement parametric polymorphism can have important performance implications. One popular approach, erasure, uses a uniform representation for generic data, which entails primitive boxing and other indirections that harm performance. Erasure destroys type information that could be used by language implementations to optimize generic code. We present TASTYTRUFFLE, an implementation for a subset of the Scala programming language. Instead of JVM bytecode, TASTYTRUFFLE interprets Scala's TASTy intermediate representation, a typed representation wherein generic types are not erased. TASTy's precise type information empowers TASTYTRUFFLE to implement generic code more effectively. In particular, it allows TASTYTRUFFLE to reify types as run-time objects that can be passed around. Using reified types, TASTYTRUFFLE supports heterogeneous box-free representations for generic values. TASTYTRUFFLE also uses reified types to specialize generic code, producing monomorphic copies of generic code that can be easily and reliably optimized by its just-in-time (JIT) compiler. Empirically, TASTYTRUFFLE is competitive with standard JVM implementations on a small set of benchmark programs; when generic code is used with multiple types, TASTYTRUFFLE consistently outperforms the JVM. The precise type information in TASTy enables TASTYTRUFFLE to find additional optimization opportunities that could not be uncovered with erased JVM bytecode.
引用
收藏
页码:1561 / 1588
页数:28
相关论文
共 30 条
  • [1] Ansaloni Danilo, 2022, Static Object Model
  • [2] Making the future safe for the past:: Adding genericity to the Java']Java™ programming language
    Bracha, G
    Odersky, M
    Stoutamire, D
    Wadler, P
    [J]. ACM SIGPLAN NOTICES, 1998, 33 (10) : 183 - 200
  • [3] Compatible genericity with run-time types for the Java']Java™ programming language
    Cartwright, R
    Steele, GL
    [J]. ACM SIGPLAN NOTICES, 1998, 33 (10) : 201 - 215
  • [4] CLICK C, 1995, SIGPLAN NOTICES, V30, P35, DOI 10.1145/202530.202534
  • [5] Doeraene Sebastien Jean R, 2018, Technical Report, DOI [10.5075/epflthesis-8733, DOI 10.5075/EPFLTHESIS-8733]
  • [6] Dragos Iulian., 2009, P 4 WORKSH IMPL COMP, DOI [DOI 10.1145/1565824.1565830, 10.1145/1565824.1565830]
  • [7] DSouza Matt, 2023, TASTyTruffle: Justintime Specialization of Parametric Polymorphism, DOI [10.5281/zenodo.8332577, DOI 10.5281/ZENODO.8332577]
  • [8] Duboscq Gilles, 2013, P 7 ACM WORKSH VIRT, P1, DOI 10.1145/2542142.2542143
  • [9] Futamura Y., 1999, Higher-Order and Symbolic Computation, V12, P381, DOI 10.1023/A:1010095604496
  • [10] Goetz Brian, 2014, State of the Specialization