Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP zend byte code reference?

is there any document which describes the byte code instruction structure of php zend vm??

there are opcode numbers and names at the php website but I want to know more detailed structures such as operand size or syntax..

is there any document for zend vm bytecode such as flash bytecode document, or intel instruction reference manual or java bytecode manual??

thank you in advance

like image 985
daehee Avatar asked Dec 11 '13 06:12

daehee


1 Answers

Detailed information can be directly found inside the source code of the Zend VM:

https://github.com/php/php-src/blob/master/Zend/zend_vm_gen.php

For each Zend VM operation, there is a native C function to run, and it is given either 0, 1 or 2 operands. After completing the operation, it gives a result plus any additional information. Also, the operation holds information on the types of any operands passed in, the result type and the opcode.

(source: https://x-team.com/blog/learn-about-php-opcodes)

However, it can be very difficult to understand any specific usage case. A possible solution could be to install the Vulcan Logic Disassembler (vld) extension. The vld hooks into the Zend Engine and dumps all the opcodes of a script.

(source: https://ctors.net/2015/09/11/php_opcodes)

With this extension it is possible to dump opcodes and the internal representation of PHP scripts. While still in beta, version 0.14.0 released in 2016 also supports PHP 7.0 and 7.1.

Latest development source code and installation instructions can be found in the author's Github repository:

https://github.com/derickr/vld

like image 69
luigif Avatar answered Sep 21 '22 12:09

luigif