3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public $v = "Not destructed"; public static $something = 0; public function __destruct() { print "A destructed\n"; $this->v = "descructed"; $this->x = new B(); A::$something++; B::$something++; C::$something++; } } class B { public $v = "Not destructed"; public static $something = 0; public function __destruct() { print "B destructed\n"; $this->v = "descructed"; $this->x = new C(); A::$something++; B::$something++; C::$something++; } } class C { public $v = "Not destructed"; public static $something = 0; public function __destruct() { print "C destructed\n"; $this->v = "descructed"; $this->x = new A(); A::$something++; B::$something++; C::$something++; } } function use_some_memory() { $a = "paul tarjan "; $as = []; $bs = []; $cs = []; while (count($as) < 10) { $a .= $a; $as[] = new A(); $bs[] = new B(); $cs[] = new C(); } // deliberate_OOM(); } function deliberate_OOM() { $a = "paul tarjan "; $as = []; $bs = []; $cs = []; while (true) { $a .= $a; $as[] = new A(); $bs[] = new B(); $cs[] = new C(); } } function on_shutdown() { print "A::something =" . A::$something . "\n"; print "B::something =" . B::$something . "\n"; print "C::something =" . C::$something . "\n"; } register_shutdown_function('on_shutdown'); $a = new A(); $b = new B(); $c = new C(); use_some_memory();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/o3XFP
function name:  (null)
number of ops:  15
compiled vars:  !0 = $a, !1 = $b, !2 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   76     0  E >   INIT_FCALL                                               'register_shutdown_function'
          1        SEND_VAL                                                 'on_shutdown'
          2        DO_ICALL                                                 
   78     3        NEW                                              $4      'A'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $4
   79     6        NEW                                              $7      'B'
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !1, $7
   80     9        NEW                                              $10     'C'
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !2, $10
   82    12        INIT_FCALL                                               'use_some_memory'
         13        DO_FCALL                                      0          
         14      > RETURN                                                   1

Function use_some_memory:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 5
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 5
Branch analysis from position: 21
Branch analysis from position: 5
filename:       /in/o3XFP
function name:  use_some_memory
number of ops:  22
compiled vars:  !0 = $a, !1 = $as, !2 = $bs, !3 = $cs
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   44     0  E >   ASSIGN                                                   !0, 'paul+tarjan+'
   45     1        ASSIGN                                                   !1, <array>
   46     2        ASSIGN                                                   !2, <array>
   47     3        ASSIGN                                                   !3, <array>
   48     4      > JMP                                                      ->18
   49     5    >   ASSIGN_OP                                     8          !0, !0
   50     6        NEW                                              $10     'A'
          7        DO_FCALL                                      0          
          8        ASSIGN_DIM                                               !1
          9        OP_DATA                                                  $10
   51    10        NEW                                              $13     'B'
         11        DO_FCALL                                      0          
         12        ASSIGN_DIM                                               !2
         13        OP_DATA                                                  $13
   52    14        NEW                                              $16     'C'
         15        DO_FCALL                                      0          
         16        ASSIGN_DIM                                               !3
         17        OP_DATA                                                  $16
   48    18    >   COUNT                                            ~18     !1
         19        IS_SMALLER                                               ~18, 10
         20      > JMPNZ                                                    ~19, ->5
   55    21    > > RETURN                                                   null

End of function use_some_memory

Function deliberate_oom:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 19, Position 2 = 5
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 19, Position 2 = 5
Branch analysis from position: 19
Branch analysis from position: 5
filename:       /in/o3XFP
function name:  deliberate_OOM
number of ops:  20
compiled vars:  !0 = $a, !1 = $as, !2 = $bs, !3 = $cs
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   58     0  E >   ASSIGN                                                   !0, 'paul+tarjan+'
   59     1        ASSIGN                                                   !1, <array>
   60     2        ASSIGN                                                   !2, <array>
   61     3        ASSIGN                                                   !3, <array>
   62     4      > JMP                                                      ->18
   63     5    >   ASSIGN_OP                                     8          !0, !0
   64     6        NEW                                              $10     'A'
          7        DO_FCALL                                      0          
          8        ASSIGN_DIM                                               !1
          9        OP_DATA                                                  $10
   65    10        NEW                                              $13     'B'
         11        DO_FCALL                                      0          
         12        ASSIGN_DIM                                               !2
         13        OP_DATA                                                  $13
   66    14        NEW                                              $16     'C'
         15        DO_FCALL                                      0          
         16        ASSIGN_DIM                                               !3
         17        OP_DATA                                                  $16
   62    18    > > JMPNZ                                                    <true>, ->5
   68    19    > > RETURN                                                   null

End of function deliberate_oom

Function on_shutdown:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/o3XFP
function name:  on_shutdown
number of ops:  13
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   71     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'something'
          1        CONCAT                                           ~1      'A%3A%3Asomething+%3D', ~0
          2        CONCAT                                           ~2      ~1, '%0A'
          3        ECHO                                                     ~2
   72     4        FETCH_STATIC_PROP_R          unknown             ~3      'something'
          5        CONCAT                                           ~4      'B%3A%3Asomething+%3D', ~3
          6        CONCAT                                           ~5      ~4, '%0A'
          7        ECHO                                                     ~5
   73     8        FETCH_STATIC_PROP_R          unknown             ~6      'something'
          9        CONCAT                                           ~7      'C%3A%3Asomething+%3D', ~6
         10        CONCAT                                           ~8      ~7, '%0A'
         11        ECHO                                                     ~8
   74    12      > RETURN                                                   null

End of function on_shutdown

Class A:
Function __destruct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/o3XFP
function name:  __destruct
number of ops:  11
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   ECHO                                                     'A+destructed%0A'
    8     1        ASSIGN_OBJ                                               'v'
          2        OP_DATA                                                  'descructed'
    9     3        NEW                                              $2      'B'
          4        DO_FCALL                                      0          
          5        ASSIGN_OBJ                                               'x'
          6        OP_DATA                                                  $2
   10     7        PRE_INC_STATIC_PROP                                      'something', 'A'
   11     8        PRE_INC_STATIC_PROP                                      'something', 'B'
   12     9        PRE_INC_STATIC_PROP                                      'something', 'C'
   13    10      > RETURN                                                   null

End of function __destruct

End of class A.

Class B:
Function __destruct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/o3XFP
function name:  __destruct
number of ops:  11
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   ECHO                                                     'B+destructed%0A'
   21     1        ASSIGN_OBJ                                               'v'
          2        OP_DATA                                                  'descructed'
   22     3        NEW                                              $2      'C'
          4        DO_FCALL                                      0          
          5        ASSIGN_OBJ                                               'x'
          6        OP_DATA                                                  $2
   23     7        PRE_INC_STATIC_PROP                                      'something', 'A'
   24     8        PRE_INC_STATIC_PROP                                      'something', 'B'
   25     9        PRE_INC_STATIC_PROP                                      'something', 'C'
   26    10      > RETURN                                                   null

End of function __destruct

End of class B.

Class C:
Function __destruct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/o3XFP
function name:  __destruct
number of ops:  11
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   ECHO                                                     'C+destructed%0A'
   34     1        ASSIGN_OBJ                                               'v'
          2        OP_DATA                                                  'descructed'
   35     3        NEW                                              $2      'A'
          4        DO_FCALL                                      0          
          5        ASSIGN_OBJ                                               'x'
          6        OP_DATA                                                  $2
   36     7        PRE_INC_STATIC_PROP                                      'something', 'A'
   37     8        PRE_INC_STATIC_PROP                                      'something', 'B'
   38     9        PRE_INC_STATIC_PROP                                      'something', 'C'
   39    10      > RETURN                                                   null

End of function __destruct

End of class C.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.1 ms | 1411 KiB | 16 Q