1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.4'

* PHP-8.4:
  Fix incorrect handling of ZEND_ACC_FINAL flag in JIT (#16778)
This commit is contained in:
Dmitry Stogov
2024-11-13 14:43:54 +03:00
3 changed files with 48 additions and 10 deletions

View File

@@ -1860,7 +1860,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
ce = op_array->scope;
/* scope is NULL for closures. */
if (ce) {
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL);
}
op1_addr = 0;
on_this = 1;
@@ -1911,7 +1911,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
ce = op_array->scope;
/* scope is NULL for closures. */
if (ce) {
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL);
}
op1_addr = 0;
on_this = 1;
@@ -1955,7 +1955,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
ce = op_array->scope;
/* scope is NULL for closures. */
if (ce) {
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL);
}
op1_addr = 0;
on_this = 1;
@@ -2433,7 +2433,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
ce = op_array->scope;
/* scope is NULL for closures. */
if (ce) {
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL);
}
on_this = 1;
} else {
@@ -2603,7 +2603,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
ce = op_array->scope;
/* scope is NULL for closures. */
if (ce) {
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL);
}
on_this = 1;
} else {

View File

@@ -4785,7 +4785,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
ce = op_array->scope;
/* scope is NULL for closures. */
if (ce) {
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL);
}
op1_addr = 0;
on_this = 1;
@@ -4879,7 +4879,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
ce = op_array->scope;
/* scope is NULL for closures. */
if (ce) {
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL);
}
op1_addr = 0;
on_this = 1;
@@ -4962,7 +4962,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
ce = op_array->scope;
/* scope is NULL for closures. */
if (ce) {
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL);
}
op1_addr = 0;
on_this = 1;
@@ -6035,7 +6035,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
ce = op_array->scope;
/* scope is NULL for closures. */
if (ce) {
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL);
}
op1_addr = 0;
on_this = 1;
@@ -6341,7 +6341,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
ce = op_array->scope;
/* scope is NULL for closures. */
if (ce) {
ce_is_instanceof = (ce->ce_flags & ZEND_ACC_FINAL) != 0;
ce_is_instanceof = !(ce->ce_flags & ZEND_ACC_FINAL);
}
op1_addr = 0;
on_this = 1;

View File

@@ -0,0 +1,38 @@
--TEST--
JIT ASSIGN_OBJ: Typed & not-typed property
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.file_update_protection=0
opcache.jit_buffer_size=1M
--FILE--
<?php
interface I {
}
abstract class C1 implements I {
public function __construct($x) {
$this->x = $x;
}
}
class C2 extends C1 {
public $x = 0;
}
class C3 extends C1 {
public int $x = 0;
}
$o = new C2("abcd");
var_dump($o->x);
$o = new C3(42);
var_dump($o->x);
$o = new C3("abcd");
var_dump($o->x);
?>
--EXPECTF--
string(4) "abcd"
int(42)
Fatal error: Uncaught TypeError: Cannot assign string to property C3::$x of type int in %sassign_obj_005.php:6
Stack trace:
#0 %sassign_obj_005.php(19): C1->__construct('abcd')
#1 {main}
thrown in %sassign_obj_005.php on line 6