Skip to content

Commit f8088c8

Browse files
committed
fix(zend, opcache): track generic_type_table persistence with explicit flag
Signed-off-by: azjezz <azjezz@protonmail.com>
1 parent 3e0412d commit f8088c8

3 files changed

Lines changed: 3 additions & 16 deletions

File tree

Zend/zend_compile.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ typedef struct _zend_generic_type_table {
161161
HashTable *implements; /* implements index -> zend_type * */
162162
HashTable *trait_uses; /* trait-use index -> zend_type * */
163163
HashTable *turbofish_args; /* opline->extended_value -> zend_type * (NAMED_WITH_ARGS holding the call-site type arguments); index is stable across optimizer reorderings */
164+
bool persisted; /* set by opcache when the table lives in SHM/file-cache memory; suppresses destruction */
164165
} zend_generic_type_table;
165166

166167
/* Compile-time linked stack of in-scope generic type parameters. */

Zend/zend_opcode.c

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -185,22 +185,7 @@ ZEND_API zend_generic_type_table *zend_generic_type_table_alloc(void) {
185185
}
186186

187187
ZEND_API void zend_generic_type_table_destroy(zend_generic_type_table *table) {
188-
if (!table) {
189-
return;
190-
}
191-
192-
bool persisted = false;
193-
#define MAYBE_PERSISTED(ht) ((ht) && (GC_FLAGS(ht) & IS_ARRAY_IMMUTABLE))
194-
if (MAYBE_PERSISTED(table->parameters)
195-
|| MAYBE_PERSISTED(table->properties)
196-
|| MAYBE_PERSISTED(table->class_constants)
197-
|| MAYBE_PERSISTED(table->implements)
198-
|| MAYBE_PERSISTED(table->trait_uses)
199-
|| MAYBE_PERSISTED(table->turbofish_args)) {
200-
persisted = true;
201-
}
202-
#undef MAYBE_PERSISTED
203-
if (persisted) {
188+
if (!table || table->persisted) {
204189
return;
205190
}
206191

ext/opcache/zend_persist.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,7 @@ static zend_generic_type_table *zend_persist_generic_type_table(zend_generic_typ
480480
}
481481

482482
zend_generic_type_table *persisted = zend_shared_memdup_put_free(table, sizeof(*table));
483+
persisted->persisted = true;
483484
if (persisted->return_type) {
484485
persisted->return_type = zend_shared_memdup_put_free(persisted->return_type, sizeof(zend_type));
485486
zend_persist_type(persisted->return_type);

0 commit comments

Comments
 (0)