Skip to content

Commit 24bb178

Browse files
committed
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0: JIT: Fixed incorrect code generation
2 parents 14fddd1 + 0d44bbd commit 24bb178

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

ext/opcache/jit/zend_jit_arm64.dasc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13460,6 +13460,7 @@ static int zend_jit_assign_obj(dasm_State **Dst,
1346013460
zend_jit_addr this_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, offsetof(zend_execute_data, This));
1346113461
zend_jit_addr prop_addr;
1346213462
bool needs_slow_path = 0;
13463+
bool needs_val_dtor = 0;
1346313464

1346413465
if (RETURN_VALUE_USED(opline)) {
1346513466
res_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, opline->result.var);
@@ -13516,6 +13517,7 @@ static int zend_jit_assign_obj(dasm_State **Dst,
1351613517
}
1351713518
if (((opline+1)->op1_type & (IS_VAR|IS_TMP_VAR))
1351813519
&& (val_info & (MAY_BE_REF|MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE))) {
13520+
needs_val_dtor = 1;
1351913521
| b >7
1352013522
} else {
1352113523
| b >9
@@ -13692,6 +13694,13 @@ static int zend_jit_assign_obj(dasm_State **Dst,
1369213694
val_info |= MAY_BE_RC1|MAY_BE_RCN;
1369313695
}
1369413696

13697+
|7:
13698+
| // FREE_OP_DATA();
13699+
| FREE_OP (opline+1)->op1_type, (opline+1)->op1, val_info, 0, opline, ZREG_TMP1, ZREG_TMP2
13700+
| b >9
13701+
|.code
13702+
} else if (needs_val_dtor) {
13703+
|.cold_code
1369513704
|7:
1369613705
| // FREE_OP_DATA();
1369713706
| FREE_OP (opline+1)->op1_type, (opline+1)->op1, val_info, 0, opline, ZREG_TMP1, ZREG_TMP2

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14276,6 +14276,7 @@ static int zend_jit_assign_obj(dasm_State **Dst,
1427614276
zend_jit_addr this_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, offsetof(zend_execute_data, This));
1427714277
zend_jit_addr prop_addr;
1427814278
bool needs_slow_path = 0;
14279+
bool needs_val_dtor = 0;
1427914280

1428014281
if (RETURN_VALUE_USED(opline)) {
1428114282
res_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, opline->result.var);
@@ -14332,6 +14333,7 @@ static int zend_jit_assign_obj(dasm_State **Dst,
1433214333
}
1433314334
if (((opline+1)->op1_type & (IS_VAR|IS_TMP_VAR))
1433414335
&& (val_info & (MAY_BE_REF|MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE))) {
14336+
needs_val_dtor = 1;
1433514337
| jmp >7
1433614338
} else {
1433714339
| jmp >9
@@ -14557,6 +14559,13 @@ static int zend_jit_assign_obj(dasm_State **Dst,
1455714559
val_info |= MAY_BE_RC1|MAY_BE_RCN;
1455814560
}
1455914561

14562+
|7:
14563+
| // FREE_OP_DATA();
14564+
| FREE_OP (opline+1)->op1_type, (opline+1)->op1, val_info, 0, opline
14565+
| jmp >9
14566+
|.code
14567+
} else if (needs_val_dtor) {
14568+
|.cold_code
1456014569
|7:
1456114570
| // FREE_OP_DATA();
1456214571
| FREE_OP (opline+1)->op1_type, (opline+1)->op1, val_info, 0, opline
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
--TEST--
2+
JIT ASSIGN_OBJ: Assign undefined vatiable to property
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.file_update_protection=0
7+
opcache.jit_buffer_size=1M
8+
--FILE--
9+
<?php
10+
class Node {
11+
public $previous;
12+
public $next;
13+
}
14+
15+
function xxx() {
16+
$firstNode = new Node();
17+
// $firstNode->previous = $firstNode;
18+
$firstNode->next = $firstNode;
19+
$circularDoublyLinkedList = null;
20+
for ($i = 0; $i < 2; $i++) {
21+
$currentNode = $circularDoublyLinkedList;
22+
$nextNode = $circularDoublyLinkedList->next;
23+
$newNode->next = $undef1->next; // <- ???
24+
$newNode = new Node();
25+
$currentNode->undef2 = new Node();
26+
$circularDoublyLinkedList = $nextNode;
27+
}
28+
}
29+
30+
try {
31+
@xxx();
32+
} catch (Throwable $e) {
33+
echo "Exception: " . $e->getMessage() . "\n";
34+
}
35+
?>
36+
--EXPECT--
37+
Exception: Attempt to assign property "next" on null

0 commit comments

Comments
 (0)