-
Notifications
You must be signed in to change notification settings - Fork 33
Description
Currently, this project targets being a drop-in replacement for PHP-SRC, implementing a JIT compiler and virtual machine, as well as AOT compilation. This would allow users to drop-in replace their current systems with no deployment mechanism change (just like HHVM did). If they want to change the deployment mechanism they can to achieve some gains, but it would work out-of-the-box.
However, AOT compilation requires a few steps that JIT/VM do not, and JIT/VM would need to make some assumptions that AOT does not. For example:
- AOT requires a mechanism for traversing an entire codebase to find all classes/files that could be required, and compiling them all. This would also require a mechanism to tell the compiler to not compile certain files.
- JIT compilation could happen only on functions/classes, and would by definition leave require/include to the VM. Where AOT MUST support include/require.
- JIT would by definition have access to any function/class at call time (accounting for autoloading), but AOT may not (since conditional function declarations wouldn't have happened since AOT doesn't execute before compilation).
- Dynamic language features (
eval, etc) can be handled in JIT code by kicking back to the VM, but with AOT code it would either need to error on such code, or embed the compiler to attempt to "JIT" the dynamic code. - etc...
Proposal
The idea that I'm thinking about is removing the VM from the compiler. There would then be two modes: JIT and AOT.
However JIT mode would be very different from what people normally consider JIT. It would be basically "AOT Compile and Execute In Process" vs the AOT mode which is "AOT Compile and generate an executable to be run later".
The JIT mode would allow something that "feels" like normal PHP (just run jit file.php and it will execute just like PHP-SRC does), but takes a lot longer to boot (since it's doing a full compilation pass). But once it's booted, it's running native compiled code.
It also would allow the AOT mode to embed the JIT mode in the executable to handle cases of dynamic code (again, eval(), etc). So if compiled code called eval, internally in the executable it would compile the evaled code to native and then run it inside the process.
The prime benefits would be to greatly simply the compiler as well as focus on only the major differentiating mode from PHP-SRC. The prime detriment would be losing the ability to "drop-in" replace PHP-SRC (which would really hurt adoption significantly).
Request for Comments
The change from a VM primary compiler to a AOT primary compiler has a lot of side-effects. It makes it so the project doesn't aim to be a drop-in replacement for PHP-SRC. However, by doing that, it removes performance constraints around the compile step and opens the door to significant potential performance gains for compiled code (at execution phase).
So, I'd like to ask for comments and votes. Should the project aim to be a drop-in replacement for PHP-SRC? Or should we ditch the dynamic aspect and go for pure performance at the expense of compile time and deployment mechanisms.
Please vote with "reactions": Rocket ship means move to AOT, eyes for keep the VM.