Abstract

Values need to be represented differently when interacting with certain language features. For example, an integer has to take an object-based representation when interacting with erased generics, although, for performance reasons, the stack-based value representation is better. To abstract over these implementation details, some programming languages choose to expose a unified high-level concept (the integer) and let the compiler choose its exact representation and insert coercions where necessary.
This pattern appears in multiple language features such as value classes, specialization and multi-stage programming: they all expose a unified concept which they later refine into multiple representations. Yet, the underlying compiler implementations typically entangle the core mechanism with assumptions about the alternative representations and their interaction with other language features.
In this paper we present the Late Data Layout mechanism, a simple but versatile type-driven generalization that subsumes and improves the state-of-the-art representation transformations. In doing so, we make two key observations: (1) annotated types conveniently capture the semantics of using multiple representations and (2) local type inference can be used to consistently and optimally introduce coercions.
We validated our approach by implementing three language features as Scala compiler extensions: value classes, specialization (using the miniboxing representation) and a simplified multi-stage programming mechanism.
Supplemental Material
Available for Download
The artifact consists of a VMWare virtual machine that includes the source code, the binaries and the instructions to test the artifacts of the "Late Data Layout: Unifying Data Representation Transformations" paper (OOPSLA '14). You can download the free VMWare Player to play the VM (https://my.vmware.com/web/vmware/free#desktop_end_user_computing/vmware_player/6_0). The archive containing the VM is 2.5GB and the extracted VM is 6GB. It requires at least 6GB RAM to work. If you have any questions or feedback, please don't hesitate to contact me at [email protected]. I'll be very glad to answer any questions.
- Count lines of code. URL http://cloc.sourceforge.net/.Google Scholar
- Value Types in the Common Type System, Microsoft Developer Network. URL http://msdn.microsoft.com/en-us/library/34yytbws.aspx.Google Scholar
- Haskell 98 Language and Libraries: Section 4.2.3. URL http://www.haskell.org/onlinereport/decls.html#sect4.2.3.Google Scholar
- JSR 308: Annotations on Java Types. URL https://jcp.org/en/jsr/detail?id=308.Google Scholar
- The Miniboxing plugin website. URL http://scala-miniboxing.org.Google Scholar
- Rosetta Code Website. URL http://rosettacode.org.Google Scholar
- Scala SIP-15: Value Classes. URL http://docs.scala-lang.org/sips/completed/value-classes.html.Google Scholar
- SIP-5 - Internals of Scala Annotations. URL http://docs.scala-lang.org/sips/completed/internals-of-scala-annotations.html.Google Scholar
- ECMA International, Standard ECMA-335: Common Language Infrastructure, June 2006.Google Scholar
- S. Ackermann, V. Jovanovic, T. Rompf, and M. Odersky. Jet: An embedded DSL for high performance big data processing. In Big Data, 2012.Google Scholar
- J. A. Bank, A. C. Myers, and B. Liskov. Parameterized Types for Java. In PoPL. ACM, 1997. Google Scholar
Digital Library
- M. C. Bolingbroke and S. L. Peyton Jones. Types Are Calling Conventions. In Haskell. ACM, 2009. Google Scholar
Digital Library
- C. F. Bolz, A. Cuni,M. Fijalkowski, and A. Rigo. Tracing the Meta-level: PyPy's Tracing JIT Compiler. In ICOOLPS. ACM, 2009. Google Scholar
Digital Library
- C. F. Bolz, L. Diekmann, and L. Tratt. Storage Strategies for Collections in Dynamically Typed Languages. In OOPSLA. ACM, 2013. Google Scholar
Digital Library
- G. Bracha, M. Odersky, D. Stoutamire, and P. Wadler. Making the future safe for the past: Adding Genericity to the Java Programming Language. In OOPSLA. ACM, 1998. Google Scholar
Digital Library
- K. J. Brown, A. K. Sujeeth, H. J. Lee, T. Rompf, H. Chafi, M. Odersky, and K. Olukotun. A heterogeneous parallel framework for domain-specific languages. In PACT. IEEE Computer Society, 2011. Google Scholar
Digital Library
- S. Brunthaler. Efficient Interpretation Using Quickening. In DLS. ACM, 2010. Google Scholar
Digital Library
- E. Burmako. Scala Macros: Let Our Powers Combine!: On How Rich Syntax and Static Types Work with Metaprogramming. In SCALA. ACM, 2013. Google Scholar
Digital Library
- R. Cartwright and G. L. Steele, Jr. Compatible Genericity with Run-time Types for the Java Programming Language. In OOPSLA. ACM, 1998. Google Scholar
Digital Library
- A. Deutsch. On Determining Lifetime and Aliasing of Dynamically Allocated Data in Higher-order Functional Specifications. In POPL. ACM, 1990. . Google Scholar
Digital Library
- I. Dragos. Compiling Scala for Performance. PhD thesis, École Polytechnique Fédérale de Lausanne, 2010.Google Scholar
- I. Dragos and M. Odersky. Compiling Generics Through User-Directed Type Specialization. In ICOOOLPS, Genova, Italy, 2009. Google Scholar
Digital Library
- C. Flanagan, A. Sabry, B. F. Duba, and M. Felleisen. The Essence of Compiling with Continuations. In PLDI. ACM, 1993. Google Scholar
Digital Library
- A. Gal, B. Eich, M. Shaver, D. Anderson, D. Mandelin, M. R. Haghighat, B. Kaplan, G. Hoare, B. Zbarsky, J. Orendorff, J. Ruderman, E. W. Smith, R. Reitmaier, M. Bebenita, M. Chang, and M. Franz. Trace-based Just-in-time Type Specialization for Dynamic Languages. In PLDI. ACM, 2009. Google Scholar
Digital Library
- S. E. Ganz, A. Sabry, and W. Taha. Macros As Multi-stage Computations: Typesafe, Generative, Binding Macros in MacroML. In ICFP. ACM, 2001. Google Scholar
Digital Library
- A. Genêt, V. Ureche, and M. Odersky. Improving the Performance of Scala Collections with Miniboxing (EPFL-REPORT-200245). Technical report, EPFL, 2014. URL http://scala-miniboxing.org/.Google Scholar
- P. Gerakios, A. Biboudis, and Y. Smaragdakis. Reified Type Parameters Using Java Annotations. In GPCE. ACM, 2013. Google Scholar
Digital Library
- B. Goetz. The State of Speclaization, 2014. URL http://web.archive.org/web/20140718191952/http://cr.openjdk.java.net/~briangoetz/valhalla/specialization.html.Google Scholar
- J. Gosling. The Evolution of Numerical Computing in Java - preliminary discussion on value classes. URL http://web.archive.org/web/19990202050412/http://java.sun.com/people/jag/FP.html#classes.Google Scholar
- R. Harper and G. Morrisett. Compiling Polymorphism Using Intensional Type Analysis. In PoPL. ACM, 1995. Google Scholar
Digital Library
- F. Henglein and J. Jørgensen. Formally Optimal Boxing. In PoPL. ACM, 1994. Google Scholar
Digital Library
- S. L. P. Jones and J. Launchbury. Unboxed Values as First Class Citizens in a Non-Strict Functional Language. In Functional Programming Languages and Computer Architecture. Springer, 1991. Google Scholar
Digital Library
- S. L. P. Jones, R. Leshchinskiy, G. Keller, and M. M. Chakravarty. Harnessing the Multicores: Nested Data Parallelism in Haskell. In FSTTCS, volume 2, pages 383--414, 2008.Google Scholar
- V. Jovanovic, A. Shaikhha, S. Stucki, V. Nikolaev, C. Koch, and M. Odersky. Yin-Yang: Concealing the Deep Embedding of DSLs. 2014.Google Scholar
- A. Kennedy and D. Syme. Design and Implementation of Generics for the .NET Common Language Runtime. In PLDI, 2001. Google Scholar
Digital Library
- G. A. Kildall. A unified approach to global program optimization. In PoPL. ACM, 1973. Google Scholar
Digital Library
- G. Kossakowski, N. Amin, T. Rompf, and M. Odersky. JavaScript As an Embedded DSL. In ECOOP. Springer, 2012. Google Scholar
Digital Library
- T. Kotzmann, C.Wimmer, H. Mössenböck, T. Rodriguez, K. Russell, and D. Cox. Design of the Java HotSpot Client Compiler for Java 6. ACM Transactions on Architecture and Code Optimization (TACO), 5(1), 2008. Google Scholar
Digital Library
- P. A. Kulkarni. JIT Compilation Policy for Modern Machines. In OOPSLA. ACM, 2011. Google Scholar
Digital Library
- J. Launchbury and R. Paterson. Parametricity and unboxing with unpointed types. In ESOP. Springer, 1996. Google Scholar
Digital Library
- S. Leather, J. Jeuring, A. Löh, and B. Schuur. Type-changing Rewriting and Semantics-preserving Transformation. In PEPM '14. ACM, 2014. Google Scholar
Digital Library
- X. Leroy. Unboxed Objects and Polymorphic Typing. In PoPL. ACM, 1992. Google Scholar
Digital Library
- T. Lindholm and F. Yellin. Java Virtual Machine Specification. Addison-Wesley Longman Publishing Co., Inc., 1999. Google Scholar
Digital Library
- Y. Minamide and J. Garriguc. On the Runtime Complexity of Type-Directed Unboxing. In ICFP, 1998. Google Scholar
Digital Library
- A. Moors, T. Rompf, P. Haller, and M. Odersky. Scala-Virtualized. In PEPM. ACM, 2012. Google Scholar
Digital Library
- R. Morrison, A. Dearle, R. C. H. Connor, and A. L. Brown. An Ad Hoc Approach to the Implementation of Polymorphism. ACM TOPLAS, 1991. Google Scholar
Digital Library
- M. Odersky, E. Runne, and P.Wadler. Two Ways to Bake Your Pizza-Translating Parameterised Types into Java. Springer, 2000.Google Scholar
Cross Ref
- M. Odersky, M. Zenger, and C. Zenger. Colored Local Type Inference. In PoPL. ACM, 2001. Google Scholar
Digital Library
- E. Osheim. Generic Numeric Programming Through Specialized Type Classes. ScalaDays, 2012.Google Scholar
- M. Paleczny, C. Vick, and C. Click. The Java HotSpot Server Compiler. In Proceedings of the 2001 Symposium on Java Virtual Machine Research and Technology Symposium-Volume 1. USENIX Association, 2001. Google Scholar
Digital Library
- M. M. Papi, M. Ali, T. L. Correa, Jr., J. H. Perkins, and M. D. Ernst. Practical Pluggable Types for Java. In ISSTA. ACM, 2008. Google Scholar
Digital Library
- B. C. Pierce and D. N. Turner. Local Type Inference. ACM TOPLAS, 2000. Google Scholar
Digital Library
- A. Prokopec. ScalaMeter. URL http://axel22.github.com/scalameter/.Google Scholar
- T. Rompf. Lightweight Modular Staging and Embedded Compilers: Abstraction Without Regret for High-Level High-Performance Programming. PhD thesis, École Polytechnique Fédérale de Lausanne, 2012.Google Scholar
- T. Rompf andM. Odersky. LightweightModular Staging: A Pragmatic Approach to Runtime Code Generation and Compiled DSLs. In GPCE, 2010. Google Scholar
Digital Library
- T. Rompf, I. Maier, and M. Odersky. Implementing First-class Polymorphic Delimited Continuations by a Type-directed Selective CPS-transform. In ICFP. ACM, 2009. Google Scholar
Digital Library
- T. Rompf, A. K. Sujeeth, H. Lee, K. J. Brown, H. Chafi, M. Odersky, and K. Olukotun. Building-Blocks for Performance Oriented DSLs. In DSL, 2011.Google Scholar
Cross Ref
- J. Rose. Value Types and Struct Tearing, URL https://web.archive.org/web/20140320141639/https://blogs.oracle.com/jrose/entry/value_types_and_struct_tearing.Google Scholar
- J. Rose. Value Types in the VM, URL http://web.archive.org/web/20131229122932/https://blogs.oracle.com/jrose/entry/value_types_in_the_vm.Google Scholar
- L. Rytz. A Practical Effect System for Scala. PhD thesis, École Polytechnique Fédérale de Lausanne, 2014.Google Scholar
- L. Rytz, M. Odersky, and P. Haller. Lightweight Polymorphic Effects. In ECOOP. Springer, 2012. Google Scholar
Digital Library
- M. Schinz. Compiling Scala for the Java Virtual Machine. PhD thesis, École Polytechnique Fédérale de Lausanne, 2005.Google Scholar
- Z. Shao. Flexible Representation Analysis. In ICFP. ACM, 1997. Google Scholar
Digital Library
- Z. Shao and A. W. Appel. A Type-Based Compiler for Standard ML. In PLDI, 1995. Google Scholar
Digital Library
- L. Stadler, T. Würthinger, and H. Mössenböck. Partial Escape Analysis and Scalar Replacement for Java. In CGO. ACM, 2014. Google Scholar
Digital Library
- B. Stroustrup. The C++ Programming Language, Third Edition. Addison-Wesley Longman Publishing Co., Inc., Boston, MA, 3rd edition, 1997. Google Scholar
Digital Library
- N. Stucki and V. Ureche. Bridging islands of specialized code using macros and reified types. In SCALA. ACM, 2013. Google Scholar
Digital Library
- S. Stucki, N. Amin, M. Jonnalagedda, and T. Rompf. What Are the Odds?: Probabilistic Programming in Scala. In SCALA. ACM, 2013. Google Scholar
Digital Library
- N. Swamy, M. Hicks, and G. M. Bierman. A Theory of Typed Coercions and Its Applications. In ICFP '09. ACM, 2009. Google Scholar
Digital Library
- W. Taha. A Gentle Introduction toMulti-stage Programming. In Domain-Specific Program Generation, pages 30--50. Springer, 2004.Google Scholar
Cross Ref
- D. Tarditi, G. Morrisett, P. Cheng, C. Stone, R. Harper, and P. Lee. TIL: A Type-Directed Optimizing Compiler for ML. In PLDI. ACM, 1996. Google Scholar
Digital Library
- P. J. Thiemann. Unboxed Values and Polymorphic Typing Revisited. In Functional Programming Languages and Computer Architecture. ACM, 1995. Google Scholar
Digital Library
- V. Ureche. Additional Material for "Unifying Data Representation Transformations (EPFL-REPORT-200246)". Technical report, EPFL, 2014.Google Scholar
- V. Ureche, T. Rompf, A. Sujeeth, H. Chafi, and M. Odersky. StagedSAC: A Case Study in Performance-oriented DSL Development. In PEPM. ACM, 2012. Google Scholar
Digital Library
- V. Ureche, C. Talau, and M. Odersky. Miniboxing: Improving the Speed to Code Size Tradeoff in Parametric Polymorphism Translations. In OOPSLA, 2013. Google Scholar
Digital Library
- M. Viroli and A. Natali. Parametric Polymorphism in Java: An Approach to Translation Based on Reflective Features. In OOPSLA. ACM, 2000. Google Scholar
Digital Library
- S. Wholey and S. E. Fahlman. The Design of an Instruction Set for Common Lisp. In LFP, 1984. Google Scholar
Digital Library
- T.Würthinger, A.Wöß, L. Stadler, G. Duboscq, D. Simon, and C.Wimmer. Self-Optimizing AST interpreters. In DLS. ACM, 2012. Google Scholar
Digital Library
- T. Würthinger, C. Wimmer, A. Wöß, L. Stadler, G. Duboscq, C. Humer, G. Richards, D. Simon, andM.Wolczko. One VMto Rule Them All. In Onward! ACM, 2013. Google Scholar
Digital Library
- D. Yu, A. Kennedy, and D. Syme. Formalization of Generics for the .NET Common Language Runtime. In POPL, POPL '04. ACM. Google Scholar
Digital Library
Index Terms
Late data layout: unifying data representation transformations
Recommendations
Late data layout: unifying data representation transformations
OOPSLA '14: Proceedings of the 2014 ACM International Conference on Object Oriented Programming Systems Languages & ApplicationsValues need to be represented differently when interacting with certain language features. For example, an integer has to take an object-based representation when interacting with erased generics, although, for performance reasons, the stack-based value ...
Polymorphism and page tables: systems programming from a functional programmer's perspective
ICFP '08With features that include lightweight syntax, expressive type systems, and deep semantic foundations, functional languages are now being used to develop an increasingly broad range of complex, real-world applications. In the area of systems software, ...
Explicitly heterogeneous metaprogramming with MetaHaskell
ICFP '12: Proceedings of the 17th ACM SIGPLAN international conference on Functional programmingLanguages with support for metaprogramming, like MetaOCaml, offer a principled approach to code generation by guaranteeing that well-typed metaprograms produce well-typed programs. However, many problem domains where metaprogramming can fruitfully be ...







Comments