3v4l.org

run code in 500+ PHP versions simultaneously
<?php var_dump(ini_get('memory_limit')); $i = 0; $fx = function (int $fiberNumber): void { $res = array_map(function ($str) use ($fiberNumber) { global $i, $fx, $fibers; if (($i++ % 1_000) === 0) { var_dump($i . ' @' . $fiberNumber); return $fibers[$fiberNumber + 1]->start(); } if ($i > 50_000) { return $fiberNumber; } return $fx($fiberNumber); }, ['x']); Fiber::suspend($res); }; $fibers = []; foreach (range(0, 99) as $fi) { $fibers[] = new Fiber(fn() => $fx($fi)); } $res = $fibers[0]->start(); print_r($res);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 25
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 25
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/JfYeZ
function name:  (null)
number of ops:  34
compiled vars:  !0 = $i, !1 = $fx, !2 = $fibers, !3 = $fi, !4 = $res
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                                   'var_dump'
          1        INIT_FCALL                                                   'ini_get'
          2        SEND_VAL                                                     'memory_limit'
          3        DO_ICALL                                             $5      
          4        SEND_VAR                                                     $5
          5        DO_ICALL                                                     
    5     6        ASSIGN                                                       !0, 0
    7     7        DECLARE_LAMBDA_FUNCTION                              ~8      [0]
          8        ASSIGN                                                       !1, ~8
   25     9        ASSIGN                                                       !2, <array>
   26    10        INIT_FCALL                                                   'range'
         11        SEND_VAL                                                     0
         12        SEND_VAL                                                     99
         13        DO_ICALL                                             $11     
         14      > FE_RESET_R                                           $12     $11, ->25
         15    > > FE_FETCH_R                                                   $12, !3, ->25
   27    16    >   NEW                                                  $14     'Fiber'
         17        DECLARE_LAMBDA_FUNCTION                              ~15     [1]
         18        BIND_LEXICAL                                                 ~15, !1
         19        BIND_LEXICAL                                                 ~15, !3
         20        SEND_VAL_EX                                                  ~15
         21        DO_FCALL                                          0          
         22        ASSIGN_DIM                                                   !2
         23        OP_DATA                                                      $14
   26    24      > JMP                                                          ->15
         25    >   FE_FREE                                                      $12
   30    26        FETCH_DIM_R                                          ~17     !2, 0
         27        INIT_METHOD_CALL                                             ~17, 'start'
         28        DO_FCALL                                          0  $18     
         29        ASSIGN                                                       !4, $18
   32    30        INIT_FCALL                                                   'print_r'
         31        SEND_VAR                                                     !4
         32        DO_ICALL                                                     
         33      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JfYeZ
function name:  {closure:/in/JfYeZ:7}
number of ops:  12
compiled vars:  !0 = $fiberNumber, !1 = $res
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   RECV                                                 !0      
    8     1        INIT_FCALL                                                   'array_map'
          2        DECLARE_LAMBDA_FUNCTION                              ~2      [0]
          3        BIND_LEXICAL                                                 ~2, !0
   20     4        SEND_VAL                                                     ~2
          5        SEND_VAL                                                     <array>
    8     6        DO_ICALL                                             $3      
          7        ASSIGN                                                       !1, $3
   22     8        INIT_STATIC_METHOD_CALL                                      'Fiber', 'suspend'
          9        SEND_VAR                                                     !1
         10        DO_FCALL                                          0          
   23    11      > RETURN                                                       null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 19
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 22
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JfYeZ
function name:  {closure:{closure:/in/JfYeZ:7}:8}
number of ops:  27
compiled vars:  !0 = $str, !1 = $fiberNumber, !2 = $i, !3 = $fx, !4 = $fibers
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    8     0  E >   RECV                                                 !0      
          1        BIND_STATIC                                                  !1
    9     2        BIND_GLOBAL                                                  !2, 'i'
          3        BIND_GLOBAL                                                  !3, 'fx'
          4        BIND_GLOBAL                                                  !4, 'fibers'
   10     5        POST_INC                                             ~5      !2
          6        MOD                                                  ~6      ~5, 1000
          7        IS_IDENTICAL                                                 ~6, 0
          8      > JMPZ                                                         ~7, ->19
   11     9    >   INIT_FCALL                                                   'var_dump'
         10        CONCAT                                               ~8      !2, '+%40'
         11        CONCAT                                               ~9      ~8, !1
         12        SEND_VAL                                                     ~9
         13        DO_ICALL                                                     
   12    14        ADD                                                  ~11     !1, 1
         15        FETCH_DIM_R                                          ~12     !4, ~11
         16        INIT_METHOD_CALL                                             ~12, 'start'
         17        DO_FCALL                                          0  $13     
         18      > RETURN                                                       $13
   15    19    >   IS_SMALLER                                                   50000, !2
         20      > JMPZ                                                         ~14, ->22
   16    21    > > RETURN                                                       !1
   19    22    >   INIT_DYNAMIC_CALL                                            !3
         23        SEND_VAR_EX                                                  !1
         24        DO_FCALL                                          0  $15     
         25      > RETURN                                                       $15
   20    26*     > RETURN                                                       null

End of Dynamic Function 0

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JfYeZ
function name:  {closure:/in/JfYeZ:27}
number of ops:  7
compiled vars:  !0 = $fx, !1 = $fi
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   27     0  E >   BIND_STATIC                                                  !0
          1        BIND_STATIC                                                  !1
          2        INIT_DYNAMIC_CALL                                            !0
          3        SEND_VAR_EX                                                  !1
          4        DO_FCALL                                          0  $2      
          5      > RETURN                                                       $2
          6*     > RETURN                                                       null

End of Dynamic Function 1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
141.78 ms | 491 KiB | 12 Q