skip to main content
article

A domain-specific language for building self-optimizing AST interpreters

Published:15 September 2014Publication History
Skip Abstract Section

Abstract

Self-optimizing AST interpreters dynamically adapt to the provided input for faster execution. This adaptation includes initial tests of the input, changes to AST nodes, and insertion of guards that ensure assumptions still hold. Such specialization and speculation is essential for the performance of dynamic programming languages such as JavaScript. In traditional procedural and objectoriented programming languages it can be tedious to write selfoptimizing AST interpreters, as those languages fail to provide constructs that would specifically support that. This paper introduces a declarative domain-specific language (DSL) that greatly simplifies writing self-optimizing AST interpreters. The DSL supports specialization of operations based on types of the input and other properties. It can then use these specializations directly or chain them to represent the operation with the minimum amount of code possible. The DSL significantly reduces the complexity of expressing specializations for those interpreters. We use it in our high-performance implementation of JavaScript, where 274 language operations have an average of about 4 and a maximum of 190 specializations. In addition, the DSL is used in implementations of Ruby, Python, R, and Smalltalk.

References

  1. Project Lombok. URL http://projectlombok.org/.Google ScholarGoogle Scholar
  2. Meta programming system. URL http://www.jetbrains.com/mps.Google ScholarGoogle Scholar
  3. Xtext. URL http://www.eclipse.org/Xtext/.Google ScholarGoogle Scholar
  4. TruffleSOM: A file-based Smalltalk implementation built with truffle., 2014. URL https://github.com/smarr/TruffleSOM.Google ScholarGoogle Scholar
  5. L. Bettini. A DSL for writing type systems for Xtext languages. In Proceedings of the International Conference on the Principles and Practice of Programming in Java, pages 31–40. ACM Press, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. L. Bettini. Implementing Java-like languages in Xtext with Xsemantics. In Proceedings of the ACM Symposium on Applied Computing, pages 1559–1564. ACM Press, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. E. Bruneton, R. Lenglet, and T. Coupaye. ASM: A code manipulation tool to implement adaptable systems. In Adaptable and Extensible Component Systems, 2002.Google ScholarGoogle Scholar
  8. S. Brunthaler. Efficient interpretation using quickening. In Proceedings of the Dynamic Languages Symposium, pages 1–14. ACM Press, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. M. L. V. D. V. C. Seaton and M. Haupt. Debugging at full speed. In Proceedings of the 8th Workshop on Dynamic Languages and Applications (DYLA), 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. H. Chafi, Z. DeVito, A. Moors, T. Rompf, A. K. Sujeeth, P. Hanrahan, M. Odersky, and K. Olukotun. Language virtualization for heterogeneous parallel computing. In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages, and Applications, pages 835–847. ACM Press, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. C. Chambers, D. Ungar, and E. Lee. An efficient implementation of SELF, a dynamically-typed object-oriented language based on prototypes. In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages, and Applications, pages 49–70. ACM Press, 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. W. Dietl, S. Dietzel, M. D. Ernst, K. Mus¸lu, and T. W. Schiller. Building and using pluggable type-checkers. In Proceedings of the International Conference on Software Engineering, pages 681–690. ACM Press, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. S. Efftinge, M. Eysholdt, J. Köhnlein, S. Zarnekow, R. von Massow, W. Hasselbring, and M. Hanus. Xbase: implementing domain-specific languages for Java. In Proceedings of the International Conference on Generative Programming and Component Engineering, pages 112– 121. ACM Press, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. M. Ernst, C. Kaplan, and C. Chambers. Predicate dispatching: A unified theory of dispatch. In Proceedings of the 12th European Conference on Object-Oriented Programming, ECCOP ’98, pages 186–211, London, UK, UK, 1998. Springer-Verlag. ISBN 3-540- 64737-6. URL http://dl.acm.org/citation.cfm?id=646155.679688. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. FastR. FastR is an implementation of the R language in Java atop Truffle and Graal., 2014. URL https://bitbucket.org/allr/fastr.Google ScholarGoogle Scholar
  16. A. Gal, B. Eich, M. Shaver, D. Anderson, D. Mandelin, M. R. Haghighat, B. Kaplan, G. Hoare, B. Zbarsky, J. Orendorff, J. Ruderman, E. W. Smith, R. Reitmaier, M. Bebenita, M. Chang, and M. Franz. Trace-based Just-in-Time Type Specialization for Dynamic Languages. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation, pages 465–478. ACM Press, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. D. Ghosh. DSLs in Action. Manning Publications Co., Greenwich, CT, USA, 1st edition, 2010. ISBN 9781935182450. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Google. V8 JavaScript engine, 2012. URL http://code.google.com/p/ v8/.Google ScholarGoogle Scholar
  19. Google. V8 benchmark suite, 2012. URL http://v8.googlecode.com/ svn/data/benchmarks/current/run.html.Google ScholarGoogle Scholar
  20. JSR 269. JSR 269: Pluggable Annotation Processing API, 2011. URL http://www.jcp.org/en/jsr/detail?id=269.Google ScholarGoogle Scholar
  21. L. C. Kats and E. Visser. The Spoofax language workbench: rules for declarative specification of languages and IDEs. In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages, and Applications, pages 444–463. ACM Press, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. A. Klepinin and A. Melentyev. Integration of semantic verifiers into Java language compilers. Automatic Control and Computer Sciences, 45(7):408–412, 2011..Google ScholarGoogle ScholarCross RefCross Ref
  23. D. H. Lorenz and B. Rosenan. Cedalion: a language for language oriented programming. In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages, and Applications, pages 733–752. ACM Press, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. D. McNamee, J. Walpole, C. Pu, C. Cowan, C. Krasic, A. Goel, P. Wagle, C. Consel, G. Muller, and R. Marlet. Specialization tools and techniques for systematic optimization of system software. ACM Trans. Comput. Syst., 19(2):217–251, May 2001. ISSN 0734-2071. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. R. Nuccitelli, E. Guerra, and C. Fernandes. Parsing XML documents in Java using annotations. In XML, Associated Technologies and Applications, 2010.Google ScholarGoogle Scholar
  26. OpenJDK. Graal project, 2013. URL http://openjdk.java.net/projects/ graal.Google ScholarGoogle Scholar
  27. M. M. Papi, M. Ali, T. L. Correa, Jr., J. H. Perkins, and M. D. Ernst. Practical pluggable types for Java. In Proceedings of the International Symposium on Software Testing and Analysis, pages 201–212. ACM Press, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. T. Rompf and M. Odersky. Lightweight modular staging: a pragmatic approach to runtime code generation and compiled DSLs. In Proceedings of the International Conference on Generative Programming and Component Engineering, pages 127–136. ACM Press, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. E. N. Volanschi, C. Consel, G. Muller, and C. Cowan. Declarative specialization of object-oriented programs. SIGPLAN Not., 32(10): 286–300, Oct. 1997. ISSN 0362-1340. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. M. P. Ward. Language oriented programming. Software-Concepts and Tools, 15:147–161, 1995.Google ScholarGoogle Scholar
  31. T. Würthinger, A. Wöß, L. Stadler, G. Duboscq, D. Simon, and C. Wimmer. Self-optimizing AST interpreters. In Proceedings of the 8th symposium on Dynamic languages, DLS ’12, pages 73–82. ACM Press, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. 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
  33. W. Zhang, P. Larsen, S. Brunthaler, and M. Franz. Accelerating iterators in optimizing ast interpreters. In Submitted to OOPSLA, 2014. Introduction System Structure Node Rewriting Expressing Specializations Truffle DSL Specializations Example Conditional Child Execution Optimization Type Check Elimination Specialization Reduction Guard Reduction DSL Implementation Annotation Processor Evaluation Initial Conversion to Truffle DSL Current use of Truffle DSL Related Work ConclusionsGoogle ScholarGoogle Scholar

Index Terms

  1. A domain-specific language for building self-optimizing AST interpreters

    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!