cvs: ZendEngine2 / zend_compile.h zend_execute_API.c zend_opcode.c

From: Date: Wed, 29 Jan 2003 17:54:48 +0000
Subject: cvs: ZendEngine2 / zend_compile.h zend_execute_API.c zend_opcode.c
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-856@lists.php.net to get a copy of this message
stas Wed Jan 29 12:54:48 2003 EDT Modified files: /ZendEngine2 zend_compile.h zend_execute_API.c zend_opcode.c Log: Add additional stage to post-session cleanup. We need separate cleanup stage because of the following problem: Suppose we destroy class X, which destroys function table, and in function table we have function foo() that has static $bar. Now if object of class X was assigned to $bar, its destructor will be called and will fail since X's function table is in mid-destruction. So we want first of all to clean up all data and then move to tables destruction. Note that only run-time accessed data need to be cleaned up, pre-defined data can not contain objects and thus are not probelmatic. # Looks like we are having a lots of pain in the various parts of the body # because of the destructors... Index: ZendEngine2/zend_compile.h diff -u ZendEngine2/zend_compile.h:1.204 ZendEngine2/zend_compile.h:1.205 --- ZendEngine2/zend_compile.h:1.204 Mon Jan 27 10:13:01 2003 +++ ZendEngine2/zend_compile.h Wed Jan 29 12:54:47 2003 @@ -427,6 +427,8 @@ ZEND_API void destroy_op_array(zend_op_array *op_array); ZEND_API void zend_destroy_file_handle(zend_file_handle *file_handle TSRMLS_DC); ZEND_API void zend_file_handle_dtor(zend_file_handle *fh); +ZEND_API int zend_cleanup_class_data(zend_class_entry **pce TSRMLS_DC); +ZEND_API int zend_cleanup_function_data(zend_function *function TSRMLS_DC); ZEND_API void destroy_zend_function(zend_function *function); ZEND_API void destroy_zend_class(zend_class_entry **pce); Index: ZendEngine2/zend_execute_API.c diff -u ZendEngine2/zend_execute_API.c:1.190 ZendEngine2/zend_execute_API.c:1.191 --- ZendEngine2/zend_execute_API.c:1.190 Wed Jan 29 09:33:18 2003 +++ ZendEngine2/zend_execute_API.c Wed Jan 29 12:54:48 2003 @@ -218,6 +218,17 @@ zend_ptr_stack_destroy(&EG(argument_stack)); + /* Cleanup static data for functions and arrays. + We need separate cleanup stage because of the following problem: + Suppose we destroy class X, which destroys function table, + and in function table we have function foo() that has static $bar. Now if + object of class X is assigned to $bar, its destructor will be called and will + fail since X's function table is in mid-destruction. + So we want first of all to clean up all data and then move to tables destruction. + Note that only run-time accessed data need to be cleaned up, pre-defined data can + not contain objects and thus are not probelmatic */ + zend_hash_apply(EG(function_table), (apply_func_t) zend_cleanup_function_data); + zend_hash_apply(EG(class_table), (apply_func_t) zend_cleanup_class_data); /* Destroy all op arrays */ if (EG(full_tables_cleanup)) { zend_hash_apply(EG(function_table), (apply_func_t) is_not_internal_function TSRMLS_CC); Index: ZendEngine2/zend_opcode.c diff -u ZendEngine2/zend_opcode.c:1.77 ZendEngine2/zend_opcode.c:1.78 --- ZendEngine2/zend_opcode.c:1.77 Tue Dec 31 10:54:08 2002 +++ ZendEngine2/zend_opcode.c Wed Jan 29 12:54:48 2003 @@ -107,6 +107,33 @@ } } +static void zend_cleanup_op_array_data(zend_op_array *op_array) +{ + if (op_array->static_variables) { + zend_hash_clean(op_array->static_variables); + } +} + +ZEND_API int zend_cleanup_function_data(zend_function *function TSRMLS_DC) +{ + if(function->type == ZEND_USER_FUNCTION) { + zend_cleanup_op_array_data((zend_op_array *) function); + } + return 0; +} + +ZEND_API int zend_cleanup_class_data(zend_class_entry **pce TSRMLS_DC) +{ + if((*pce)->type == ZEND_USER_CLASS) { + /* Clean all parts that can contain run-time data */ + /* Note that only run-time accessed data need to be cleaned up, pre-defined data can + not contain objects and thus are not probelmatic */ + zend_hash_clean((*pce)->static_members); + zend_hash_apply(&(*pce)->class_table, (apply_func_t) zend_cleanup_class_data TSRMLS_CC); + zend_hash_apply(&(*pce)->function_table, (apply_func_t) zend_cleanup_function_data TSRMLS_CC); + } + return 0; +} ZEND_API void destroy_zend_class(zend_class_entry **pce) {

« previous php.zend-engine.cvs (#856) next »