Abstract
Runtime metaprogramming enables many useful applications and is often a convenient solution to solve problems in a generic way, which makes it widely used in frameworks, middleware, and domain-specific languages. However, powerful metaobject protocols are rarely supported and even common concepts such as reflective method invocation or dynamic proxies are not optimized. Solutions proposed in literature either restrict the metaprogramming capabilities or require application or library developers to apply performance improving techniques. For overhead-free runtime metaprogramming, we demonstrate that dispatch chains, a generalized form of polymorphic inline caches common to self-optimizing interpreters, are a simple optimization at the language-implementation level. Our evaluation with self-optimizing interpreters shows that unrestricted metaobject protocols can be realized for the first time without runtime overhead, and that this optimization is applicable for just-in-time compilation of interpreters based on meta-tracing as well as partial evaluation. In this context, we also demonstrate that optimizing common reflective operations can lead to significant performance improvements for existing applications.
- K. Asai. Compiling a Reflective Language Using MetaOCaml. In Proceedings of the 2014 International Conference on Generative Programming: Concepts and Experiences, GPCE 2014, pages 113–122. ACM, 2014. Google Scholar
Digital Library
- V. Bala, E. Duesterwald, and S. Banerjia. Dynamo: A Transparent Dynamic Optimization System. In Proceedings of the ACM SIGPLAN 2000 Conference on Programming Language Design and Implementation, PLDI ’00, pages 1–12. ACM, 2000. Google Scholar
Digital Library
- C. F. Bolz and L. Tratt. The Impact of Meta-Tracing on VM Design and Implementation. Science of Computer Programming, 2013.Google Scholar
- C. F. Bolz, A. Cuni, M. Fijalkowski, and A. Rigo. Tracing the Meta-level: PyPy’s Tracing JIT Compiler. In Proceedings of the 4th Workshop on the Implementation, Compilation, Optimization of Object-Oriented Languages and Programming Systems, ICOOOLPS ’09, pages 18–25. ACM, 2009. Google Scholar
Digital Library
- G. T. Brown. Ruby Best Practices. O’Reilly, Sebastopol, CA, June 2009. Google Scholar
Digital Library
- S. Brunthaler. Efficient Interpretation Using Quickening. In Proceedings of the 6th Symposium on Dynamic Languages, number 12 in DLS, pages 1–14. ACM, Oct. 2010. Google Scholar
Digital Library
- K. Casey, M. A. Ertl, and D. Gregg. Optimizing Indirect Branch Prediction Accuracy in Virtual Machine Interpreters. ACM Trans. Program. Lang. Syst., 29(6):37, 2007. Google Scholar
Digital Library
- S. Chiba. A Study of Compile-time Metaobject Protocol. Phd thesis, University of Tokyo, November 1996.Google Scholar
- L. P. Deutsch and A. M. Schiffman. Efficient implementation of the smalltalk-80 system. In POPL ’84: Proceedings of the 11th ACM SIGACT-SIGPLAN symposium on Principles of programming languages, pages 297–302. ACM, 1984. Google Scholar
Digital Library
- Z. DeVito, D. Ritchie, M. Fisher, A. Aiken, and P. Hanrahan. Firstclass Runtime Generation of High-performance Types Using Exotypes. In Proceedings of the 35th ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI ’14, pages 77–88. ACM, 2014. Google Scholar
Digital Library
- M. Fowler. Domain-Specific Languages. Addison-Wesley, October 2010. Google Scholar
Digital Library
- A. Gal, C. W. Probst, and M. Franz. HotpathVM: An Effective JIT Compiler for Resource-constrained Devices. In Proc. of VEE, pages 144–153. ACM, 2006. Google Scholar
Digital Library
- M. Golm and J. Kleinöder. Jumping to the Meta Level. In P. Cointe, editor, Meta-Level Architectures and Reflection, volume 1616 of LNCS, pages 22–39. Springer, 1999.Google Scholar
Cross Ref
- M. Grimmer, M. Rigger, R. Schatz, L. Stadler, and H. Mössenböck. TruffleC: Dynamic Execution of C on a Java Virtual Machine. In Proc of the Conference on Principles and Practices of Programming on the Java Platform: Virtual Machines, Languages, and Tools, PPPJ ’14, pages 17–26. ACM, 2014. Google Scholar
Digital Library
- M. Haupt, R. Hirschfeld, T. Pape, G. Gabrysiak, S. Marr, A. Bergmann, A. Heise, M. Kleine, and R. Krahn. The SOM Family: Virtual Machines for Teaching and Research. In Proceedings of the 15th Annual Conference on Innovation and Technology in Computer Science Education (ITiCSE), pages 18–22. ACM Press, June 2010. Google Scholar
Digital Library
- 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 13th International Conference on Generative Programming: Concepts and Experiences, GPCE ’14. ACM, 2014. Google Scholar
Digital Library
- U. Hölzle, C. Chambers, and D. Ungar. Optimizing Dynamically-Typed Object-Oriented Languages With Polymorphic Inline Caches. In ECOOP ’91: European Conference on Object-Oriented Programming, volume 512 of LNCS, pages 21–38. Springer, 1991. Google Scholar
Digital Library
- H. Inoue, H. Hayashizaki, P. Wu, and T. Nakatani. Adaptive multilevel compilation in a trace-based java jit compiler. In Proceedings of the ACM International Conference on Object Oriented Programming Systems Languages and Applications, OOPSLA ’12, pages 179–194, New York, NY, USA, 2012. ACM. Google Scholar
Digital Library
- T. Kalibera, P. Maj, F. Morandat, and J. Vitek. A Fast Abstract Syntax Tree Interpreter for R. In Proceedings of the 10th ACM SIGPLAN/SIGOPS International Conference on Virtual Execution Environments, VEE’14, pages 89–102. ACM, 2014. Google Scholar
Digital Library
- G. Kiczales, J. des Rivières, and D. G. Bobrow. The Art of the Metaobject Protocol. The MIT Press, 1991. Google Scholar
Digital Library
- S. Marr and T. D’Hondt. Identifying A Unifying Mechanism for the Implementation of Concurrency Abstractions on Multi-Language Virtual Machines. In Objects, Models, Components, Patterns, 50th International Conference, TOOLS 2012, volume 7304 of LNCS, pages 171–186. Springer, May 2012. Google Scholar
Digital Library
- S. Marr, T. Pape, and W. De Meuter. Are We There Yet? Simple Language Implementation Techniques for the 21st Century. IEEE Software, 31(5):60–67, September 2014. ISSN 0740-7459.Google Scholar
Cross Ref
- H. Masuhara, S. Matsuoka, K. Asai, and A. Yonezawa. Compiling Away the Meta-level in Object-oriented Concurrent Reflective Languages Using Partial Evaluation. In Proceedings of the Tenth Annual Conference on Object-oriented Programming Systems, Languages, and Applications, OOPSLA ’95, pages 300–315. ACM, 1995. Google Scholar
Digital Library
- R. Olsen. Eloquent Ruby. Professional Ruby. Addison-Wesley, Upper Saddle River, NJ, February 2011. Google Scholar
Digital Library
- J. R. Rose. Bytecodes meet Combinators: invokedynamic on the JVM. In Proceedings of the Third Workshop on Virtual Machines and Intermediate Languages, pages 1–11. ACM, Oct. 2009. Google Scholar
Digital Library
- C. Seaton, M. L. Van De Vanter, and M. Haupt. Debugging at Full Speed. In Proceedings of the Workshop on Dynamic Languages and Applications, Dyla’14, pages 2:1–2:13. ACM, 2014. Google Scholar
Digital Library
- A. Shali and W. R. Cook. Hybrid Partial Evaluation. In Proceedings of the 2011 ACM International Conference on Object Oriented Programming Systems Languages and Applications, OOPSLA ’11, pages 375–390. ACM, 2011. Google Scholar
Digital Library
- G. Sullivan. Dynamic Partial Evaluation. In Programs as Data Objects, volume 2053 of LNCS, pages 238–256. Springer, 2001. Google Scholar
Digital Library
- W. Taha and T. Sheard. Multi-stage Programming with Explicit Annotations. In Proceedings of the 1997 ACM SIGPLAN Symposium on Partial Evaluation and Semantics-based Program Manipulation, PEPM ’97, pages 203–217. ACM, 1997. Google Scholar
Digital Library
- E. Tanter, J. Noyé, D. Caromel, and P. Cointe. Partial Behavioral Reflection: Spatial and Temporal Selection of Reification. In Proceedings of the 18th Annual ACM SIGPLAN Conference on Objectoriented Programing, Systems, Languages, and Applications, pages 27–46. ACM, October 2003. Google Scholar
Digital Library
- S. Tobin-Hochstadt, V. St-Amour, R. Culpepper, M. Flatt, and M. Felleisen. Languages as libraries. In Proceedings of the 32nd ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI ’11, pages 132–141. ACM, 2011. Google Scholar
Digital Library
- L. Tratt. Compile-time Meta-programming in a Dynamically Typed OO Language. In Proceedings of the 2005 Symposium on Dynamic Languages, DLS ’05, pages 49–63. ACM, 2005. Google Scholar
Digital Library
- T. Würthinger, A. Wöß, L. Stadler, G. Duboscq, D. Simon, and C. Wimmer. Self-Optimizing AST Interpreters. In Proceedings of the 8th Dynamic Languages Symposium, DLS’12, pages 73–82, October 2012. Google Scholar
Digital Library
- 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 the 2013 ACM International Symposium on New Ideas, New Paradigms, and Reflections on Programming & Software, Onward!’’13, pages 187–204. ACM, 2013. Google Scholar
Digital Library
- 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 2014 International Conference on Principles and Practices of Programming on the Java Platform: Virtual Machines, Languages, and Tools, PPPJ ’14. ACM, 2014. Google Scholar
Digital Library
- W. Zhang, P. Larsen, S. Brunthaler, and M. Franz. Accelerating Iterators in Optimizing AST Interpreters. In Proceedings of the 2014 ACM International Conference on Object Oriented Programming Systems Languages & Applications, OOPSLA ’’14, pages 727–743. ACM, 2014. Google Scholar
Digital Library
Index Terms
Zero-overhead metaprogramming: reflection and metaobject protocols fast and without compromises
Recommendations
Zero-overhead metaprogramming: reflection and metaobject protocols fast and without compromises
PLDI '15: Proceedings of the 36th ACM SIGPLAN Conference on Programming Language Design and ImplementationRuntime metaprogramming enables many useful applications and is often a convenient solution to solve problems in a generic way, which makes it widely used in frameworks, middleware, and domain-specific languages. However, powerful metaobject protocols ...
Tracing vs. partial evaluation: comparing meta-compilation approaches for self-optimizing interpreters
OOPSLA 2015: Proceedings of the 2015 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and ApplicationsTracing and partial evaluation have been proposed as meta-compilation techniques for interpreters to make just-in-time compilation language-independent. They promise that programs executing on simple interpreters can reach performance of the same order ...
Tracing vs. partial evaluation: comparing meta-compilation approaches for self-optimizing interpreters
OOPSLA '15Tracing and partial evaluation have been proposed as meta-compilation techniques for interpreters to make just-in-time compilation language-independent. They promise that programs executing on simple interpreters can reach performance of the same order ...






Comments