Giter VIP home page Giter VIP logo

opcode-analysis's Introduction

PHP Opcode Analysis Kit

A set of Docker images to test out PHP code against the interpreter to see the resulting opcodes with multiple PHP versions.

Usage

Edit the test.php file with the code you would like to test. From there, run the bash/PowerShell script to build the containers and test the code.

Linux

./run.sh

Windows

.\run.ps1

Test File

<?php

$x = 'a';
$y = $x.' b';
echo $y;

$x = 'a';
$y = "$x b";
echo $y;

$x = 'a';
$y = "{$x} b";
echo $y;

Example Output

branch: #  0; line:     3-   14; sop:     0; eop:    14; out1:  -2
path #1: 0,
Finding entry points
Branch analysis from position: 0
Jump found. (Code = 62) Position 1 = -2
filename:       /test.php
function name:  (null)
number of ops:  15
compiled vars:  !0 = $x, !1 = $y
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   ASSIGN                                                   !0, 'a'
   4     1        CONCAT                                           ~1      !0, '+b'
         2        ASSIGN                                                   !1, ~1
   5     3        ECHO                                                     !1
   7     4        ASSIGN                                                   !0, 'a'
   8     5        ADD_VAR                                          ~4      !0
         6        ADD_STRING                                       ~4      ~4, '+b'
         7        ASSIGN                                                   !1, ~4
   9     8        ECHO                                                     !1
  11     9        ASSIGN                                                   !0, 'a'
  12    10        ADD_VAR                                          ~7      !0
        11        ADD_STRING                                       ~7      ~7, '+b'
        12        ASSIGN                                                   !1, ~7
  13    13        ECHO                                                     !1
  14    14      > RETURN                                                   1

Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /test.php
function name:  (null)
number of ops:  15
compiled vars:  !0 = $x, !1 = $y
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   ASSIGN                                                   !0, 'a'
   4     1        CONCAT                                           ~3      !0, '+b'
         2        ASSIGN                                                   !1, ~3
   5     3        ECHO                                                     !1
   7     4        ASSIGN                                                   !0, 'a'
   8     5        NOP
         6        FAST_CONCAT                                      ~6      !0, '+b'
         7        ASSIGN                                                   !1, ~6
   9     8        ECHO                                                     !1
  11     9        ASSIGN                                                   !0, 'a'
  12    10        NOP
        11        FAST_CONCAT                                      ~9      !0, '+b'
        12        ASSIGN                                                   !1, ~9
  13    13        ECHO                                                     !1
  14    14      > RETURN                                                   1

branch: #  0; line:     3-   14; sop:     0; eop:    14; out0:  -2
path #1: 0,
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /test.php
function name:  (null)
number of ops:  15
compiled vars:  !0 = $x, !1 = $y
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   ASSIGN                                                   !0, 'a'
   4     1        CONCAT                                           ~3      !0, '+b'
         2        ASSIGN                                                   !1, ~3
   5     3        ECHO                                                     !1
   7     4        ASSIGN                                                   !0, 'a'
   8     5        NOP
         6        FAST_CONCAT                                      ~6      !0, '+b'
         7        ASSIGN                                                   !1, ~6
   9     8        ECHO                                                     !1
  11     9        ASSIGN                                                   !0, 'a'
  12    10        NOP
        11        FAST_CONCAT                                      ~9      !0, '+b'
        12        ASSIGN                                                   !1, ~9
  13    13        ECHO                                                     !1
  14    14      > RETURN                                                   1

branch: #  0; line:     3-   14; sop:     0; eop:    14; out0:  -2
path #1: 0,
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /test.php
function name:  (null)
number of ops:  15
compiled vars:  !0 = $x, !1 = $y
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   ASSIGN                                                   !0, 'a'
   4     1        CONCAT                                           ~3      !0, '+b'
         2        ASSIGN                                                   !1, ~3
   5     3        ECHO                                                     !1
   7     4        ASSIGN                                                   !0, 'a'
   8     5        NOP
         6        FAST_CONCAT                                      ~6      !0, '+b'
         7        ASSIGN                                                   !1, ~6
   9     8        ECHO                                                     !1
  11     9        ASSIGN                                                   !0, 'a'
  12    10        NOP
        11        FAST_CONCAT                                      ~9      !0, '+b'
        12        ASSIGN                                                   !1, ~9
  13    13        ECHO                                                     !1
  14    14      > RETURN                                                   1

branch: #  0; line:     3-   14; sop:     0; eop:    14; out0:  -2
path #1: 0,

Contributions are always welcome and happy testing!

opcode-analysis's People

Contributors

codysnider avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.