Questions about PHP source code

see two pieces of code:

// 
int symbols;
do {
    symbols = zend_hash_num_elements(&EG(symbol_table));
    zend_hash_reverse_apply(&EG(symbol_table), (apply_func_t) zval_call_destructor TSRMLS_CC);
} while (symbols != zend_hash_num_elements(&EG(symbol_table)));

// 
zend_objects_store_call_destructors(&EG(objects_store) TSRMLS_CC);
Does this code mean to traverse the symbol_table backwards, and then throw each zval that needs to execute the destructor into the TSRMLS_CC, this guy is an array, and then as an argument to the zend_objects_store_call_destructors function, the zend_objects_store_call_destructors function traverses it internally (TSRMLS_CC)?
is that so? Thank you all

Apr.08,2021

1. Reverse traversing the global symbol table
2. Apply the zval_call_destructor function
3 to each element in the symbol table. Determine the type of value in the symbol table, and if it is an object, set its zval to IS_UNDEF
4. Traverse the object stack and execute the destructor of the object one by one

,,ZEND_HASH_APPLY_REMOVE,zval,
static int zval_call_destructor(zval *zv) /* {{{ */
{
    if (Z_TYPE_P(zv) == IS_INDIRECT) {
        zv = Z_INDIRECT_P(zv);
    }
    if (Z_TYPE_P(zv) == IS_OBJECT && Z_REFCOUNT_P(zv) == 1) {
        return ZEND_HASH_APPLY_REMOVE;
    } else {
        return ZEND_HASH_APPLY_KEEP;
    }
}

Update-
in the previous paragraph of symbol, the destructor of the symbol table is set

if (CG(unclean_shutdown)) {
    EG(symbol_table).pDestructor = zend_unclean_zval_ptr_dtor;
}

in the process of traversing the symbol table in reverse, if the reference count is reduced to 0, execute the destructor on its stored zval
this function calls the zend_objects_store_del
function to first execute the destructor of the object, and then release the memory occupied by the object

Menu