Skip to content

Commit b5746a4

Browse files
committed
Drop HAS_UNLINKED_USES flag
Instead always use the unlinked_uses table, which is already used if opcache is used. Not much point in having a different mechanism for the non-opcache case.
1 parent 132d499 commit b5746a4

File tree

3 files changed

+11
-24
lines changed

3 files changed

+11
-24
lines changed

Zend/zend_compile.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ typedef struct _zend_oparray_context {
241241
/* or IS_CONSTANT_VISITED_MARK | | | */
242242
#define ZEND_CLASS_CONST_IS_CASE (1 << 6) /* | | | X */
243243
/* | | | */
244-
/* Class Flags (unused: 15,30,31) | | | */
244+
/* Class Flags (unused: 15,21,30,31) | | | */
245245
/* =========== | | | */
246246
/* | | | */
247247
/* Special class types | | | */
@@ -285,9 +285,6 @@ typedef struct _zend_oparray_context {
285285
/* Class is linked apart from variance obligations. | | | */
286286
#define ZEND_ACC_NEARLY_LINKED (1 << 20) /* X | | | */
287287
/* | | | */
288-
/* Whether this class was used in its unlinked state. | | | */
289-
#define ZEND_ACC_HAS_UNLINKED_USES (1 << 21) /* X | | | */
290-
/* | | | */
291288
/* stored in opcache (may be partially) | | | */
292289
#define ZEND_ACC_CACHED (1 << 22) /* X | | | */
293290
/* | | | */

Zend/zend_execute_API.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,15 +1055,11 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, zend_string *
10551055
if ((flags & ZEND_FETCH_CLASS_ALLOW_UNLINKED) ||
10561056
((flags & ZEND_FETCH_CLASS_ALLOW_NEARLY_LINKED) &&
10571057
(ce->ce_flags & ZEND_ACC_NEARLY_LINKED))) {
1058-
if (ce->ce_flags & ZEND_ACC_IMMUTABLE) {
1059-
if (!CG(unlinked_uses)) {
1060-
ALLOC_HASHTABLE(CG(unlinked_uses));
1061-
zend_hash_init(CG(unlinked_uses), 0, NULL, NULL, 0);
1062-
}
1063-
zend_hash_index_add_empty_element(CG(unlinked_uses), (zend_long)(zend_uintptr_t)ce);
1064-
} else {
1065-
ce->ce_flags |= ZEND_ACC_HAS_UNLINKED_USES;
1058+
if (!CG(unlinked_uses)) {
1059+
ALLOC_HASHTABLE(CG(unlinked_uses));
1060+
zend_hash_init(CG(unlinked_uses), 0, NULL, NULL, 0);
10661061
}
1062+
zend_hash_index_add_empty_element(CG(unlinked_uses), (zend_long)(zend_uintptr_t)ce);
10671063
return ce;
10681064
}
10691065
return NULL;

Zend/zend_inheritance.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2570,10 +2570,8 @@ static void check_unrecoverable_load_failure(zend_class_entry *ce) {
25702570
* to remove the class from the class table and throw an exception, because there is already
25712571
* a dependence on the inheritance hierarchy of this specific class. Instead we fall back to
25722572
* a fatal error, as would happen if we did not allow exceptions in the first place. */
2573-
if ((ce->ce_flags & ZEND_ACC_HAS_UNLINKED_USES)
2574-
|| ((ce->ce_flags & ZEND_ACC_IMMUTABLE)
2575-
&& CG(unlinked_uses)
2576-
&& zend_hash_index_del(CG(unlinked_uses), (zend_long)(zend_uintptr_t)ce) == SUCCESS)) {
2573+
if (CG(unlinked_uses)
2574+
&& zend_hash_index_del(CG(unlinked_uses), (zend_long)(zend_uintptr_t)ce) == SUCCESS) {
25772575
zend_exception_uncaught_error(
25782576
"During inheritance of %s with variance dependencies", ZSTR_VAL(ce->name));
25792577
}
@@ -2847,20 +2845,16 @@ ZEND_API zend_class_entry *zend_do_link_class(zend_class_entry *ce, zend_string
28472845
ce = zend_lazy_class_load(ce);
28482846
zv = zend_hash_find_known_hash(CG(class_table), key);
28492847
Z_CE_P(zv) = ce;
2850-
if (CG(unlinked_uses)
2851-
&& zend_hash_index_del(CG(unlinked_uses), (zend_long)(zend_uintptr_t)proto) == SUCCESS) {
2852-
ce->ce_flags |= ZEND_ACC_HAS_UNLINKED_USES;
2853-
}
28542848
} else if (ce->ce_flags & ZEND_ACC_FILE_CACHED) {
28552849
/* Lazy class loading */
28562850
ce = zend_lazy_class_load(ce);
28572851
ce->ce_flags &= ~ZEND_ACC_FILE_CACHED;
28582852
zv = zend_hash_find_known_hash(CG(class_table), key);
28592853
Z_CE_P(zv) = ce;
2860-
if (CG(unlinked_uses)
2861-
&& zend_hash_index_del(CG(unlinked_uses), (zend_long)(zend_uintptr_t)proto) == SUCCESS) {
2862-
ce->ce_flags |= ZEND_ACC_HAS_UNLINKED_USES;
2863-
}
2854+
}
2855+
2856+
if (CG(unlinked_uses)) {
2857+
zend_hash_index_del(CG(unlinked_uses), (zend_long)(zend_uintptr_t) ce);
28642858
}
28652859

28662860
orig_linking_class = CG(current_linking_class);

0 commit comments

Comments
 (0)