[php-src] master: Merge branch 'PHP-8.5' into PHP-8.6

From: Date: Wed, 04 Nov 2026 21:42:04 +0000
Subject: [php-src] master: Merge branch 'PHP-8.5' into PHP-8.6
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-143333@lists.php.net to get a copy of this message
Author: Ilia Alshanetsky (iliaal) Date: 2026-11-04T16:37:47-05:00 Commit: https://github.com/php/php-src/commit/f52903dd035fdb9be6381275800aba712d560bb9 Raw diff: https://github.com/php/php-src/commit/f52903dd035fdb9be6381275800aba712d560bb9.diff Merge branch 'PHP-8.5' into PHP-8.6 * PHP-8.5: ext/opcache: Fix GH-25164 loop liveness across calls # Conflicts: # ext/opcache/jit/zend_jit.c # ext/opcache/jit/zend_jit_ir.c Changed paths: A ext/opcache/tests/jit/gh25164.phpt M NEWS M ext/opcache/jit/zend_jit.c M ext/opcache/jit/zend_jit_ir.c Diff: diff --git a/NEWS b/NEWS index d04ed034619d..1f255dff5316 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,8 @@ PHP NEWS (Daisuke Komazaki) . Fixed bug GH-25165 (Tracing JIT loops forever once opcache.jit_buffer_size is exhausted while compiling side traces). (Ilia Alshanetsky) + . Fixed bug GH-25164 (Function JIT loop calling a user function runs once + or never terminates). (Ilia Alshanetsky) 05 Nov 2026, PHP 8.6.0RC5 diff --git a/ext/opcache/jit/zend_jit.c b/ext/opcache/jit/zend_jit.c index 28e6f1e8217e..ff40b1380a64 100644 --- a/ext/opcache/jit/zend_jit.c +++ b/ext/opcache/jit/zend_jit.c @@ -1198,7 +1198,8 @@ static void zend_jit_allocate_registers(zend_jit_ctx *ctx, const zend_op_array * ra[src].flags |= ZREG_STORE; } } else { - int need_move = 0; + /* The VM may enter an ENTRY block, so its Phi sources must go through memory */ + int need_move = (ssa->cfg.blocks[phi->block].flags & (ZEND_BB_ENTRY|ZEND_BB_RECV_ENTRY)) != 0; uint32_t k; for (k = 0; k < ssa->cfg.blocks[phi->block].predecessors_count; k++) { diff --git a/ext/opcache/jit/zend_jit_ir.c b/ext/opcache/jit/zend_jit_ir.c index 266f36269bd8..7f375e04d13c 100644 --- a/ext/opcache/jit/zend_jit_ir.c +++ b/ext/opcache/jit/zend_jit_ir.c @@ -17887,6 +17887,7 @@ static bool zend_jit_may_be_in_reg(const zend_op_array *op_array, zend_ssa *ssa, zend_basic_block *bb; zend_ssa_phi *p; bool ret = true; + bool def_is_pi = false; zend_worklist worklist; ALLOCA_FLAG(use_heap) @@ -17896,6 +17897,7 @@ static bool zend_jit_may_be_in_reg(const zend_op_array *op_array, zend_ssa *ssa, } else { ZEND_ASSERT(ssa->vars[var].definition_phi); def_block = ssa->vars[var].definition_phi->block; + def_is_pi = ssa->vars[var].definition_phi->pi >= 0; } ZEND_WORKLIST_ALLOCA(&worklist, ssa->cfg.blocks_count, use_heap); @@ -17913,9 +17915,14 @@ static bool zend_jit_may_be_in_reg(const zend_op_array *op_array, zend_ssa *ssa, p = ssa->vars[var].phi_use_chain; while (p) { - use_block = p->block; - if (use_block != def_block) { - bb = &ssa->cfg.blocks[use_block]; + bb = &ssa->cfg.blocks[p->block]; + if (p->pi >= 0) { + /* A Pi uses the value on the single edge from its "pi" block */ + if (p->pi != def_block) { + zend_worklist_push(&worklist, p->pi); + } + } else if (p->block != def_block || !def_is_pi) { + /* Live to the end of the predecessor; a same-block Pi is zero-length */ for (j = 0; j < bb->predecessors_count; j++) { if (p->sources[j] == var) { use_block = ssa->cfg.predecessors[bb->predecessor_offset + j]; diff --git a/ext/opcache/tests/jit/gh25164.phpt b/ext/opcache/tests/jit/gh25164.phpt new file mode 100644 index 000000000000..1809b89775b9 --- /dev/null +++ b/ext/opcache/tests/jit/gh25164.phpt @@ -0,0 +1,45 @@ +--TEST-- +GH-25164 (JIT: loop variable kept in a register across a user function call) +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.file_update_protection=0 +opcache.jit_buffer_size=64M +opcache.jit=function +--EXTENSIONS-- +opcache +--FILE-- +<?php + +function leaf() { + static $calls = 0; + if (++$calls > 20) { + die("runaway loop\n"); + } + echo "a"; +} + +function driver() { + $i = 0; + while ($i++ < 5) { + leaf(); + } + return $i; +} + +function driver2() { + $i = 0; + while ((($i = ($i + 3) & 15) | 0) != 9) { + leaf(); + echo "-"; + } + return $i; +} + +var_dump(driver()); +var_dump(driver2()); + +?> +--EXPECT-- +aaaaaint(6) +a-a-int(9)

« previous php.cvs (#143333) next »