Abstract
When building a compiler for a high-level language, certain intrinsic features of the language must be expressed in terms of the resulting low-level operations. Complex features are often expressed by explicitly weaving together bits of low-level IR, a process that is tedious, error prone, difficult to read, difficult to reason about, and machine dependent. In the Graal compiler for Java, we take a different approach: we use snippets of Java code to express semantics in a high-level, architecture-independent way. Two important restrictions make snippets feasible in practice: they are compiler specific, and they are explicitly prepared and specialized. Snippets make Graal simpler and more portable while still capable of generating machine code that can compete with other compilers of the Java HotSpot VM.
Supplemental Material
Available for Download
Slide deck associated with this paper
- B. Alpern, C. R. Attanasio, J. J. Barton, M. G. Burke, P.Cheng, J.-D. Choi, A. Cocchi, S. J. Fink, D. Grove, M. Hind, S. F. Hummel, D. Lieber, V. Litvinov, M. F. Mergen, T. Ngo, J. R. Russell, V. Sarkar, M. J. Serrano, J. C. Shepherd, S. E. Smith, V. C. Sreedhar, H. Srinivasan, and J. Whaley. 2000. The Jalapeño virtual machine. IBM Systems Journal 39, 1 (2000), 211--238. Google ScholarDigital Library
- Bowen Alpern, C. R. Attanasio, Anthony Cocchi, Susan Flynn Hummel, Derek Lieber, Mark Mergen, Janice C. Shepherd, and Stephen Smith. 1999. Implementing Jalapeño in Java. In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages, and Applications. ACM, 314--324. DOI:http://dx.doi.org/10.1145/320384.320418 Google ScholarDigital Library
- Davide Ancona, Massimo Ancona, Antonio Cuni, and Nicholas D. Matsakis. 2007. RPython: A step towards reconciling dynamically and statically typed OO languages. In Proceedings of the Dynamic Languages Symposium. ACM, 53--64. DOI:http://dx.doi.org/10.1145/1297081.1297091 Google ScholarDigital Library
- Apache Software Foundation. 2011. Dynamic Runtime Layer Virtual Machine. Retrieved from http://harmony.apache.org/subcomponents/drlvm/.Google Scholar
- S. M. Blackburn, R. Garner, C. Hoffman, A. M. Khan, K. S. McKinley, R. Bentzur, A. Diwan, D. Feinberg, D. Frampton, S. Z. Guyer, M. Hirzel, A. Hosking, M. Jump, H. Lee, J. E. B. Moss, A. Phansalkar, D. Stefanović, T. VanDrunen, D. von Dincklage, and B. Wiedermann. 2006. The DaCapo benchmarks: Java benchmarking development and analysis. In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages, and Applications. ACM, 169--190. DOI:http://dx.doi.org/10.1145/1167473.1167488 Google ScholarDigital Library
- Stephen M. Blackburn, Sergey I. Salishev, Mikhail Danilov, Oleg A. Mokhovikov, Anton A. Nashatyrev, Peter A. Novodvorsky, Vadim I. Bogdanov, Xiao Feng Li, and Dennis Ushakov. 2008. The Moxie JVM Experience. Technical Report TR-CS-08-01. Department of Computer Science, Australian National University.Google Scholar
- Michael G. Burke, Jong-Deok Choi, Stephen J. Fink, David Grove, Michael Hind, Vivek Sarkar, Mauricio J. Serrano, V. C. Sreedhar, Harini Srinivasan, and John Whaley. 1999. The Jalapeño dynamic optimizing compiler for Java. In Proceedings of the ACM Conference on Java Grande. ACM, 129--141. DOI:http://dx.doi.org/10.1145/304065.304113 Google ScholarDigital Library
- Michal Cierniak, Marsha Eng, Neal Glew, Brian T. Lewis, and James M. Stichnoth. 2005. The open runtime platform: A flexible high-performance managed runtime environment. Concurrency and Computation: Practice and Experience 17, 5--6 (2005), 617--637. DOI:http://dx.doi.org/10.1002/cpe.852 Google ScholarDigital Library
- Ron Cytron, Jeanne Ferrante, Barry K. Rosen, Mark N. Wegman, and F. Kenneth Zadeck. 1991. Efficiently computing static single assignment form and the control dependence graph. ACM Transactions on Programming Languages and Systems 13, 4 (1991), 451--490. DOI:http://dx.doi.org/10.1145/115372.115320 Google ScholarDigital Library
- Gilles Duboscq, Lukas Stadler, Thomas Würthinger, Doug Simon, Christian Wimmer, and Hanspeter Mössenböck. 2013a. Graal IR: An extensible declarative intermediate representation. In Proceedings of the Asia-Pacific Programming Languages and Compilers Workshop.Google Scholar
- Gilles Duboscq, Thomas Würthinger, Lukas Stadler, Christian Wimmer, Doug Simon, and Hanspeter Mössenböck. 2013b. An intermediate representation for speculative optimizations in a dynamic compiler. In Proceedings of the ACM Workshop on Virtual Machines and Intermediate Languages. ACM, 1--10. DOI:http://dx.doi.org/10.1145/2542142.2542143 Google ScholarDigital Library
- Daniel Frampton, Stephen M. Blackburn, Perry Cheng, Robin J. Garner, David Grove, J. Eliot B. Moss, and Sergey I. Salishev. 2009. Demystifying magic: High-level low-level programming. In Proceedings of the International Conference on Virtual Execution Environments. ACM, 81--90. DOI:http://dx.doi.org/10.1145/1508293.1508305 Google ScholarDigital Library
- Neal Glew, Spyridon Triantafyllis, Michał Clerniak, Marsha Eng, Brian Lewis, and James Stichnoth. 2004. LIL: An architecture-neutral language for virtual-machine stubs. In Proceedings of the Virtual Machine Research and Technology Symposium. USENIX Association, 111--125. Google ScholarDigital Library
- Urs Hölzle, Craig Chambers, and David Ungar. 1992. Debugging optimized code with dynamic deoptimization. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation. ACM, 32--43. DOI:http://dx.doi.org/10.1145/143095.143114 Google ScholarDigital Library
- Thomas Kotzmann, Christian Wimmer, Hanspeter Mössenböck, Thomas Rodriguez, Kenneth Russell, and David Cox. 2008. Design of the Java HotSpot™client compiler for Java 6. ACM Transactions on Architecture and Code Optimization 5, 1 (2008), Article 7. DOI:http://dx.doi.org/10.1145/1369396.1370017 Google ScholarDigital Library
- Bernd Mathiske. 2008. Systems Programming in the Maxine VM: How to Enable It and How to Get Around It. Retrieved from http://www.agentgroup.unimo.it/pppj08/invtalk1.html.Google Scholar
- OpenJDK 2013. Graal Project. Retrieved from http://openjdk.java.net/projects/graal.Google Scholar
- Krzysztof Palacz, Jason Baker, Chapman Flack, Christian Grothoff, Hiroshi Yamauchi, and Jan Vitek. 2005. Engineering a common intermediate representation for the OVM framework. Science of Computer Programming 57, 3 (2005), 357--378. DOI:http://dx.doi.org/10.1016/j.scico.2004.08.007 Google ScholarDigital Library
- Michael Paleczny, Christopher Vick, and Cliff Click. 2001. The Java HotSpot™ server compiler. In Proceedings of the Symposium on Java Virtual Machine Research and Technology. USENIX, 1--12. Google ScholarDigital Library
- Armin Rigo and Samuele Pedroni. 2006. PyPy’s approach to virtual machine construction. In Companion to the ACM SIGPLAN Conference on Object Oriented Programming Systems, Languages, and Applications. ACM, 944--953. DOI:http://dx.doi.org/10.1145/1176617.1176753 Google ScholarDigital Library
- Ian Rogers and Dave Grove. 2009. The strength of metacircular virtual machines: Jikes RVM. In Beautiful Architecture, Diomidis Spinellis and Georgios Gousios (Eds.). O’Reilly, Chapter 10.Google Scholar
- Andreas Sewe, Mira Mezini, Aibek Sarimbekov, and Walter Binder. 2011. Da Capo con Scala: Design and analysis of a Scala benchmark suite for the Java virtual machine. In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages, and Applications. ACM Press, 657--676. DOI:http://dx.doi.org/10.1145/2048066.2048118 Google ScholarDigital Library
- Doug Simon. 2009. The Maxine Project: Snippets in the Maxine VM. Retrieved from https://wikis.oracle.com/display/MaxineVM/Snippets.Google Scholar
- Ben L. Titzer, Thomas Würthinger, Doug Simon, and Marcelo Cintra. 2010. Improving compiler-runtime separation with XIR. In Proceedings of the International Conference on Virtual Execution Environments. ACM, 39--50. DOI:http://dx.doi.org/10.1145/1735997.1736005 Google ScholarDigital Library
- David Ungar, Adam Spitz, and Alex Ausch. 2005. Constructing a metacircular virtual machine in an exploratory programming environment. In Companion to the ACM SIGPLAN Conference on Object Oriented Programming Systems, Languages, and Applications. ACM, 11--20. DOI:http://dx.doi.org/10.1145/1094855.1094865 Google ScholarDigital Library
- Christian Wimmer, Michael Haupt, Michael L. Van De Vanter, Mick Jordan, Laurent Daynès, and Douglas Simon. 2013. Maxine: An approachable virtual machine for, and in, Java. ACM Transactions on Architecture and Code Optimization 9, 4 (2013), Article 30, 24 pages. DOI:http://dx.doi.org/10.1145/2400682.2400689 Google ScholarDigital Library
- Thomas Würthinger, Christian Wimmer, and Hanspeter Mössenböck. 2008. Visualization of program dependence graphs. In Proceedings of the International Conference on Compiler Construction. Springer-Verlag, 193--196. DOI:http://dx.doi.org/10.1007/978-3-540-78791-4_13 Google ScholarDigital Library
Index Terms
- Snippets: Taking the High Road to a Low Level
Recommendations
Joeq: a virtual machine and compiler infrastructure
Special issue on advances in interpreters, virtual machines and emulators (IVME'03)Joeq is a virtual machine and compiler infrastructure designed to facilitate research in virtual machine technologies such as Just-In-Time and Ahead-Of-Time compilation, advanced garbage collection techniques, distributed computation, sophisticated ...
Experiences with Building Domain-Specific Compilation Plugins in Graal
ManLang 2017: Proceedings of the 14th International Conference on Managed Languages and RuntimesIn this paper, we describe our experiences in co-designing a domain-specific compilation stack. Our motivation stems from the missed optimization opportunities we observed while implementing a computer vision library in Java. To tackle the performance ...
Optimizing invokedynamic
PPPJ '10: Proceedings of the 8th International Conference on the Principles and Practice of Programming in JavaIn order to support the needs of non-Java languages, the JSR 292 Expert Group has designed a new bytecode "invokedynamic" which allows JVM bytecodes to contain call sites with pluggable, user-defined behavior. The bytecode is accompanied by a new data ...
Comments