Skip to content

Commit 7b029a3

Browse files
committed
Merge branch 'PHP-8.4'
* PHP-8.4: Fix incorrect handling of ZEND_ACC_FINAL flag in JIT (php#16778)
2 parents 3b115e6 + f6256fa commit 7b029a3

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
@@ -1860,7 +1860,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
18601860
ce = op_array->scope;
18611861
/* scope is NULL for closures. */
18621862
if (ce) {
1863-
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
1863+
ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL);
18641864
}
18651865
op1_addr = 0;
18661866
on_this = 1;
@@ -1911,7 +1911,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
19111911
ce = op_array->scope;
19121912
/* scope is NULL for closures. */
19131913
if (ce) {
1914-
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
1914+
ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL);
19151915
}
19161916
op1_addr = 0;
19171917
on_this = 1;
@@ -1955,7 +1955,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
19551955
ce = op_array->scope;
19561956
/* scope is NULL for closures. */
19571957
if (ce) {
1958-
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
1958+
ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL);
19591959
}
19601960
op1_addr = 0;
19611961
on_this = 1;
@@ -2433,7 +2433,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
24332433
ce = op_array->scope;
24342434
/* scope is NULL for closures. */
24352435
if (ce) {
2436-
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
2436+
ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL);
24372437
}
24382438
on_this = 1;
24392439
} else {
@@ -2603,7 +2603,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
26032603
ce = op_array->scope;
26042604
/* scope is NULL for closures. */
26052605
if (ce) {
2606-
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
2606+
ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL);
26072607
}
26082608
on_this = 1;
26092609
} else {

ext/opcache/jit/zend_jit_trace.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4785,7 +4785,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
47854785
ce = op_array->scope;
47864786
/* scope is NULL for closures. */
47874787
if (ce) {
4788-
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
4788+
ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL);
47894789
}
47904790
op1_addr = 0;
47914791
on_this = 1;
@@ -4879,7 +4879,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
48794879
ce = op_array->scope;
48804880
/* scope is NULL for closures. */
48814881
if (ce) {
4882-
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
4882+
ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL);
48834883
}
48844884
op1_addr = 0;
48854885
on_this = 1;
@@ -4962,7 +4962,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
49624962
ce = op_array->scope;
49634963
/* scope is NULL for closures. */
49644964
if (ce) {
4965-
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
4965+
ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL);
49664966
}
49674967
op1_addr = 0;
49684968
on_this = 1;
@@ -6035,7 +6035,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
60356035
ce = op_array->scope;
60366036
/* scope is NULL for closures. */
60376037
if (ce) {
6038-
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
6038+
ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL);
60396039
}
60406040
op1_addr = 0;
60416041
on_this = 1;
@@ -6341,7 +6341,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
63416341
ce = op_array->scope;
63426342
/* scope is NULL for closures. */
63436343
if (ce) {
6344-
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
6344+
ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL);
63456345
}
63466346
op1_addr = 0;
63476347
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)