skip to main content
article

Practical partial evaluation for high-performance dynamic language runtimes

Published:14 June 2017Publication History
Skip Abstract Section

Abstract

Most high-performance dynamic language virtual machines duplicate language semantics in the interpreter, compiler, and runtime system. This violates the principle to not repeat yourself. In contrast, we define languages solely by writing an interpreter. The interpreter performs specializations, e.g., augments the interpreted program with type information and profiling information. Compiled code is derived automatically using partial evaluation while incorporating these specializations. This makes partial evaluation practical in the context of dynamic languages: It reduces the size of the compiled code while still compiling all parts of an operation that are relevant for a particular program. When a speculation fails, execution transfers back to the interpreter, the program re-specializes in the interpreter, and later partial evaluation again transforms the new state of the interpreter to compiled code. We evaluate our approach by comparing our implementations of JavaScript, Ruby, and R with best-in-class specialized production implementations. Our general-purpose compilation system is competitive with production systems even when they have been heavily optimized for the one language they support. For our set of benchmarks, our speedup relative to the V8 JavaScript VM is 0.83x, relative to JRuby is 3.8x, and relative to GNU R is 5x.

References

  1. R. Affeldt, H. Masuhara, E. Sumii, and A. Yonezawa. Supporting objects in run-time bytecode specialization. In Proceedings of the ASIAN Symposium on Partial Evaluation and Semantics-Based Program Manipulation, pages 50–60. ACM Press, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. O. Agesen and D. Detlefs. Mixed-mode bytecode execution. Technical report, Sun Microsystems, Inc., 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. B. Alpern, S. Augart, S. M. Blackburn, M. Butrico, A. Cocchi, P. Cheng, J. Dolby, S. Fink, D. Grove, M. Hind, K. S. McKinley, M. Mergen, J. E. B. Moss, T. Ngo, and V. Sarkar. The Jikes Research Virtual Machine project: Building an opensource research community. IBM Systems Journal, 44(2):399– 417, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. M. Arnold, S. J. Fink, D. Grove, M. Hind, and P. F. Sweeney. Adaptive optimization in the Jalape˜no JVM. In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages, and Applications, pages 47– 65. ACM Press, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. G. Benson. Zero and Shark: a zero-assembly port of Open-JDK, 2009.Google ScholarGoogle Scholar
  6. C. F. Bolz and A. Rigo. How to not write virtual machines for dynamic languages. In Proceedings of the Workshop on Dynamic Languages and Applications, 2007.Google ScholarGoogle Scholar
  7. C. F. Bolz and L. Tratt. The impact of meta-tracing on VM design and implementation. Science of Computer Programming, 98(3):408–421, 2015. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. C. F. Bolz, A. Cuni, M. Fijałkowski, and A. Rigo. Tracing the meta-level: PyPy’s tracing JIT compiler. In Proceedings of the Workshop on the Implementation, Compilation, Optimization of Object-Oriented Languages and Programming Systems, pages 18–25. ACM Press, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. C. F. Bolz, M. Leuschel, and A. Rigo. Towards just-in-time partial evaluation of Prolog. In Proceedings of the International Conference on Logic-Based Program Synthesis and Transformation, pages 158–172. Springer-Verlag, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. C. F. Bolz, A. Cuni, M. Fijałkowski, M. Leuschel, S. Pedroni, and A. Rigo. Runtime feedback in a meta-tracing JIT for efficient dynamic languages. In Proceedings of the Workshop on the Implementation, Compilation, Optimization of Object-Oriented Languages and Programming Systems, pages 9:1– 9:8. ACM Press, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. M. Chevalier-Boisvert, L. Hendren, and C. Verbrugge. Optimizing MATLAB through just-in-time specialization. In Proceedings of the International Conference on Compiler Construction, pages 46–65. Springer-Verlag, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. B. Daloze, S. Marr, D. Bonetta, and H. Mössenböck. Efficient and thread-safe objects for dynamically-typed languages. In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages, and Applications, pages 642–659. ACM Press, 2016. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. G. Duboscq, L. Stadler, T. Würthinger, D. Simon, C. Wimmer, and H. Mössenböck. Graal IR: An extensible declarative intermediate representation. In Proceedings of the Asia-Pacific Programming Languages and Compilers Workshop, 2013.Google ScholarGoogle Scholar
  14. G. Duboscq, T. Würthinger, L. Stadler, C. Wimmer, D. Simon, and H. Mössenböck. An intermediate representation for speculative optimizations in a dynamic compiler. In Proceedings of the ACM Workshop on Virtual Machines and Intermediate Languages, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Y. Futamura. Partial evaluation of computation process–an approach to a compiler-compiler. Systems, Computers, Controls, 2(5):721–728, 1971.Google ScholarGoogle Scholar
  16. N. Geoffray, G. Thomas, J. Lawall, G. Muller, and B. Folliot. VMKit: A substrate for managed runtime environments. In Proceedings of the International Conference on Virtual Execution Environments, pages 51–62, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. GitHub. Graal multi-language VM, 2016.Google ScholarGoogle Scholar
  18. I. Gouy. The computer language benchmarks game, 2016.Google ScholarGoogle Scholar
  19. M. Grimmer, M. Rigger, R. Schatz, L. Stadler, and H. Mössenböck. TruffleC: Dynamic execution of C on a Java virtual machine. In Proceedings of the International Conference on the Principles and Practice of Programming in Java, pages 17–26. ACM Press, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. M. Grimmer, R. Schatz, C. Seaton, T. Würthinger, and H. Mössenböck. Memory-safe execution of C on a Java VM. In Proceedings of the ACM Workshop on Programming Languages and Analysis for Security, pages 16–27. ACM Press, 2015. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. M. Grimmer, C. Seaton, R. Schatz, T. Würthinger, and H. Mössenböck. High-performance cross-language interoperability in a multi-language runtime. In Proceedings of the Dynamic Languages Symposium, pages 78–90. ACM Press, 2015. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. M. Grimmer, C. Seaton, T. Würthinger, and H. Mössenböck. Dynamically composing languages in a modular way: Supporting C extensions for dynamic languages. In Proceedings of the International Conference on Modularity, pages 1–13. ACM Press, 2015. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. U. Hölzle and D. Ungar. A third-generation SELF implementation: Reconciling responsiveness with performance. In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages, and Applications, pages 229–243. ACM Press, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. U. Hölzle, C. Chambers, and D. Ungar. Optimizing dynamically-typed object-oriented languages with polymorphic inline caches. In Proceedings of the European Conference on Object-Oriented Programming, pages 21–38. Springer-Verlag, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. U. Hölzle, C. Chambers, and D. Ungar. Debugging optimized code with dynamic deoptimization. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation, pages 32–43. ACM Press, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. C. Humer, C. Wimmer, C. Wirth, A. Wöß, and T. Würthinger. A domain-specific language for building self-optimizing AST interpreters. In Proceedings of the International Conference on Generative Programming and Component Engineering, pages 123–132. ACM Press, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. N. D. Jones and A. J. Glenstrup. Program generation, termination, and binding-time analysis. In Generative Programming and Component Engineering, volume 2487 of Lecture Notes in Computer Science, pages 1–31. Springer-Verlag, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. T. Kotzmann and H. Mössenböck. Run-time support for optimizations based on escape analysis. In Proceedings of the International Symposium on Code Generation and Optimization, pages 49–60. IEEE Computer Society, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. C. Lattner and V. Adve. LLVM: A compilation framework for lifelong program analysis & transformation. In Proceedings of the International Symposium on Code Generation and Optimization, pages 75–86. IEEE Computer Society, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. MacRuby. MacRuby, 2013.Google ScholarGoogle Scholar
  31. S. Marr, B. Daloze, and H. Mössenböck. Cross-language compiler benchmarking: Are we fast yet? In Proceedings of the Dynamic Languages Symposium, pages 120–131. ACM Press, 2016. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. H. Masuhara and A. Yonezawa. A portable-approach to dynamic optimization in run-time specialization. New Generation Computing, 20(1):101–124, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. F. Morandat, B. Hill, L. Osvald, and J. Vitek. Evaluating the design of the R language: Objects and functions for data analysis. In Proceedings of the European Conference on Object-Oriented Programming, pages 104–131. Springer-Verlag, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. C. Nutter. So you want to optimize Ruby, 2012.Google ScholarGoogle Scholar
  35. Optcarrot. Optcarrot: A NES emulator for Ruby benchmark, 2016.Google ScholarGoogle Scholar
  36. Oracle. Oracle Labs GraalVM downloads, 2016.Google ScholarGoogle Scholar
  37. M. Paleczny, C. Vick, and C. Click. The Java HotSpot TM server compiler. In Proceedings of the Java Virtual Machine Research and Technology Symposium, pages 1–12. USENIX, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. M. Rigger, M. Grimmer, C. Wimmer, T. Würthinger, and H. Mössenböck. Bringing low-level languages to the JVM: Efficient execution of LLVM IR on Truffle. In Proceedings of the ACM Workshop on Virtual Machines and Intermediate Languages, pages 6–15. ACM Press, 2016. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. A. Rigo and S. Pedroni. PyPy’s approach to virtual machine construction. In Companion to the ACM SIGPLAN Conference on Object Oriented Programming Systems, Languages, and Applications, pages 944–953. ACM Press, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. T. Rompf, A. K. Sujeeth, K. J. Brown, H. Lee, H. Chafi, and K. Olukotun. Surgical precision JIT compilers. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation, pages 41–52. ACM Press, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. Rubinius. Rubinius: Use Ruby, 2013.Google ScholarGoogle Scholar
  42. G. Savrun-Yenic¸eri, M. L. Van de Vanter, P. Larsen, S. Brunthaler, and M. Franz. An efficient and generic event-based profiler framework for dynamic languages. In Proceedings of the International Conference on the Principles and Practice of Programming in Java, pages 102–112. ACM Press, 2015. Google ScholarGoogle ScholarDigital LibraryDigital Library
  43. U. P. Schultz, J. L. Lawall, C. Consel, and G. Muller. Towards automatic specialization of Java programs. In Proceedings of the European Conference on Object-Oriented Programming, pages 367–390. Springer-Verlag, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  44. U. P. Schultz, J. L. Lawall, and C. Consel. Automatic program specialization for Java. In ACM Transactions on Programming Languages and Systems, pages 452–499. ACM Press, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  45. C. Seaton. AST specialisation and partial evaluation for easy high-performance metaprogramming. In Workshop on Meta-Programming Techniques and Reflection, 2016.Google ScholarGoogle Scholar
  46. C. Seaton, M. L. Van De Vanter, and M. Haupt. Debugging at full speed. In Proceedings of the Workshop on Dynamic Languages and Applications, pages 2:1–2:13. ACM Press, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  47. A. Shali and W. R. Cook. Hybrid partial evaluation. In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages, and Applications, pages 375–390. ACM Press, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  48. Y. Shi, K. Casey, M. A. Ertl, and D. Gregg. Virtual machine showdown: Stack versus registers. ACM Transactions on Architecture and Code Optimization, 4(4), 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  49. D. Simon, C. Wimmer, B. Urban, G. Duboscq, L. Stadler, and T. Würthinger. Snippets: Taking the high road to a low level. ACM Transactions on Architecture and Code Optimization, 12 (2):20:1–20:25, 2015. Google ScholarGoogle ScholarDigital LibraryDigital Library
  50. L. Stadler, C. Wimmer, T. Würthinger, H. Mössenböck, and J. Rose. Lazy continuations for Java virtual machines. In Proceedings of the International Conference on the Principles and Practice of Programming in Java, pages 143–152. ACM Press, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  51. L. Stadler, T. Würthinger, and C. Wimmer. Efficient coroutines for the Java platform. In Proceedings of the International Conference on the Principles and Practice of Programming in Java, pages 20–28. ACM Press, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  52. L. Stadler, T. Würthinger, and H. Mössenböck. Partial escape analysis and scalar replacement for java. In Proceedings of the International Symposium on Code Generation and Optimization, pages 165–174. ACM Press, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  53. L. Stadler, A. Welc, C. Humer, and M. Jordan. Optimizing R language execution via aggressive speculation. In Proceedings of the Dynamic Languages Symposium, pages 84–95. ACM Press, 2016. Google ScholarGoogle ScholarDigital LibraryDigital Library
  54. TC39. Official ecmascript conformance test suite, 2016.Google ScholarGoogle Scholar
  55. Unladen Swallow. unladen-swallow, 2009.Google ScholarGoogle Scholar
  56. S. Urbanek. R benchmarks 2.5, 2008.Google ScholarGoogle Scholar
  57. M. L. Van De Vanter. Building debuggers and other tools: We can ”have it all”. In Proceedings of the Workshop on the Implementation, Compilation, Optimization of Object-Oriented Languages and Programming Systems, pages 2:1–2:3. ACM Press, 2015. Google ScholarGoogle ScholarDigital LibraryDigital Library
  58. C. Wimmer, M. Haupt, M. L. Van De Vanter, M. Jordan, L. Daynès, and D. Simon. Maxine: An approachable virtual machine for, and in, Java. ACM Transactions on Architecture and Code Optimization, 9(4):30:1–30:24, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  59. C. Wimmer, V. Jovanovic, E. Eckstein, and T. Würthinger. One compiler: Deoptimization to optimized code. In Proceedings of the International Conference on Compiler Construction, pages 55–64. ACM Press, 2017. Google ScholarGoogle ScholarDigital LibraryDigital Library
  60. A. Wöß, C. Wirth, D. Bonetta, C. Seaton, C. Humer, and H. Mössenböck. An object storage model for the truffle language implementation framework. In Proceedings of the International Conference on the Principles and Practice of Programming in Java, pages 133–144. ACM Press, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  61. T. Würthinger, C. Wimmer, A. Wöß, L. Stadler, G. Duboscq, C. Humer, G. Richards, D. Simon, and M. Wolczko. One VM to rule them all. In Proceedings of Onward! ACM Press, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  62. W. Zhang, P. Larsen, S. Brunthaler, and M. Franz. Accelerating iterators in optimizing AST interpreters. In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages, and Applications, pages 727–743. ACM Press, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Practical partial evaluation for high-performance dynamic language runtimes

    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

    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!