3v4l.org

run code in 300+ PHP versions simultaneously
<?php function igorRetry($retries, callable $fn) { beginning: try { return $fn(); } catch (\Exception $e) { if (!$retries) { throw new \Exception('', 0, $e); } $retries--; goto beginning; } } $fn = function() { if ($GLOBALS['counter'] > 0) { $GLOBALS['counter']--; throw new \Exception('Try again'); } return 'something successfull'; }; $start = microtime(true); try { $GLOBALS['counter'] = 999999; igorRetry(1000000, $fn); } catch (\Exception $e) {} echo 'Igor retry finished in: ' . (microtime(true) -$start) . "\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 14
Branch analysis from position: 14
2 jumps found. (Code = 107) Position 1 = 15, Position 2 = -2
Branch analysis from position: 15
filename:       /in/Y1dqr
function name:  (null)
number of ops:  23
compiled vars:  !0 = $fn, !1 = $start, !2 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FY1dqr%3A17%240'
          1        ASSIGN                                                   !0, ~3
   28     2        INIT_FCALL                                               'microtime'
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $5      
          5        ASSIGN                                                   !1, $5
   30     6        FETCH_W                      global              $7      'GLOBALS'
          7        ASSIGN_DIM                                               $7, 'counter'
          8        OP_DATA                                                  999999
   31     9        INIT_FCALL                                               'igorretry'
         10        SEND_VAL                                                 1000000
         11        SEND_VAR                                                 !0
         12        DO_FCALL                                      0          
         13      > JMP                                                      ->15
   32    14  E > > CATCH                                       last         'Exception'
   33    15    >   INIT_FCALL                                               'microtime'
         16        SEND_VAL                                                 <true>
         17        DO_ICALL                                         $10     
         18        SUB                                              ~11     $10, !1
         19        CONCAT                                           ~12     'Igor+retry+finished+in%3A+', ~11
         20        CONCAT                                           ~13     ~12, '%0A'
         21        ECHO                                                     ~13
         22      > RETURN                                                   1

Function igorretry:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 7
Branch analysis from position: 7
2 jumps found. (Code = 107) Position 1 = 8, Position 2 = -2
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 16
Branch analysis from position: 10
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
filename:       /in/Y1dqr
function name:  igorRetry
number of ops:  19
compiled vars:  !0 = $retries, !1 = $fn, !2 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    6     2    >   NOP                                                      
    7     3        INIT_DYNAMIC_CALL                                        !1
          4        DO_FCALL                                      0  $3      
          5      > RETURN                                                   $3
          6*       JMP                                                      ->18
    8     7  E > > CATCH                                       last         'Exception'
    9     8    >   BOOL_NOT                                         ~4      !0
          9      > JMPZ                                                     ~4, ->16
   10    10    >   NEW                                              $5      'Exception'
         11        SEND_VAL_EX                                              ''
         12        SEND_VAL_EX                                              0
         13        SEND_VAR_EX                                              !2
         14        DO_FCALL                                      0          
         15      > THROW                                         0          $5
   12    16    >   PRE_DEC                                                  !0
   13    17      > JMP                                                      ->2
   15    18*     > RETURN                                                   null

End of function igorretry

Function %00%7Bclosure%7D%2Fin%2FY1dqr%3A17%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 11
Branch analysis from position: 4
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Y1dqr
function name:  {closure}
number of ops:  13
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   FETCH_R                      global              ~0      'GLOBALS'
          1        FETCH_DIM_R                                      ~1      ~0, 'counter'
          2        IS_SMALLER                                               0, ~1
          3      > JMPZ                                                     ~2, ->11
   20     4    >   FETCH_RW                     global              $3      'GLOBALS'
          5        FETCH_DIM_RW                                     $4      $3, 'counter'
          6        PRE_DEC                                                  $4
   21     7        NEW                                              $6      'Exception'
          8        SEND_VAL_EX                                              'Try+again'
          9        DO_FCALL                                      0          
         10      > THROW                                         0          $6
   23    11    > > RETURN                                                   'something+successfull'
   24    12*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FY1dqr%3A17%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.56 ms | 1403 KiB | 16 Q