Skip to content

Commit 19809a5

Browse files
authored
Fix incorrect handling of ZEND_ACC_FINAL flag in JIT (php#16778)
1 parent 02ee521 commit 19809a5

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
@@ -3169,7 +3169,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
31693169
if (opline->op1_type == IS_UNUSED) {
31703170
op1_info = MAY_BE_OBJECT|MAY_BE_RC1|MAY_BE_RCN;
31713171
ce = op_array->scope;
3172-
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
3172+
ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL);
31733173
op1_addr = 0;
31743174
on_this = 1;
31753175
} else {
@@ -3217,7 +3217,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
32173217
if (opline->op1_type == IS_UNUSED) {
32183218
op1_info = MAY_BE_OBJECT|MAY_BE_RC1|MAY_BE_RCN;
32193219
ce = op_array->scope;
3220-
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
3220+
ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL);
32213221
op1_addr = 0;
32223222
on_this = 1;
32233223
} else {
@@ -3258,7 +3258,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
32583258
if (opline->op1_type == IS_UNUSED) {
32593259
op1_info = MAY_BE_OBJECT|MAY_BE_RC1|MAY_BE_RCN;
32603260
ce = op_array->scope;
3261-
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
3261+
ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL);
32623262
op1_addr = 0;
32633263
on_this = 1;
32643264
} else {
@@ -3761,7 +3761,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
37613761
op1_info = MAY_BE_OBJECT|MAY_BE_RC1|MAY_BE_RCN;
37623762
op1_addr = 0;
37633763
ce = op_array->scope;
3764-
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
3764+
ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL);
37653765
on_this = 1;
37663766
} else {
37673767
op1_info = OP1_INFO();
@@ -3912,7 +3912,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
39123912
op1_info = MAY_BE_OBJECT|MAY_BE_RC1|MAY_BE_RCN;
39133913
op1_addr = 0;
39143914
ce = op_array->scope;
3915-
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
3915+
ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL);
39163916
on_this = 1;
39173917
} else {
39183918
op1_info = OP1_INFO();

ext/opcache/jit/zend_jit_trace.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4648,7 +4648,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
46484648
if (opline->op1_type == IS_UNUSED) {
46494649
op1_info = MAY_BE_OBJECT|MAY_BE_RC1|MAY_BE_RCN;
46504650
ce = op_array->scope;
4651-
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
4651+
ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL);
46524652
op1_addr = 0;
46534653
on_this = 1;
46544654
} else {
@@ -4739,7 +4739,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
47394739
if (opline->op1_type == IS_UNUSED) {
47404740
op1_info = MAY_BE_OBJECT|MAY_BE_RC1|MAY_BE_RCN;
47414741
ce = op_array->scope;
4742-
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
4742+
ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL);
47434743
op1_addr = 0;
47444744
on_this = 1;
47454745
} else {
@@ -4819,7 +4819,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
48194819
if (opline->op1_type == IS_UNUSED) {
48204820
op1_info = MAY_BE_OBJECT|MAY_BE_RC1|MAY_BE_RCN;
48214821
ce = op_array->scope;
4822-
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
4822+
ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL);
48234823
op1_addr = 0;
48244824
on_this = 1;
48254825
} else {
@@ -5839,7 +5839,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
58395839
if (opline->op1_type == IS_UNUSED) {
58405840
op1_info = MAY_BE_OBJECT|MAY_BE_RC1|MAY_BE_RCN;
58415841
ce = op_array->scope;
5842-
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
5842+
ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL);
58435843
op1_addr = 0;
58445844
on_this = 1;
58455845
} else {
@@ -6118,7 +6118,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
61186118
if (opline->op1_type == IS_UNUSED) {
61196119
op1_info = MAY_BE_OBJECT|MAY_BE_RC1|MAY_BE_RCN;
61206120
ce = op_array->scope;
6121-
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
6121+
ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL);
61226122
op1_addr = 0;
61236123
on_this = 1;
61246124
} else {
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)