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

From: Date: Sat, 31 Oct 2026 15:16:10 +0000
Subject: [php-src] PHP-8.6: Merge branch 'PHP-8.5' into PHP-8.6
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-143069@lists.php.net to get a copy of this message
Author: Jorg Sowa (jorgsowa) Date: 2026-10-31T16:00:13+01:00 Commit: https://github.com/php/php-src/commit/7412af20813d467092c77e9f99f434819c3fd0d0 Raw diff: https://github.com/php/php-src/commit/7412af20813d467092c77e9f99f434819c3fd0d0.diff Merge branch 'PHP-8.5' into PHP-8.6 Changed paths: A ext/opcache/tests/jit/preload_restart_hot_counters.phpt M NEWS M ext/opcache/jit/zend_jit.c Diff: diff --git a/NEWS b/NEWS index c16e79474252..519a9b22c5f9 100644 --- a/NEWS +++ b/NEWS @@ -124,6 +124,8 @@ PHP NEWS when zend_interrupt_function resets EG(vm_interrupt). (Levi Morrison) . Fix JIT losing the called scope of self::/parent:: calls in included files. (ndossche) + . Fixed preloaded functions not JIT-compiled again after OPcache restart. + (Jorg Sowa) - OpenSSL: . Fixed build with OpenSSL 4.1. (Weilin Du) diff --git a/ext/opcache/jit/zend_jit.c b/ext/opcache/jit/zend_jit.c index 730bb13c895f..fbfde39863ac 100644 --- a/ext/opcache/jit/zend_jit.c +++ b/ext/opcache/jit/zend_jit.c @@ -3296,6 +3296,8 @@ static int zend_jit_restart_hot_counters(zend_op_array *op_array) uint32_t i; jit_extension = (zend_jit_op_array_hot_extension*)ZEND_FUNC_INFO(op_array); + /* The JIT-ed code is gone, so allow compiling it again */ + jit_extension->func_info.flags &= ~ZEND_FUNC_JITED; for (i = 0; i < op_array->last; i++) { op_array->opcodes[i].handler = jit_extension->orig_handlers[i]; } diff --git a/ext/opcache/tests/jit/preload_restart_hot_counters.phpt b/ext/opcache/tests/jit/preload_restart_hot_counters.phpt new file mode 100644 index 000000000000..8f6af56b1671 --- /dev/null +++ b/ext/opcache/tests/jit/preload_restart_hot_counters.phpt @@ -0,0 +1,76 @@ +--TEST-- +Preloaded functions JIT-compiled by hot counters must be JIT-compiled again after an OPcache restart +--EXTENSIONS-- +opcache +--SKIPIF-- +<?php +if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows'); +if (ini_get('opcache.jit') === false) die('skip PHP is compiled without JIT'); +?> +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.jit=1235 +opcache.jit_buffer_size=16M +--CONFLICTS-- +server +--FILE-- +<?php +$dir = __DIR__ . '/preload_restart_hot_counters'; +@mkdir($dir); + +file_put_contents($dir . '/preload.php', <<<'PHP' +<?php +function preloaded_sum(int $n): int { + $s = 0; + for ($i = 0; $i < $n; $i++) { + $s += ($i * 3) ^ ($i >> 2); + } + return $s; +} +PHP); + +/* A dynamic call keeps the function out of the call graph of the calling script */ +file_put_contents($dir . '/call.php', <<<'PHP' +<?php +$f = 'preloaded_sum'; +echo $f(1000), "\n"; +PHP); + +file_put_contents($dir . '/reset.php', <<<'PHP' +<?php +var_dump(opcache_get_status()['jit']['on']); +var_dump(opcache_reset()); +PHP); + +include __DIR__ . '/../php_cli_server.inc'; + +$ini = '-d opcache.enable=1 -d opcache.enable_cli=1 -d opcache.jit=1235 -d opcache.jit_buffer_size=16M' + . ' -d opcache.jit_hot_func=1 -d opcache.validate_timestamps=0 -d opcache.file_update_protection=0' + . ' -d opcache.preload_user=root -d opcache.preload=' . $dir . '/preload.php'; +$opcache = ini_get('extension_dir') . '/opcache.' . PHP_SHLIB_SUFFIX; +if (file_exists($opcache)) { + $ini .= ' -d zend_extension=' . $opcache; +} +php_cli_server_start($ini); + +$base = 'http://' . PHP_CLI_SERVER_ADDRESS . '/jit/preload_restart_hot_counters/'; +$context = stream_context_create(['http' => ['timeout' => 5]]); +foreach (['call', 'reset', 'call', 'call'] as $script) { + echo @file_get_contents($base . $script . '.php', false, $context) ?: "no response\n"; +} +?> +--CLEAN-- +<?php +$dir = __DIR__ . '/preload_restart_hot_counters'; +foreach (['preload', 'call', 'reset'] as $script) { + @unlink("$dir/$script.php"); +} +@rmdir($dir); +?> +--EXPECT-- +1502868 +bool(true) +bool(true) +1502868 +1502868

« previous php.cvs (#143069) next »