Skip to content

Commit cf42de8

Browse files
committed
fix(zend, opcache): use a property flag to identify generic clones
Signed-off-by: azjezz <azjezz@protonmail.com>
1 parent 8d8a55c commit cf42de8

4 files changed

Lines changed: 7 additions & 3 deletions

File tree

Zend/zend_compile.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ typedef struct _zend_oparray_context {
332332
/* has #[\Override] attribute | | | */
333333
#define ZEND_ACC_OVERRIDE (1 << 28) /* | X | X | */
334334
/* | | | */
335-
/* Property Flags (unused: 13-27,29...) | | | */
335+
/* Property Flags (unused: 14-27,29...) | | | */
336336
/* =========== | | | */
337337
/* | | | */
338338
/* Promoted property / parameter | | | */
@@ -346,6 +346,9 @@ typedef struct _zend_oparray_context {
346346
#define ZEND_ACC_PROTECTED_SET (1 << 11) /* | | X | */
347347
#define ZEND_ACC_PRIVATE_SET (1 << 12) /* | | X | */
348348
/* | | | */
349+
/* Parametric LSP substitution clone owned by a child | | | */
350+
#define ZEND_ACC_GENERIC_CLONE (1 << 13) /* | | X | */
351+
/* | | | */
349352
/* Class Flags (unused: 31) | | | */
350353
/* =========== | | | */
351354
/* | | | */

Zend/zend_inheritance.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1920,6 +1920,7 @@ static void do_inherit_property(zend_property_info *parent_info, zend_string *ke
19201920
if (!ZEND_TYPE_HAS_TYPE_PARAMETER(sub)) {
19211921
zend_property_info *clone = zend_arena_alloc(&CG(arena), sizeof(*clone));
19221922
*clone = *parent_info;
1923+
clone->flags |= ZEND_ACC_GENERIC_CLONE;
19231924
clone->type = sub;
19241925
zend_type_copy_ctor(&clone->type, /* use_arena */ true, /* persistent */ false);
19251926

ext/opcache/zend_persist.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1211,7 +1211,7 @@ zend_class_entry *zend_persist_class_entry(zend_class_entry *orig_ce)
12111211
zend_property_info *xlat_prop = zend_shared_alloc_get_xlat_entry(prop);
12121212
if (xlat_prop) {
12131213
Z_PTR(p->val) = xlat_prop;
1214-
} else if (!zend_accel_in_shm(prop) && prop->ce->type == ZEND_USER_CLASS) {
1214+
} else if (prop->flags & ZEND_ACC_GENERIC_CLONE) {
12151215
Z_PTR(p->val) = zend_persist_substituted_property_info(prop);
12161216
} else {
12171217
/* This can happen if preloading is used and we inherit a property from an

ext/opcache/zend_persist_calc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ void zend_persist_class_entry_calc(zend_class_entry *ce)
662662
ADD_INTERNED_STRING(p->key);
663663
if (prop->ce == ce) {
664664
zend_persist_property_info_calc(prop);
665-
} else if (!zend_accel_in_shm(prop) && prop->ce->type == ZEND_USER_CLASS && !zend_shared_alloc_get_xlat_entry(prop)) {
665+
} else if ((prop->flags & ZEND_ACC_GENERIC_CLONE) && !zend_shared_alloc_get_xlat_entry(prop)) {
666666
zend_shared_alloc_register_xlat_entry(prop, prop);
667667
zend_persist_substituted_property_info_calc(prop);
668668
}

0 commit comments

Comments
 (0)