Skip to content

Commit 5a08577

Browse files
committed
Fixed incorrect JIT for FETCH_THIS+SEND_REF
1 parent ddd99a7 commit 5a08577

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10136,13 +10136,16 @@ static int zend_jit_send_ref(dasm_State **Dst, const zend_op *opline, const zend
1013610136
|2:
1013710137
| // ZVAL_NEW_REF(arg, varptr);
1013810138
if (opline->op1_type == IS_VAR) {
10139+
if (Z_REG(op1_addr) != ZREG_R0 || Z_OFFSET(op1_addr) != 0) {
10140+
| LOAD_ZVAL_ADDR r0, op1_addr
10141+
}
1013910142
| mov aword T1, r0 // save
1014010143
}
1014110144
| EMALLOC sizeof(zend_reference), op_array, opline
1014210145
| mov dword [r0], 2
1014310146
| mov dword [r0 + offsetof(zend_reference, gc.u.type_info)], GC_REFERENCE
1014410147
| mov aword [r0 + offsetof(zend_reference, sources.ptr)], 0
10145-
ref_addr = ZEND_ADDR_MEM_ZVAL(ZREG_R0, 8);
10148+
ref_addr = ZEND_ADDR_MEM_ZVAL(ZREG_R0, offsetof(zend_reference, val));
1014610149
if (opline->op1_type == IS_VAR) {
1014710150
zend_jit_addr val_addr = ZEND_ADDR_MEM_ZVAL(ZREG_R1, 0);
1014810151

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
JIT SEND_REF: 001
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.file_update_protection=0
7+
opcache.jit_buffer_size=1M
8+
--SKIPIF--
9+
<?php require_once('skipif.inc'); ?>
10+
--FILE--
11+
<?php
12+
function foo(&$obj) {
13+
}
14+
class A {
15+
function foo() {
16+
for ($i = 0; $i < 10; $i++) {
17+
foo($this);
18+
}
19+
echo "ok\n";
20+
}
21+
}
22+
$a = new A;
23+
$a->foo();
24+
?>
25+
--EXPECT--
26+
ok

0 commit comments

Comments
 (0)