Skip to content

Commit 13c8d93

Browse files
committed
Merge branch 'PHP-8.3'
2 parents 345580c + f52b2a9 commit 13c8d93

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

ext/opcache/jit/zend_jit_ir.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9878,7 +9878,10 @@ static int zend_jit_do_fcall(zend_jit_ctx *jit, const zend_op *opline, const zen
98789878
}
98799879

98809880
if (ZEND_OBSERVER_ENABLED) {
9881-
if (GCC_GLOBAL_REGS) {
9881+
if (trace && (trace->op != ZEND_JIT_TRACE_END || trace->stop != ZEND_JIT_TRACE_STOP_INTERPRETER)) {
9882+
ZEND_ASSERT(trace[1].op == ZEND_JIT_TRACE_VM || trace[1].op == ZEND_JIT_TRACE_END);
9883+
jit_SET_EX_OPLINE(jit, trace[1].opline);
9884+
} else if (GCC_GLOBAL_REGS) {
98829885
// EX(opline) = opline
98839886
ir_STORE(jit_EX(opline), jit_IP(jit));
98849887
}

ext/opcache/tests/jit/gh13772.phpt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
EX(opline) is correctly set for nested JIT user code calls
3+
--EXTENSIONS--
4+
opcache
5+
zend_test
6+
--INI--
7+
opcache.enable=1
8+
opcache.enable_cli=1
9+
zend_test.observer.enabled=1
10+
zend_test.observer.observe_all=1
11+
zend_test.observer.show_output=0
12+
--FILE--
13+
<?php
14+
15+
function Ack($m, $n) {
16+
if ($m == 0) return $n+1;
17+
if ($n == 0) return Ack($m-1, 1);
18+
return Ack($m - 1, Ack($m, ($n - 1)));
19+
}
20+
21+
var_dump(Ack(3, 3));
22+
23+
?>
24+
--EXPECT--
25+
int(61)
26+

ext/zend_test/observer.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,16 @@ static void observer_show_opcode(zend_execute_data *execute_data)
6767
php_printf("%*s<!-- opcode: '%s' -->\n", 2 * ZT_G(observer_nesting_depth), "", zend_get_opcode_name(EX(opline)->opcode));
6868
}
6969

70+
static inline void assert_observer_opline(zend_execute_data *execute_data) {
71+
ZEND_ASSERT(!ZEND_USER_CODE(EX(func)->type) ||
72+
(EX(opline) >= EX(func)->op_array.opcodes && EX(opline) < EX(func)->op_array.opcodes + EX(func)->op_array.last) ||
73+
(EX(opline) >= EG(exception_op) && EX(opline) < EG(exception_op) + 3));
74+
}
75+
7076
static void observer_begin(zend_execute_data *execute_data)
7177
{
78+
assert_observer_opline(execute_data);
79+
7280
if (!ZT_G(observer_show_output)) {
7381
return;
7482
}
@@ -112,6 +120,8 @@ static void get_retval_info(zval *retval, smart_str *buf)
112120

113121
static void observer_end(zend_execute_data *execute_data, zval *retval)
114122
{
123+
assert_observer_opline(execute_data);
124+
115125
if (!ZT_G(observer_show_output)) {
116126
return;
117127
}

0 commit comments

Comments
 (0)