Merge branch 'PHP-8.3'

* PHP-8.3:
  Fixed type inference
This commit is contained in:
Dmitry Stogov 2023-12-18 12:28:36 +03:00
commit d2e16a2199
3 changed files with 40 additions and 1 deletions

View File

@ -2828,8 +2828,15 @@ static zend_always_inline zend_result _zend_update_type_info(
/* DOUBLE may be auto-converted to LONG */
tmp |= MAY_BE_LONG;
tmp &= ~MAY_BE_DOUBLE;
} else if ((t1 & (MAY_BE_LONG|MAY_BE_DOUBLE|MAY_BE_STRING)) == MAY_BE_STRING
&& (tmp & (MAY_BE_LONG|MAY_BE_DOUBLE))) {
/* LONG/DOUBLE may be auto-converted to STRING */
tmp |= MAY_BE_STRING;
tmp &= ~(MAY_BE_LONG|MAY_BE_DOUBLE);
}
tmp &= t1;
} else {
tmp |= MAY_BE_LONG | MAY_BE_STRING;
}
} else if (opline->opcode == ZEND_ASSIGN_STATIC_PROP_OP) {
/* The return value must also satisfy the property type */
@ -2840,8 +2847,15 @@ static zend_always_inline zend_result _zend_update_type_info(
/* DOUBLE may be auto-converted to LONG */
tmp |= MAY_BE_LONG;
tmp &= ~MAY_BE_DOUBLE;
} else if ((t1 & (MAY_BE_LONG|MAY_BE_DOUBLE|MAY_BE_STRING)) == MAY_BE_STRING
&& (tmp & (MAY_BE_LONG|MAY_BE_DOUBLE))) {
/* LONG/DOUBLE may be auto-converted to STRING */
tmp |= MAY_BE_STRING;
tmp &= ~(MAY_BE_LONG|MAY_BE_DOUBLE);
}
tmp &= t1;
} else {
tmp |= MAY_BE_LONG | MAY_BE_STRING;
}
} else {
if (tmp & MAY_BE_REF) {

View File

@ -799,7 +799,9 @@ zend_class_entry *zend_optimizer_get_class_entry(
}
ce = zend_hash_find_ptr(CG(class_table), lcname);
if (ce && ce->type == ZEND_INTERNAL_CLASS) {
if (ce
&& (ce->type == ZEND_INTERNAL_CLASS
|| (op_array && ce->info.user.filename == op_array->filename))) {
return ce;
}

View File

@ -0,0 +1,23 @@
--TEST--
JIT ASSIGN_STATIC_PROP_OP: 001
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.file_update_protection=0
opcache.jit_buffer_size=1M
--EXTENSIONS--
opcache
--FILE--
<?php
function ref () {
}
class Foo {
static $i;
static string $s;
}
Foo::$i = 1;
Foo::$s = Foo::$i;
var_dump(Foo::$s -= ref());
?>
--EXPECT--
string(1) "1"