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.
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- DWARF Standards Committee. Dwarf debugging information format, version 4, June 2010. URL http://www.dwarfstd.org/.Google Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- Google. V8 JavaScript Engine, 2017. URL https://developers.google.com/v8/.Google Scholar
- 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 Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- O. Kowalke. Boost.Context, 2017. URL http://www.boost.org/doc/libs/1_63_0/libs/context/doc/html/index.html.Google Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- Mozilla. SpiderMonkey, 2017. URL https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey.Google Scholar
- M. Prandini and M. Ramilli. Return-oriented programming. IEEE Security & Privacy, 10(6):84--87, Nov. 2012. Google Scholar
Digital Library
- K. Wang. Holstein: the reference implementation of Mu, 2018. URL https://gitlab.anu.edu.au/mu/mu-impl-ref2.Google Scholar
- K. Wang. The specification of the Mu micro virtual machine, 2018. URL https://gitlab.anu.edu.au/mu/mu-spec.Google Scholar
- 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 Scholar
- 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 Scholar
Digital Library
Index Terms
Hop, Skip, & Jump: Practical On-Stack Replacement for a Cross-Platform Language-Neutral VM
Recommendations
Hop, Skip, & Jump: Practical On-Stack Replacement for a Cross-Platform Language-Neutral VM
VEE '18: Proceedings of the 14th ACM SIGPLAN/SIGOPS International Conference on Virtual Execution EnvironmentsOn-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 ...
Graal and truffle: modularity and separation of concerns as cornerstones for building a multipurpose runtime
MODULARITY '14: Proceedings of the companion publication of the 13th international conference on ModularityMulti-language runtimes providing simultaneously high performance for several programming languages still remain an illusion. Industrial-strength managed language runtimes are built with a focus on one language (e.g., Java or C#). Other languages may ...
A modular approach to on-stack replacement in LLVM
VEE '13On-stack replacement (OSR) is a technique that allows a virtual machine to interrupt running code during the execution of a function/method, to re-optimize the function on-the-fly using an optimizing JIT compiler, and then to resume the interrupted ...







Comments