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

From: Date: Tue, 27 Oct 2026 21:34:38 +0000
Subject: [php-src] master: Merge branch 'PHP-8.6'
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-142859@lists.php.net to get a copy of this message
Author: Jorg Sowa (jorgsowa) Date: 2026-10-27T22:33:06+01:00 Commit: https://github.com/php/php-src/commit/6d2196792c284ceba5b67fea07833a1cf980cbfe Raw diff: https://github.com/php/php-src/commit/6d2196792c284ceba5b67fea07833a1cf980cbfe.diff Merge branch 'PHP-8.6' * PHP-8.6: Fix JIT SWITCH_STRING type checks on referenced operand Changed paths: A ext/opcache/tests/jit/switch_002.phpt A ext/opcache/tests/jit/switch_003.phpt M ext/opcache/jit/zend_jit_ir.c Diff: diff --git a/ext/opcache/jit/zend_jit_ir.c b/ext/opcache/jit/zend_jit_ir.c index 63ebcb47553c..045a3d7b0251 100644 --- a/ext/opcache/jit/zend_jit_ir.c +++ b/ext/opcache/jit/zend_jit_ir.c @@ -16696,7 +16696,7 @@ static int zend_jit_switch(zend_jit_ctx *jit, const zend_op *opline, const zend_ if (fallback_label) { jit_guard_Z_TYPE(jit, op1_addr, IS_REFERENCE, fallback_label); } else { - ir_ref if_ref = jit_if_Z_TYPE(jit, op1_addr, IS_STRING); + ir_ref if_ref = jit_if_Z_TYPE(jit, op1_addr, IS_REFERENCE); ir_IF_FALSE_cold(if_ref); ir_refs_add(slow_inputs, ir_END()); ir_IF_TRUE(if_ref); @@ -16706,7 +16706,7 @@ static int zend_jit_switch(zend_jit_ctx *jit, const zend_op *opline, const zend_ op1_addr = ZEND_ADDR_REF_ZVAL(ref2); if (fallback_label) { - jit_guard_Z_TYPE(jit, op1_addr, IS_LONG, fallback_label); + jit_guard_Z_TYPE(jit, op1_addr, IS_STRING, fallback_label); } else { if_string = jit_if_Z_TYPE(jit, op1_addr, IS_STRING); ir_IF_FALSE_cold(if_string); diff --git a/ext/opcache/tests/jit/switch_002.phpt b/ext/opcache/tests/jit/switch_002.phpt new file mode 100644 index 000000000000..580a1134c22e --- /dev/null +++ b/ext/opcache/tests/jit/switch_002.phpt @@ -0,0 +1,27 @@ +--TEST-- +JIT SWITCH_STRING on a reference holding a non-string value +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.file_update_protection=0 +opcache.jit=tracing +opcache.jit_hot_loop=1 +--EXTENSIONS-- +opcache +--FILE-- +<?php +function test($a) { + $n = 0; + foreach ($a as &$x) { + switch ($x) { + case "a": case "b": $n++; break; + } + } + return $n; +} +var_dump(test(["a"])); +var_dump(test([1])); +?> +--EXPECT-- +int(1) +int(0) diff --git a/ext/opcache/tests/jit/switch_003.phpt b/ext/opcache/tests/jit/switch_003.phpt new file mode 100644 index 000000000000..2a33f6dac457 --- /dev/null +++ b/ext/opcache/tests/jit/switch_003.phpt @@ -0,0 +1,26 @@ +--TEST-- +JIT SWITCH_STRING on a reference (function JIT) +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.file_update_protection=0 +opcache.jit=function +--EXTENSIONS-- +opcache +--FILE-- +<?php +function test($a) { + $n = 0; + foreach ($a as &$x) { + switch ($x) { + case "a": case "b": $n++; break; + } + } + return $n; +} +var_dump(test(["a", "b", "c"])); +var_dump(test([1])); +?> +--EXPECT-- +int(2) +int(0)

« previous php.cvs (#142859) next »