Reducing the Cost of Object Boxing

Language implementations that use a uniform pointer representation for generic datatypes typically apply boxing operations to convert non-uniform objects into the required form. The cost of this boxing process impacts upon the performance of programs that make heavy use of genericity with non-uniform data such as integers and other primitive value types. We show that the overhead of boxing objects into heap storage can be significantly reduced by taking a lazy approach: allowing pointers to stack-allocated objects that are only copied to the heap when necessary. Delaying the boxing of objects avoids unnecessary heap allocation, and results in speedups of around 25% for a range of test programs.

[1]  Bertrand Meyer,et al.  Eiffel: The Language , 1991 .

[2]  Martin Odersky,et al.  Pizza into Java: translating theory into practice , 1997, POPL '97.

[3]  Simon L. Peyton Jones,et al.  C-: A Portable Assembly Language , 1997, Implementation of Functional Languages.

[4]  Andrew D. Gordon,et al.  Typing a multi-language intermediate code , 2001, POPL '01.

[5]  Robert Cartwright,et al.  Compatible genericity with run-time types for the Java programming language , 1998, OOPSLA '98.

[6]  Xavier Leroy,et al.  Unboxed objects and polymorphic typing , 1992, POPL '92.

[7]  Olivier Zendra,et al.  Type Inference for Late Binding: The SmallEiffel Compiler , 1997, JMLC.

[8]  Jong-Deok Choi,et al.  Escape analysis for Java , 1999, OOPSLA '99.

[9]  Martin Odersky,et al.  Making the future safe for the past: adding genericity to the Java programming language , 1998, OOPSLA '98.

[10]  David Gay,et al.  Fast Escape Analysis and Stack Allocation for Object-Based Programs , 2000, CC.

[11]  Werner Kluge,et al.  Implementation of Functional Languages , 1996, Lecture Notes in Computer Science.

[12]  Bjarne Stroustrup,et al.  The Design and Evolution of C , 1994 .

[13]  Andrew Kennedy,et al.  Design and implementation of generics for the .NET Common language runtime , 2001, PLDI '01.

[14]  Andrew W. Appel,et al.  A type-based compiler for standard ML , 1995, PLDI '95.

[15]  Robert Harper,et al.  Compiling polymorphism using intensional type analysis , 1995, POPL '95.