3v4l.org

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