V8 also powers Node.js, which is a popular project meant to allow using JavaScript also on the server side. Some time ago we talked in the Lately in JavaScript podcast about a trend of Node.js becoming a sort of PHP but in JavaScript.
Implementing a proper JIT compiler is easier said than done, but fortunately there are some Open Source projects that can be adopted, rather than writing a JIT compiler from scratch. Here is an overview of some that I know:
There is not much more to say about Phalanger besides what was already said above.
I just suspect that it will never be considered as acceptable JIT solution, not because of technical matters, but maybe because it is built on top of a platform created by Microsoft. And you know, there are core developers that hate anything related with Microsoft with a passion. But who knows I may wrong.
What I said about Phalanger, I could also say about the Quercus. That is a project which compiles PHP into Java bytecodes. It is basically the same approach for a different platform, which is not so different after all, as .NET is basically the Microsoft implementation of a platform like Java.
Coincidentally Facebook just released an enhanced version of their PHP Facebook HipHop compiler that does JIT. Unlike the initial version release that takes hours to compile a simple PHP application like Wordpress, this release implements fast dynamic translation of PHP code to native machine code which can compile PHP code in a few seconds.
Facebook employed Scott MacVicar, a PHP core developer to work on the PHP HipHop compiler project. I guess this fact helps making HipHop JIT engine a strong candidate to be used by PHP core developers as the JIT engine for the future of Zend Engine based PHP.
PHC is a PHP compiler that compiles PHP scripts into PHP extensions that can be used with the Zend Engine based PHP implementation.To be accurate we cannot call it a JIT engine because it uses the static compilation approach, very similar to the original HipHop PHP compiler implementation, so it is very slow.
The main difference is that PHC can generate C code that can run with Zend Engine, while HipHop is a project totally independent of Zend Engine.
LLVM is a set of compiler tools that among other things can be used to create JIT compilers for a variety of languages, including PHP.
In 2008 Nuno Lopes started working on a PECL LLVM extension that aimed to add JIT capabilities the Zend Engine by compiling Zend opcodes into native machine code.
I contacted Nuno and he told me that the project is somewhat abandoned due to the lack of interest of other core developers to help on achieving the project goals.
Now that the interest about bringing to life a PHP JIT compiler that works with Zend Engine sort of emerged, who knows if Nuno or other developers will regain interest in resuming the project.
Zend may as well come up with their own JIT compiler. They could even build a JIT engine that generates native machine code directly, instead of generating intermediary opcodes first. That is basically what the Google V8 engine does, and it is really very fast.
Such project would consume Zend a lot of resources but in the end it would be something they would have greater control.
Well, I just covered several possibilities of existing JIT projects that could somehow be adopted in future PHP releases based on the Zend Engine. If you know about any other interesting JIT solutions, just post a comment telling about them.