3v4l.org

run code in 300+ PHP versions simultaneously
<?php function xrange() { for ($i = 0; $i < 1000; $i++) { yield $i; } } $range = xrange(); echo "first\n"; $j = 0; foreach ($range as $i) { if ($j++ >= 500) { break; } } echo "second ($j)\n"; foreach ($range as $i) {}
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 12
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 12
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 11
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
2 jumps found. (Code = 77) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
2 jumps found. (Code = 78) Position 1 = 19, Position 2 = 20
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 12
Branch analysis from position: 12
filename:       /in/u1OG2
function name:  (null)
number of ops:  22
compiled vars:  !0 = $range, !1 = $j, !2 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   INIT_FCALL                                               'xrange'
          1        DO_FCALL                                      0  $3      
          2        ASSIGN                                                   !0, $3
   10     3        ECHO                                                     'first%0A'
   11     4        ASSIGN                                                   !1, 0
   12     5      > FE_RESET_R                                       $6      !0, ->12
          6    > > FE_FETCH_R                                               $6, !2, ->12
   13     7    >   POST_INC                                         ~7      !1
          8        IS_SMALLER_OR_EQUAL                                      500, ~7
          9      > JMPZ                                                     ~8, ->11
   14    10    > > JMP                                                      ->12
   12    11    > > JMP                                                      ->6
         12    >   FE_FREE                                                  $6
   17    13        ROPE_INIT                                     3  ~10     'second+%28'
         14        ROPE_ADD                                      1  ~10     ~10, !1
         15        ROPE_END                                      2  ~9      ~10, '%29%0A'
         16        ECHO                                                     ~9
   18    17      > FE_RESET_R                                       $12     !0, ->20
         18    > > FE_FETCH_R                                               $12, !2, ->20
         19    > > JMP                                                      ->18
         20    >   FE_FREE                                                  $12
         21      > RETURN                                                   1

Function xrange:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 7, Position 2 = 3
Branch analysis from position: 7
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 7, Position 2 = 3
Branch analysis from position: 7
Branch analysis from position: 3
filename:       /in/u1OG2
function name:  xrange
number of ops:  8
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   GENERATOR_CREATE                                         
    4     1        ASSIGN                                                   !0, 0
          2      > JMP                                                      ->5
    5     3    >   YIELD                                                    !0
    4     4        PRE_INC                                                  !0
          5    >   IS_SMALLER                                               !0, 1000
          6      > JMPNZ                                                    ~4, ->3
    7     7    > > GENERATOR_RETURN                                         

End of function xrange

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.77 ms | 1403 KiB | 14 Q