TruffleC: dynamic execution of C on a Java virtual machine

This paper presents TruffleC, a C interpreter that allows the dynamic execution of C code on top of a Java Virtual Machine (JVM). Rather than producing a static build of a C application, TruffleC is a self-optimizing abstract syntax tree (AST) interpreter combined with a just-in-time (JIT) compiler. Our self-optimizing interpreter specializes the AST based on run-time feedback. AST specialization relies on optimistic assumptions and allows us to build inline caches for polymorphic function pointer calls, to profile runtime values and to potentially replace them with constants, or to speculatively remove code that was not executed yet. After AST specialization, the JIT compiler translates the AST to highly optimized machine code. The machine code uses dynamic deoptimization points at which the control switches back to the interpreter in case of a violated assumption. We evaluated TruffleC using a C micro-benchmark in terms of peak performance. This evaluation showed that TruffleC outperforms the code produced by industry standard compilers such as GCC or Clang/LLVM. The evaluation of other benchmarks ("Computer Language Benchmarks Game") showed that the TruffleC performance is on average only 7% slower than the best performance out of the GCC and Clang/LLVM performances.

[1]  Hanspeter Mössenböck,et al.  Compilation queuing and graph caching for dynamic compilers , 2012, VMIL '12.

[2]  ChambersCraig,et al.  Debugging optimized code with dynamic deoptimization , 1992 .

[3]  Hanspeter Mössenböck,et al.  An efficient native function interface for Java , 2013, PPPJ.

[4]  Adam Megacz,et al.  Complete translation of unsafe native code to safe bytecode , 2004, IVME '04.

[5]  Mark N. Wegman,et al.  Efficiently computing static single assignment form and the control dependence graph , 1991, TOPL.

[6]  Suman Saha,et al.  An approach to improving the structure of error-handling code in the linux kernel , 2011, LCTES '11.

[7]  Hanspeter Mössenböck,et al.  Partial Escape Analysis and Scalar Replacement for Java , 2014, CGO '14.

[8]  Zahira Ammarguellat,et al.  Parcel and Miprac: Parallelizers for Symbolic and Numeric Programs , .

[9]  Wen-mei W. Hwu,et al.  Inline function expansion for compiling C programs , 1989, PLDI '89.

[10]  Markus Mock,et al.  Dynamic points-to sets: a comparison with static analyses and potential applications in program understanding and optimization , 2001, PASTE '01.

[11]  Christian Wimmer,et al.  Self-optimizing AST interpreters , 2012, DLS.

[12]  Scott A. Mahlke,et al.  Profile‐guided automatic inline expansion for C programs , 1992, Softw. Pract. Exp..

[13]  Matthew Arnold,et al.  A Survey of Adaptive Optimization in Virtual Machines , 2005, Proceedings of the IEEE.

[14]  Lars Lundberg,et al.  Cibyl: an environment for language diversity on mobile devices , 2007, VEE '07.

[15]  Steve Johnson,et al.  Compiling C for vectorization, parallelization, and inline expansion , 1988, PLDI '88.

[16]  Brian N. Bershad,et al.  Fast, effective dynamic compilation , 1996, PLDI '96.

[17]  Erven Rohou,et al.  CLI-based compilation flows for the C language , 2010, 2010 International Conference on Embedded Computer Systems: Architectures, Modeling and Simulation.

[18]  Laurie J. Hendren,et al.  Taming control flow: a structured approach to eliminating goto statements , 1994, Proceedings of 1994 IEEE International Conference on Computer Languages (ICCL'94).

[19]  Christian Wimmer,et al.  One VM to rule them all , 2013, Onward!.