Skip to content

Commit 36d2dd0

Browse files
committed
Remove redundant static_members/mutable_data cleanup
static_members, mutable_data and static vars in methods are cleaned up during an earlier shutdown phase (because this has to happen before we destroy the object store). There is no need to repeat this cleanup when destroying the classes.
1 parent 89d0115 commit 36d2dd0

File tree

1 file changed

+18
-31
lines changed

1 file changed

+18
-31
lines changed

Zend/zend_opcode.c

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -277,47 +277,34 @@ ZEND_API void destroy_zend_class(zval *zv)
277277
zend_class_entry *ce = Z_PTR_P(zv);
278278
zend_function *fn;
279279

280-
if (ce->default_static_members_count) {
281-
zend_cleanup_internal_class_data(ce);
280+
if (ce->ce_flags & (ZEND_ACC_IMMUTABLE|ZEND_ACC_PRELOADED)) {
281+
return;
282282
}
283283

284-
if (ce->ce_flags & (ZEND_ACC_IMMUTABLE|ZEND_ACC_PRELOADED|ZEND_ACC_FILE_CACHED)) {
285-
zend_op_array *op_array;
284+
if (ce->ce_flags & ZEND_ACC_FILE_CACHED) {
285+
zend_class_constant *c;
286+
zval *p, *end;
286287

287-
if (!(ce->ce_flags & ZEND_ACC_FILE_CACHED)) {
288-
if (ZEND_MAP_PTR(ce->mutable_data) && ZEND_MAP_PTR_GET_IMM(ce->mutable_data)) {
289-
zend_cleanup_mutable_class_data(ce);
288+
ZEND_HASH_FOREACH_PTR(&ce->constants_table, c) {
289+
if (c->ce == ce) {
290+
zval_ptr_dtor_nogc(&c->value);
290291
}
291-
} else {
292-
zend_class_constant *c;
293-
zval *p, *end;
292+
} ZEND_HASH_FOREACH_END();
294293

295-
ZEND_HASH_FOREACH_PTR(&ce->constants_table, c) {
296-
if (c->ce == ce) {
297-
zval_ptr_dtor_nogc(&c->value);
298-
}
299-
} ZEND_HASH_FOREACH_END();
300-
301-
p = ce->default_properties_table;
302-
end = p + ce->default_properties_count;
303-
304-
while (p < end) {
305-
zval_ptr_dtor_nogc(p);
306-
p++;
307-
}
308-
}
294+
p = ce->default_properties_table;
295+
end = p + ce->default_properties_count;
309296

310-
if (ce->ce_flags & ZEND_HAS_STATIC_IN_METHODS) {
311-
ZEND_HASH_FOREACH_PTR(&ce->function_table, op_array) {
312-
if (op_array->type == ZEND_USER_FUNCTION) {
313-
destroy_op_array(op_array);
314-
}
315-
} ZEND_HASH_FOREACH_END();
297+
while (p < end) {
298+
zval_ptr_dtor_nogc(p);
299+
p++;
316300
}
317301
return;
318-
} else if (--ce->refcount > 0) {
302+
}
303+
304+
if (--ce->refcount > 0) {
319305
return;
320306
}
307+
321308
switch (ce->type) {
322309
case ZEND_USER_CLASS:
323310
if (!(ce->ce_flags & ZEND_ACC_CACHED)) {

0 commit comments

Comments
 (0)