skip to main content
research-article

Late data layout: unifying data representation transformations

Published:15 October 2014Publication History
Skip Abstract Section

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.

Skip Supplemental Material Section

Supplemental Material

References

  1. Count lines of code. URL http://cloc.sourceforge.net/.Google ScholarGoogle Scholar
  2. Value Types in the Common Type System, Microsoft Developer Network. URL http://msdn.microsoft.com/en-us/library/34yytbws.aspx.Google ScholarGoogle Scholar
  3. Haskell 98 Language and Libraries: Section 4.2.3. URL http://www.haskell.org/onlinereport/decls.html#sect4.2.3.Google ScholarGoogle Scholar
  4. JSR 308: Annotations on Java Types. URL https://jcp.org/en/jsr/detail?id=308.Google ScholarGoogle Scholar
  5. The Miniboxing plugin website. URL http://scala-miniboxing.org.Google ScholarGoogle Scholar
  6. Rosetta Code Website. URL http://rosettacode.org.Google ScholarGoogle Scholar
  7. Scala SIP-15: Value Classes. URL http://docs.scala-lang.org/sips/completed/value-classes.html.Google ScholarGoogle Scholar
  8. SIP-5 - Internals of Scala Annotations. URL http://docs.scala-lang.org/sips/completed/internals-of-scala-annotations.html.Google ScholarGoogle Scholar
  9. ECMA International, Standard ECMA-335: Common Language Infrastructure, June 2006.Google ScholarGoogle Scholar
  10. S. Ackermann, V. Jovanovic, T. Rompf, and M. Odersky. Jet: An embedded DSL for high performance big data processing. In Big Data, 2012.Google ScholarGoogle Scholar
  11. J. A. Bank, A. C. Myers, and B. Liskov. Parameterized Types for Java. In PoPL. ACM, 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. M. C. Bolingbroke and S. L. Peyton Jones. Types Are Calling Conventions. In Haskell. ACM, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. C. F. Bolz, A. Cuni,M. Fijalkowski, and A. Rigo. Tracing the Meta-level: PyPy's Tracing JIT Compiler. In ICOOLPS. ACM, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. C. F. Bolz, L. Diekmann, and L. Tratt. Storage Strategies for Collections in Dynamically Typed Languages. In OOPSLA. ACM, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  16. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  17. S. Brunthaler. Efficient Interpretation Using Quickening. In DLS. ACM, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. E. Burmako. Scala Macros: Let Our Powers Combine!: On How Rich Syntax and Static Types Work with Metaprogramming. In SCALA. ACM, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. R. Cartwright and G. L. Steele, Jr. Compatible Genericity with Run-time Types for the Java Programming Language. In OOPSLA. ACM, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. A. Deutsch. On Determining Lifetime and Aliasing of Dynamically Allocated Data in Higher-order Functional Specifications. In POPL. ACM, 1990. . Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. I. Dragos. Compiling Scala for Performance. PhD thesis, École Polytechnique Fédérale de Lausanne, 2010.Google ScholarGoogle Scholar
  22. I. Dragos and M. Odersky. Compiling Generics Through User-Directed Type Specialization. In ICOOOLPS, Genova, Italy, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. C. Flanagan, A. Sabry, B. F. Duba, and M. Felleisen. The Essence of Compiling with Continuations. In PLDI. ACM, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  25. S. E. Ganz, A. Sabry, and W. Taha. Macros As Multi-stage Computations: Typesafe, Generative, Binding Macros in MacroML. In ICFP. ACM, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. 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 ScholarGoogle Scholar
  27. P. Gerakios, A. Biboudis, and Y. Smaragdakis. Reified Type Parameters Using Java Annotations. In GPCE. ACM, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. B. Goetz. The State of Speclaization, 2014. URL http://web.archive.org/web/20140718191952/http://cr.openjdk.java.net/~briangoetz/valhalla/specialization.html.Google ScholarGoogle Scholar
  29. 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 ScholarGoogle Scholar
  30. R. Harper and G. Morrisett. Compiling Polymorphism Using Intensional Type Analysis. In PoPL. ACM, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. F. Henglein and J. Jørgensen. Formally Optimal Boxing. In PoPL. ACM, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  33. 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 ScholarGoogle Scholar
  34. V. Jovanovic, A. Shaikhha, S. Stucki, V. Nikolaev, C. Koch, and M. Odersky. Yin-Yang: Concealing the Deep Embedding of DSLs. 2014.Google ScholarGoogle Scholar
  35. A. Kennedy and D. Syme. Design and Implementation of Generics for the .NET Common Language Runtime. In PLDI, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. G. A. Kildall. A unified approach to global program optimization. In PoPL. ACM, 1973. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. G. Kossakowski, N. Amin, T. Rompf, and M. Odersky. JavaScript As an Embedded DSL. In ECOOP. Springer, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  39. P. A. Kulkarni. JIT Compilation Policy for Modern Machines. In OOPSLA. ACM, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. J. Launchbury and R. Paterson. Parametricity and unboxing with unpointed types. In ESOP. Springer, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. S. Leather, J. Jeuring, A. Löh, and B. Schuur. Type-changing Rewriting and Semantics-preserving Transformation. In PEPM '14. ACM, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. X. Leroy. Unboxed Objects and Polymorphic Typing. In PoPL. ACM, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  43. T. Lindholm and F. Yellin. Java Virtual Machine Specification. Addison-Wesley Longman Publishing Co., Inc., 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  44. Y. Minamide and J. Garriguc. On the Runtime Complexity of Type-Directed Unboxing. In ICFP, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  45. A. Moors, T. Rompf, P. Haller, and M. Odersky. Scala-Virtualized. In PEPM. ACM, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  46. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  47. M. Odersky, E. Runne, and P.Wadler. Two Ways to Bake Your Pizza-Translating Parameterised Types into Java. Springer, 2000.Google ScholarGoogle ScholarCross RefCross Ref
  48. M. Odersky, M. Zenger, and C. Zenger. Colored Local Type Inference. In PoPL. ACM, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  49. E. Osheim. Generic Numeric Programming Through Specialized Type Classes. ScalaDays, 2012.Google ScholarGoogle Scholar
  50. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  51. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  52. B. C. Pierce and D. N. Turner. Local Type Inference. ACM TOPLAS, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  53. A. Prokopec. ScalaMeter. URL http://axel22.github.com/scalameter/.Google ScholarGoogle Scholar
  54. 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 ScholarGoogle Scholar
  55. T. Rompf andM. Odersky. LightweightModular Staging: A Pragmatic Approach to Runtime Code Generation and Compiled DSLs. In GPCE, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  56. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  57. 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 ScholarGoogle ScholarCross RefCross Ref
  58. 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 ScholarGoogle Scholar
  59. 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 ScholarGoogle Scholar
  60. L. Rytz. A Practical Effect System for Scala. PhD thesis, École Polytechnique Fédérale de Lausanne, 2014.Google ScholarGoogle Scholar
  61. L. Rytz, M. Odersky, and P. Haller. Lightweight Polymorphic Effects. In ECOOP. Springer, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  62. M. Schinz. Compiling Scala for the Java Virtual Machine. PhD thesis, École Polytechnique Fédérale de Lausanne, 2005.Google ScholarGoogle Scholar
  63. Z. Shao. Flexible Representation Analysis. In ICFP. ACM, 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  64. Z. Shao and A. W. Appel. A Type-Based Compiler for Standard ML. In PLDI, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  65. L. Stadler, T. Würthinger, and H. Mössenböck. Partial Escape Analysis and Scalar Replacement for Java. In CGO. ACM, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  66. B. Stroustrup. The C++ Programming Language, Third Edition. Addison-Wesley Longman Publishing Co., Inc., Boston, MA, 3rd edition, 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  67. N. Stucki and V. Ureche. Bridging islands of specialized code using macros and reified types. In SCALA. ACM, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  68. S. Stucki, N. Amin, M. Jonnalagedda, and T. Rompf. What Are the Odds?: Probabilistic Programming in Scala. In SCALA. ACM, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  69. N. Swamy, M. Hicks, and G. M. Bierman. A Theory of Typed Coercions and Its Applications. In ICFP '09. ACM, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  70. W. Taha. A Gentle Introduction toMulti-stage Programming. In Domain-Specific Program Generation, pages 30--50. Springer, 2004.Google ScholarGoogle ScholarCross RefCross Ref
  71. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  72. P. J. Thiemann. Unboxed Values and Polymorphic Typing Revisited. In Functional Programming Languages and Computer Architecture. ACM, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  73. V. Ureche. Additional Material for "Unifying Data Representation Transformations (EPFL-REPORT-200246)". Technical report, EPFL, 2014.Google ScholarGoogle Scholar
  74. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  75. V. Ureche, C. Talau, and M. Odersky. Miniboxing: Improving the Speed to Code Size Tradeoff in Parametric Polymorphism Translations. In OOPSLA, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  76. M. Viroli and A. Natali. Parametric Polymorphism in Java: An Approach to Translation Based on Reflective Features. In OOPSLA. ACM, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  77. S. Wholey and S. E. Fahlman. The Design of an Instruction Set for Common Lisp. In LFP, 1984. Google ScholarGoogle ScholarDigital LibraryDigital Library
  78. T.Würthinger, A.Wöß, L. Stadler, G. Duboscq, D. Simon, and C.Wimmer. Self-Optimizing AST interpreters. In DLS. ACM, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  79. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  80. D. Yu, A. Kennedy, and D. Syme. Formalization of Generics for the .NET Common Language Runtime. In POPL, POPL '04. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Late data layout: unifying data representation transformations

          Recommendations

          Comments

          Login options

          Check if you have access through your login credentials or your institution to get full access on this article.

          Sign in

          Full Access

          • Published in

            cover image ACM SIGPLAN Notices
            ACM SIGPLAN Notices  Volume 49, Issue 10
            OOPSLA '14
            October 2014
            907 pages
            ISSN:0362-1340
            EISSN:1558-1160
            DOI:10.1145/2714064
            • Editor:
            • Andy Gill
            Issue’s Table of Contents
            • cover image ACM Conferences
              OOPSLA '14: Proceedings of the 2014 ACM International Conference on Object Oriented Programming Systems Languages & Applications
              October 2014
              946 pages
              ISBN:9781450325851
              DOI:10.1145/2660193

            Copyright © 2014 ACM

            Publisher

            Association for Computing Machinery

            New York, NY, United States

            Publication History

            • Published: 15 October 2014

            Check for updates

            Qualifiers

            • research-article

          PDF Format

          View or Download as a PDF file.

          PDF

          eReader

          View online with eReader.

          eReader
          About Cookies On This Site

          We use cookies to ensure that we give you the best experience on our website.

          Learn more

          Got it!