1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00
Files
archived-php-src/ext/opcache/tests/jit/gh19493-001.phpt
Arnaud Le Blanc bc05bfe7c5 Fit JIT variable not stored before YIELD
JIT doesn't recognize that variables may be used after returning from a
trace due to YIELD, so some effects may never be stored to memory.

YIELD ops terminate trace recordings with ZEND_JIT_TRACE_STOP_RETURN, and are
handled mostly like RETURN. Here I change zend_jit_trace_execute() so that
YIELD terminates recordings with ZEND_JIT_TRACE_STOP_INTERPRETER instead,
to ensure that we recognize that variables may be used after returning from
the trace due to YIELD.

Fixes GH-19493
Closes GH-19515
2025-08-19 15:49:29 +02:00

25 lines
364 B
PHP

--TEST--
GH-19493 001: Var not stored before YIELD
--FILE--
<?php
function f() {
$offset = 0;
yield true;
for ($i = 0; $i < 100; $i++) {
$offset++;
if ($offset === 99) {
break;
}
yield true;
}
return $offset;
}
$gen = f();
foreach ($gen as $v) {}
var_dump($gen->getReturn());
?>
--EXPECT--
int(99)