A practical solution for scripting language compilers

Although scripting languages are becoming increasingly popular, even mature scripting language implementations remain interpreted. Several compilers and reimplementations have been attempted, generally focusing on performance. Based on our survey of these reimplementations, we determine that there are three important features of scripting languages that are difficult to compile or reimplement. Since scripting languages are defined primarily through the semantics of their original implementations, they often change semantics between releases. They provide large standard libraries, which are difficult to re-use, and costly to reimplement. They provide C APIs, used both for foreign-function-interfaces and to write third-party extensions. These APIs typically have tight integration with the original implementation. Finally, they support run-time code generation. These features make the important goal of correctness difficult to achieve. We present a technique to support these features in an ahead-of-time compiler for PHP. Our technique uses the original PHP implementation through the provided C API, both in our compiler, and an our generated code. We support all of these important scripting language features, particularly focusing on the correctness of compiled programs. Additionally, our approach allows us to automatically support limited future language changes. We present a discussion and performance evaluation of this technique, which has not previously been published.

[1]  Michael Franz,et al.  HotpathVM: an effective JIT compiler for resource-constrained devices , 2006, VEE '06.

[2]  Mason Chang,et al.  Trace-based just-in-time type specialization for dynamic languages , 2009, PLDI '09.

[3]  Ralph E. Griswold,et al.  An optimizing compiler for the icon programming language , 1992, Softw. Pract. Exp..

[4]  Armin Rigo,et al.  Representation-based just-in-time specialization and the psyco prototype for python , 2004, PEPM '04.

[5]  John Aycock,et al.  A brief history of just-in-time , 2003, CSUR.

[6]  Toshiaki Yasue,et al.  An Empirical Study of Method In-lining for a Java Just-in-Time Compiler , 2002, Java Virtual Machine Research and Technology Symposium.

[7]  John Aycock,et al.  UCPy : Reverse-Engineering Python , 2003 .

[8]  John Aycock Converting Python Virtual Machine Code to C , 1998 .

[9]  Edsko de Vries,et al.  Design and Implementation of a PHP Compiler Front-end , 2007 .

[10]  Angela Demke Brown,et al.  YETI: a graduallY extensible trace interpreter , 2007, VEE '07.

[11]  J. Benda Phalanger : Compiling and Running PHP Applications on the Microsoft . NET Platform , 2006 .

[12]  Michiaki Tatsubori,et al.  Copy-on-write in the PHP language , 2009, POPL '09.

[13]  Roberto Ierusalimschy,et al.  C APIs in Extension and Extensible Languages , 2007, J. Univers. Comput. Sci..

[14]  Zhendong Su,et al.  Sound and precise analysis of web applications for injection vulnerabilities , 2007, PLDI '07.

[15]  Sara Golemon Extending and Embedding PHP , 2006 .

[16]  Roberto Ierusalimschy,et al.  The Implementation of Lua 5.0 , 2005, J. Univers. Comput. Sci..

[17]  Vikram S. Adve,et al.  LLVM: a compilation framework for lifelong program analysis & transformation , 2004, International Symposium on Code Generation and Optimization, 2004. CGO 2004..

[18]  Michael Salib,et al.  Starkiller: A Static Type Inferencer and Compiler for Python , 2004 .

[19]  Marc Feeley,et al.  Speculative Inlining of Predefined Procedures in an R5RS Scheme to C Compiler , 2008, IFL.

[20]  Nicholas Nethercote,et al.  Valgrind: a framework for heavyweight dynamic binary instrumentation , 2007, PLDI '07.