Skip to content

Commit f6256fa

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: Fix incorrect handling of ZEND_ACC_FINAL flag in JIT (#16778)
2 parents a8151fc + b9c6f07 commit f6256fa

File tree

3 files changed

+48
-10
lines changed

3 files changed

+48
-10
lines changed

ext/opcache/jit/zend_jit.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1751,7 +1751,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
17511751
ce = op_array->scope;
17521752
/* scope is NULL for closures. */
17531753
if (ce) {
1754-
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
1754+
ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL);
17551755
}
17561756
op1_addr = 0;
17571757
on_this = 1;
@@ -1802,7 +1802,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
18021802
ce = op_array->scope;
18031803
/* scope is NULL for closures. */
18041804
if (ce) {
1805-
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
1805+
ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL);
18061806
}
18071807
op1_addr = 0;
18081808
on_this = 1;
@@ -1846,7 +1846,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
18461846
ce = op_array->scope;
18471847
/* scope is NULL for closures. */
18481848
if (ce) {
1849-
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
1849+
ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL);
18501850
}
18511851
op1_addr = 0;
18521852
on_this = 1;
@@ -2324,7 +2324,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
23242324
ce = op_array->scope;
23252325
/* scope is NULL for closures. */
23262326
if (ce) {
2327-
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
2327+
ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL);
23282328
}
23292329
on_this = 1;
23302330
} else {
@@ -2478,7 +2478,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
24782478
ce = op_array->scope;
24792479
/* scope is NULL for closures. */
24802480
if (ce) {
2481-
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
2481+
ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL);
24822482
}
24832483
on_this = 1;
24842484
} else {

ext/opcache/jit/zend_jit_trace.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4754,7 +4754,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
47544754
ce = op_array->scope;
47554755
/* scope is NULL for closures. */
47564756
if (ce) {
4757-
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
4757+
ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL);
47584758
}
47594759
op1_addr = 0;
47604760
on_this = 1;
@@ -4848,7 +4848,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
48484848
ce = op_array->scope;
48494849
/* scope is NULL for closures. */
48504850
if (ce) {
4851-
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
4851+
ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL);
48524852
}
48534853
op1_addr = 0;
48544854
on_this = 1;
@@ -4931,7 +4931,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
49314931
ce = op_array->scope;
49324932
/* scope is NULL for closures. */
49334933
if (ce) {
4934-
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
4934+
ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL);
49354935
}
49364936
op1_addr = 0;
49374937
on_this = 1;
@@ -6002,7 +6002,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
60026002
ce = op_array->scope;
60036003
/* scope is NULL for closures. */
60046004
if (ce) {
6005-
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
6005+
ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL);
60066006
}
60076007
op1_addr = 0;
60086008
on_this = 1;
@@ -6285,7 +6285,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
62856285
ce = op_array->scope;
62866286
/* scope is NULL for closures. */
62876287
if (ce) {
6288-
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
6288+
ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL);
62896289
}
62906290
op1_addr = 0;
62916291
on_this = 1;
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
--TEST--
2+
JIT ASSIGN_OBJ: Typed & not-typed 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+
interface I {
11+
}
12+
abstract class C1 implements I {
13+
public function __construct($x) {
14+
$this->x = $x;
15+
}
16+
}
17+
class C2 extends C1 {
18+
public $x = 0;
19+
}
20+
class C3 extends C1 {
21+
public int $x = 0;
22+
}
23+
$o = new C2("abcd");
24+
var_dump($o->x);
25+
$o = new C3(42);
26+
var_dump($o->x);
27+
$o = new C3("abcd");
28+
var_dump($o->x);
29+
?>
30+
--EXPECTF--
31+
string(4) "abcd"
32+
int(42)
33+
34+
Fatal error: Uncaught TypeError: Cannot assign string to property C3::$x of type int in %sassign_obj_005.php:6
35+
Stack trace:
36+
#0 %sassign_obj_005.php(19): C1->__construct('abcd')
37+
#1 {main}
38+
thrown in %sassign_obj_005.php on line 6

0 commit comments

Comments
 (0)