TruffleC: dynamic execution of C on a Java virtual machine
Sprache des Titels:
Proceedings of the 2014 International Conference on Principles and Practices of Programming on the Java platform: Virtual machines, Languages, and Tools
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.