Skip to content

Commit 6156505

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: JIT: Fixed incorrect code generation
2 parents 2ab05da + 24bb178 commit 6156505

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
@@ -13317,6 +13317,7 @@ static int zend_jit_assign_obj(dasm_State **Dst,
1331713317
zend_jit_addr this_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, offsetof(zend_execute_data, This));
1331813318
zend_jit_addr prop_addr;
1331913319
bool needs_slow_path = 0;
13320+
bool needs_val_dtor = 0;
1332013321

1332113322
if (RETURN_VALUE_USED(opline)) {
1332213323
res_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, opline->result.var);
@@ -13373,6 +13374,7 @@ static int zend_jit_assign_obj(dasm_State **Dst,
1337313374
}
1337413375
if (((opline+1)->op1_type & (IS_VAR|IS_TMP_VAR))
1337513376
&& (val_info & (MAY_BE_REF|MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE))) {
13377+
needs_val_dtor = 1;
1337613378
| b >7
1337713379
} else {
1337813380
| b >9
@@ -13549,6 +13551,13 @@ static int zend_jit_assign_obj(dasm_State **Dst,
1354913551
val_info |= MAY_BE_RC1|MAY_BE_RCN;
1355013552
}
1355113553

13554+
|7:
13555+
| // FREE_OP_DATA();
13556+
| FREE_OP (opline+1)->op1_type, (opline+1)->op1, val_info, 0, opline, ZREG_TMP1, ZREG_TMP2
13557+
| b >9
13558+
|.code
13559+
} else if (needs_val_dtor) {
13560+
|.cold_code
1355213561
|7:
1355313562
| // FREE_OP_DATA();
1355413563
| 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
@@ -14133,6 +14133,7 @@ static int zend_jit_assign_obj(dasm_State **Dst,
1413314133
zend_jit_addr this_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, offsetof(zend_execute_data, This));
1413414134
zend_jit_addr prop_addr;
1413514135
bool needs_slow_path = 0;
14136+
bool needs_val_dtor = 0;
1413614137

1413714138
if (RETURN_VALUE_USED(opline)) {
1413814139
res_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, opline->result.var);
@@ -14189,6 +14190,7 @@ static int zend_jit_assign_obj(dasm_State **Dst,
1418914190
}
1419014191
if (((opline+1)->op1_type & (IS_VAR|IS_TMP_VAR))
1419114192
&& (val_info & (MAY_BE_REF|MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE))) {
14193+
needs_val_dtor = 1;
1419214194
| jmp >7
1419314195
} else {
1419414196
| jmp >9
@@ -14414,6 +14416,13 @@ static int zend_jit_assign_obj(dasm_State **Dst,
1441414416
val_info |= MAY_BE_RC1|MAY_BE_RCN;
1441514417
}
1441614418

14419+
|7:
14420+
| // FREE_OP_DATA();
14421+
| FREE_OP (opline+1)->op1_type, (opline+1)->op1, val_info, 0, opline
14422+
| jmp >9
14423+
|.code
14424+
} else if (needs_val_dtor) {
14425+
|.cold_code
1441714426
|7:
1441814427
| // FREE_OP_DATA();
1441914428
| 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)