Skip to content

Commit 5ed654e

Browse files
committed
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0: JIT: Fixed register clobbering
2 parents 3661c19 + f681f90 commit 5ed654e

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

ext/opcache/jit/zend_jit_arm64.dasc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5489,6 +5489,9 @@ static int zend_jit_simple_assign(dasm_State **Dst,
54895489
|.cold_code
54905490
|1:
54915491
}
5492+
if (Z_REG(val_addr) == ZREG_REG2) {
5493+
| str x2, T1 // save
5494+
}
54925495
| // zend_refcounted *ref = Z_COUNTED_P(retval_ptr);
54935496
| GET_ZVAL_PTR REG2, val_addr, TMP1
54945497
| GC_DELREF REG2, TMP1w
@@ -5513,6 +5516,9 @@ static int zend_jit_simple_assign(dasm_State **Dst,
55135516
| GC_ADDREF Rx(tmp_reg), TMP1w
55145517
|2:
55155518
}
5519+
if (Z_REG(val_addr) == ZREG_REG2) {
5520+
| ldr x2, T1 // restore
5521+
}
55165522
if (save_r1) {
55175523
| str FCARG1x, T1 // save
55185524
}

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5977,6 +5977,9 @@ static int zend_jit_simple_assign(dasm_State **Dst,
59775977
|.cold_code
59785978
|1:
59795979
}
5980+
if (Z_REG(val_addr) == ZREG_R2) {
5981+
| mov aword T1, r2 // save
5982+
}
59805983
| // zend_refcounted *ref = Z_COUNTED_P(retval_ptr);
59815984
| GET_ZVAL_PTR r2, val_addr
59825985
| GC_DELREF r2
@@ -6001,6 +6004,9 @@ static int zend_jit_simple_assign(dasm_State **Dst,
60016004
| GC_ADDREF Ra(tmp_reg)
60026005
|2:
60036006
}
6007+
if (Z_REG(val_addr) == ZREG_R2) {
6008+
| mov r2, aword T1 // restore
6009+
}
60046010
if (save_r1) {
60056011
| mov aword T1, FCARG1a // save
60066012
}

ext/opcache/tests/jit/assign_042.phpt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
JIT ASSIGN: Assign to of reference with 1 refcount
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.file_update_protection=0
7+
opcache.jit_buffer_size=1M
8+
opcache.protect_memory=1
9+
--FILE--
10+
<?php
11+
class Test {
12+
public $prop;
13+
function __construct() {
14+
$this->prop = $this->retref();
15+
}
16+
function &retref() {
17+
return str_repeat("a", 5);
18+
}
19+
}
20+
$o = new Test();
21+
var_dump($o);
22+
?>
23+
--EXPECTF--
24+
Notice: Only variable references should be returned by reference in %sassign_042.php on line 8
25+
object(Test)#1 (1) {
26+
["prop"]=>
27+
string(5) "aaaaa"
28+
}

0 commit comments

Comments
 (0)