Miniboxing: improving the speed to code size tradeoff in parametric polymorphism translations

Miniboxing: improving the speed to code size tradeoff in parametric polymorphism translations
复制标题

Miniboxing:提高参数多态性翻译中代码大小权衡的速度

DOI:
--
复制
发表时间:
2013
期刊:
Conference on Object-Oriented Programming Systems, Languages, and Applications
影响因子:
--
通讯作者:
Martin Odersky
Martin Odersky
中科院分区:
--
文献类型:
--
作者:
Vlad Ureche;Cristian Talau;Martin Odersky

文献摘要

被引文献

相似文献

参数多态性支持代码重用和类型安全。然而,在向程序员公开的统一接口的基础上,其低级实现必须科普固有的非统一数据:不同大小和语义的值类型(字节,整数,浮点数)和引用类型(指向堆对象的指针)。在Java虚拟机上,参数多态性目前使用两种相互竞争的方法转换为字节码:同构和异构。同构翻译需要装箱,因此会引入间接访问延迟。异构转换分别为每个值类型复制和修改代码,从而产生更多的字节码。因此,字节码的速度和大小是相互矛盾的。本文提出了一种新的翻译,显着减少字节码的大小,而不影响执行速度。关键的见解是,较大的值类型(如整数)可以容纳较小的值类型(如字节),从而减少异构转换中所需的重复。在我们的实现中,在Scala编译器上,我们将所有原始值类型编码为长整数。产生的字节码接近单态代码的性能,与异构翻译的性能相匹配,并获得比同构翻译高达22倍的加速比,所有这些都在大小上略有增加。
Parametric polymorphism enables code reuse and type safety. Underneath the uniform interface exposed to programmers, however, its low level implementation has to cope with inherently non-uniform data: value types of different sizes and semantics (bytes, integers, floating point numbers) and reference types (pointers to heap objects). On the Java Virtual Machine, parametric polymorphism is currently translated to bytecode using two competing approaches: homogeneous and heterogeneous. Homogeneous translation requires boxing, and thus introduces indirect access delays. Heterogeneous translation duplicates and adapts code for each value type individually, producing more bytecode. Therefore bytecode speed and size are at odds with each other. This paper proposes a novel translation that significantly reduces the bytecode size without affecting the execution speed. The key insight is that larger value types (such as integers) can hold smaller ones (such as bytes) thus reducing the duplication necessary in heterogeneous translations. In our implementation, on the Scala compiler, we encode all primitive value types in long integers. The resulting bytecode approaches the performance of monomorphic code, matches the performance of the heterogeneous translation and obtains speedups of up to 22x over the homogeneous translation, all with modest increases in size.