Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP - Just in time compiler Vs Interpreter

PHP is a general-purpose server side scripting language. It is well known that the php code are interpreted when the page loads and resulting webpage is shown. Recently I have heard of Just in time compilers for PHP(HipHop Virtual Machine). would like to know what kind of difference would it make in the execution and is it better to have a jit instead of interpreter? are the any php engines that have jit ?

EDIT: Is PHP Execution flow like this ?: php code -> parsing -> tokens -> bytecode/opcode -> php engine interpretation -> machine code -> execution

Corect me if I am wrong. Bytecodes are generally executed in virtual machines. An Opcode( is close to machine language) can be executed by machine directly. Does this mean a php engine is a virtual machine or just some implementations of it are virtual machines?

Thanks in Advance.

like image 474
sriram_adapa Avatar asked May 02 '12 10:05

sriram_adapa


1 Answers

HipHop is not a JIT compiler - it's a code converter which changes PHP into C++ which can then be compiled using a conventional offline compiler.

As a result, eval and create_function won't work, nor the tokenizer functions. I've not looked into the matter deeply, but I would expect that conditional / runtime evaluated include operations will likely cause problems too.

There wouldn't be much point unless it made the code much faster.

OTOH using a PHP opcode cache gives a huge performance boost (not quite as much as native code) without compromising functionality.

(given the architecture off PHP a JIT compiler doesn't really make a lot of sense)

like image 119
symcbean Avatar answered Sep 23 '22 17:09

symcbean