Re: PHP Just-In-Time Compiler
| From: | Patrick Mueller | Date: | Thu, 08 Mar 2007 14:18:16 +0000 |
| Subject: | Re: PHP Just-In-Time Compiler | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-28295@lists.php.net to get a copy of this message | ||
Rasmus Lerdorf wrote:
This comes up once or twice a year. The machine code you compile to is going to end up looking a lot like the current executor since you don't have strong types to help you optimize anything. You'd still need to pass the unions around and do runtime type juggling and all the overhead that comes along with that.Strict typing is not required for JIT-level optimization. See: Smalltalk, Self, Strongtalk, Tamarin. The Strongtalk guys, who have a stricter-than-usual typed Smalltalk implementation, and a pretty good JIT, actually ignore the type information during JIT analysis.
The idea behind PHP from day one was that it was an environment for wrapping compiled code. Things that are performance critical is written in C/C++ and things that aren't are left in the PHP templates. Whether you issue an SQL query from PHP or from a compiled C program doesn't affect the overall performance of the system so you might as well do that from PHP.And since day one, people have been building big ole PHP libraries ... :-) For someone seriously interested in looking into this, there are some 'free' JITs available from the following projects: Apache Harmony (an Apache licensed J2SE implementation), StrongTalk (Smalltalk), Adobe Tamarin (recently donated to Mozilla), and Sun's HotSpot (Java; curiously, HotSpot was based on StrongTalk!). -- Patrick_Mueller@us.ibm.com IBM PHP Community Architect, IBM Research Triangle Park