skip to main content
tutorial
Open Access

Hop, Skip, & Jump: Practical On-Stack Replacement for a Cross-Platform Language-Neutral VM

Published:25 March 2018Publication History
Skip Abstract Section

Abstract

On-stack replacement (OSR) is a performance-critical technology for many languages, especially dynamic languages. Conventional wisdom, apparent in JavaScript engines such as V8 and SpiderMonkey, is that OSR must be implemented in a low-level (i.e., in assembly) and language-specific way.

This paper presents an OSR abstraction based on Swapstack, materialized as the API for a low-level virtual machine, and shows how the abstraction of resumption protocols facilitates an elegant implementation of this API on real hardware. Using an experimental JavaScript implementation, we demonstrate that this API enables the language implementation to perform OSR without the need to deal with machine-level details. We also show that the API itself is implementable on concrete hardware. This work helps crystallize OSR abstractions and, by providing a reusable implementation, brings OSR within reach for more language implementers.

References

  1. B. Alpern, C. R. Attanasio, A. Cocchi, D. Lieber, S. Smith, T. Ngo, J. J. Barton, S. Hummel Flynn, J. C. Sheperd, and M. Mergen. Implementing Jalapeño in Java. In ACM SIGPLAN International Conference on Object Oriented Programming, Systems, Languages, and Applications, pages 314--324, Denver, Colorado, Nov. 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. M. Arnold, S. Fink, D. Grove, M. Hind, and P. F. Sweeney. Adaptive optimization in the Jalapeño JVM. In ACM SIGPLAN International Conference on Object Oriented Programming, Systems, Languages, and Applications, pages 47--65, Minneapolis, Minnesota, Oct. 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. J. Castanos, D. Edelsohn, K. Ishizaki, P. Nagpurkar, T. Nakatani, T. Ogasawara, and P. Wu. On the benefits and pitfalls of extending a statically typed language JIT compiler for dynamic scripting languages. In ACM SIGPLAN International Conference on Object Oriented Programming, Systems, Languages, and Applications, pages 195--212, Tucson, Arizona, Oct. 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. D. C. D'Elia and C. Demetrescu. Flexible on-stack replacement in LLVM. In IEEE/ACM International Symposium on Code Generation and Optimization, pages 250--260, Barcelona, Spain, Mar. 2016. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. S. Dolan, S. Muralidharan, and D. Gregg. Compiler support for lightweight context switching. ACM Transactions on Architecture and Code Optimization, 9(4):36:1--25, Jan. 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. DWARF Standards Committee. Dwarf debugging information format, version 4, June 2010. URL http://www.dwarfstd.org/.Google ScholarGoogle Scholar
  7. S. J. Fink and F. Qian. Design, implementation and evaluation of adaptive recompilation with on-stack replacement. In IEEE/ACM International Symposium on Code Generation and Optimization, pages 241--252, San Francisco, California, Mar. 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. N. Geoffray, G. Thomas, J. Lawall, G. Muller, and B. Folliot. VMKit: A substrate for managed runtime environments. In ACM SIGPLAN/SIGOPS International Conference on Virtual Execution Environments, pages 51--62, Pittsburgh, Pennsylvania, Mar. 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Google. V8 JavaScript Engine, 2017. URL https://developers.google.com/v8/.Google ScholarGoogle Scholar
  10. D. Gudeman. Representing type information in dynamically typed languages. Technical Report TR 93-27, Department of Computer Science, The University of Arizona, Tucson, Arizona, Oct. 1993.Google ScholarGoogle Scholar
  11. U. Hölzle and D. Ungar. A third-generation self implementation: Reconciling responsiveness with performance. In ACM SIGPLAN International Conference on Object Oriented Programming, Systems, Languages, and Applications, pages 229--243, Portland, Oregon, Oct. 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. U. Hölzle, C. Chambers, and D. Ungar. Debugging optimized code with dynamic deoptimization. In ACM SIGPLAN International Conference on Programming Language Design and Implementation, pages 32--43, San Francisco, California, June 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. G. Klein, K. Elphinstone, G. Heiser, J. Andronick, D. Cock, P. Derrin, D. Elkaduwe, K. Engelhardt, R. Kolanski, M. Norrish, T. Sewell, H. Tuch, and S. Winwood. seL4: Formal verification of an OS kernel. In ACM SIGOPS Symposium on Operating Systems Principles, pages 207--220, Big Sky, Montana, Oct. 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. O. Kowalke. Boost.Context, 2017. URL http://www.boost.org/doc/libs/1_63_0/libs/context/doc/html/index.html.Google ScholarGoogle Scholar
  15. N. A. Lameed and L. J. Hendren. A modular approach to on-stack replacement in LLVM. In ACM SIGPLAN/SIGOPS International Conference on Virtual Execution Environments, pages 143--154, Houston, Texas, Mar. 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. C. Lattner and V. Adve. LLVM: A compilation framework for lifelong program analysis & transformation. In IEEE/ACM International Symposium on Code Generation and Optimization, pages 75--88, San Jose, California, Mar. 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Mozilla. SpiderMonkey, 2017. URL https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey.Google ScholarGoogle Scholar
  18. M. Prandini and M. Ramilli. Return-oriented programming. IEEE Security & Privacy, 10(6):84--87, Nov. 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. K. Wang. Holstein: the reference implementation of Mu, 2018. URL https://gitlab.anu.edu.au/mu/mu-impl-ref2.Google ScholarGoogle Scholar
  20. K. Wang. The specification of the Mu micro virtual machine, 2018. URL https://gitlab.anu.edu.au/mu/mu-spec.Google ScholarGoogle Scholar
  21. K. Wang, Y. Lin, S. M. Blackburn, M. Norrish, and A. L. Hosking. Draining the swamp: Micro virtual machines as solid foundation for language development. In Inaugural Summit on Advances in Programming Languages, pages 321--336, Asilomar, California, May 2015.Google ScholarGoogle Scholar
  22. 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 ACM SIGPLAN International Symposium on New Ideas, New Paradigms, and Reflections on Programming and Software, pages 187--204, Indianapolis, Indiana, Oct. 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Hop, Skip, & Jump: Practical On-Stack Replacement for a Cross-Platform Language-Neutral VM

      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 53, Issue 3
        VEE '18
        March 2018
        99 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/3296975
        Issue’s Table of Contents
        • cover image ACM Conferences
          VEE '18: Proceedings of the 14th ACM SIGPLAN/SIGOPS International Conference on Virtual Execution Environments
          March 2018
          106 pages
          ISBN:9781450355797
          DOI:10.1145/3186411

        Copyright © 2018 Owner/Author

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 25 March 2018

        Check for updates

        Qualifiers

        • tutorial
        • Research
        • Refereed limited

      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!