Skip to content

Commit

Permalink
Remove redundant static_members/mutable_data cleanup
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nikic committed Jul 23, 2021
1 parent 89d0115 commit 36d2dd0
Showing 1 changed file with 18 additions and 31 deletions.
49 changes: 18 additions & 31 deletions Zend/zend_opcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,47 +277,34 @@ ZEND_API void destroy_zend_class(zval *zv)
zend_class_entry *ce = Z_PTR_P(zv);
zend_function *fn;

if (ce->default_static_members_count) {
zend_cleanup_internal_class_data(ce);
if (ce->ce_flags & (ZEND_ACC_IMMUTABLE|ZEND_ACC_PRELOADED)) {
return;
}

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

if (!(ce->ce_flags & ZEND_ACC_FILE_CACHED)) {
if (ZEND_MAP_PTR(ce->mutable_data) && ZEND_MAP_PTR_GET_IMM(ce->mutable_data)) {
zend_cleanup_mutable_class_data(ce);
ZEND_HASH_FOREACH_PTR(&ce->constants_table, c) {
if (c->ce == ce) {
zval_ptr_dtor_nogc(&c->value);
}
} else {
zend_class_constant *c;
zval *p, *end;
} ZEND_HASH_FOREACH_END();

ZEND_HASH_FOREACH_PTR(&ce->constants_table, c) {
if (c->ce == ce) {
zval_ptr_dtor_nogc(&c->value);
}
} ZEND_HASH_FOREACH_END();

p = ce->default_properties_table;
end = p + ce->default_properties_count;

while (p < end) {
zval_ptr_dtor_nogc(p);
p++;
}
}
p = ce->default_properties_table;
end = p + ce->default_properties_count;

if (ce->ce_flags & ZEND_HAS_STATIC_IN_METHODS) {
ZEND_HASH_FOREACH_PTR(&ce->function_table, op_array) {
if (op_array->type == ZEND_USER_FUNCTION) {
destroy_op_array(op_array);
}
} ZEND_HASH_FOREACH_END();
while (p < end) {
zval_ptr_dtor_nogc(p);
p++;
}
return;
} else if (--ce->refcount > 0) {
}

if (--ce->refcount > 0) {
return;
}

switch (ce->type) {
case ZEND_USER_CLASS:
if (!(ce->ce_flags & ZEND_ACC_CACHED)) {
Expand Down

0 comments on commit 36d2dd0

Please sign in to comment.