diff options
-rw-r--r-- | Zend/zend_compile.h | 1 | ||||
-rw-r--r-- | Zend/zend_constants.c | 14 | ||||
-rw-r--r-- | Zend/zend_execute_API.c | 42 | ||||
-rw-r--r-- | Zend/zend_opcode.c | 16 |
4 files changed, 47 insertions, 26 deletions
diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index 9c94f59109..4ceaf18988 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -517,6 +517,7 @@ 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 int zend_cleanup_function_data_full(zend_function *function TSRMLS_DC); ZEND_API void destroy_zend_function(zend_function *function TSRMLS_DC); ZEND_API void zend_function_dtor(zend_function *function); diff --git a/Zend/zend_constants.c b/Zend/zend_constants.c index b144f0102e..10dbe360b3 100644 --- a/Zend/zend_constants.c +++ b/Zend/zend_constants.c @@ -55,11 +55,13 @@ void zend_copy_constants(HashTable *target, HashTable *source) static int clean_non_persistent_constant(zend_constant *c TSRMLS_DC) { - if (c->flags & CONST_PERSISTENT) { - return EG(full_tables_cleanup) ? 0 : ZEND_HASH_APPLY_STOP; - } else { - return EG(full_tables_cleanup) ? 1 : ZEND_HASH_APPLY_REMOVE; - } + return (c->flags & CONST_PERSISTENT) ? ZEND_HASH_APPLY_STOP : ZEND_HASH_APPLY_REMOVE; +} + + +static int clean_non_persistent_constant_full(zend_constant *c TSRMLS_DC) +{ + return (c->flags & CONST_PERSISTENT) ? ZEND_HASH_APPLY_KEEP : ZEND_HASH_APPLY_REMOVE; } @@ -153,7 +155,7 @@ int zend_shutdown_constants(TSRMLS_D) void clean_non_persistent_constants(TSRMLS_D) { if (EG(full_tables_cleanup)) { - zend_hash_apply(EG(zend_constants), (apply_func_t) clean_non_persistent_constant TSRMLS_CC); + zend_hash_apply(EG(zend_constants), (apply_func_t) clean_non_persistent_constant_full TSRMLS_CC); } else { zend_hash_reverse_apply(EG(zend_constants), (apply_func_t) clean_non_persistent_constant TSRMLS_CC); } diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 5aa35113ab..53d1f0d457 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -95,23 +95,27 @@ static void zend_extension_deactivator(zend_extension *extension TSRMLS_DC) } -static int is_not_internal_function(zend_function *function TSRMLS_DC) +static int clean_non_persistent_function(zend_function *function TSRMLS_DC) { - if (function->type == ZEND_INTERNAL_FUNCTION) { - return EG(full_tables_cleanup) ? 0 : ZEND_HASH_APPLY_STOP; - } else { - return EG(full_tables_cleanup) ? 1 : ZEND_HASH_APPLY_REMOVE; - } + return (function->type == ZEND_INTERNAL_FUNCTION) ? ZEND_HASH_APPLY_STOP : ZEND_HASH_APPLY_REMOVE; } -static int is_not_internal_class(zend_class_entry **ce TSRMLS_DC) +static int clean_non_persistent_function_full(zend_function *function TSRMLS_DC) { - if ((*ce)->type == ZEND_INTERNAL_CLASS) { - return EG(full_tables_cleanup) ? 0 : ZEND_HASH_APPLY_STOP; - } else { - return EG(full_tables_cleanup) ? 1 : ZEND_HASH_APPLY_REMOVE; - } + return (function->type == ZEND_INTERNAL_FUNCTION) ? ZEND_HASH_APPLY_KEEP : ZEND_HASH_APPLY_REMOVE; +} + + +static int clean_non_persistent_class(zend_class_entry **ce TSRMLS_DC) +{ + return ((*ce)->type == ZEND_INTERNAL_CLASS) ? ZEND_HASH_APPLY_STOP : ZEND_HASH_APPLY_REMOVE; +} + + +static int clean_non_persistent_class_full(zend_class_entry **ce TSRMLS_DC) +{ + return ((*ce)->type == ZEND_INTERNAL_CLASS) ? ZEND_HASH_APPLY_KEEP : ZEND_HASH_APPLY_REMOVE; } @@ -251,18 +255,22 @@ void shutdown_executor(TSRMLS_D) 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 TSRMLS_CC); + if (EG(full_tables_cleanup)) { + zend_hash_apply(EG(function_table), (apply_func_t) zend_cleanup_function_data_full TSRMLS_CC); + } else { + zend_hash_reverse_apply(EG(function_table), (apply_func_t) zend_cleanup_function_data TSRMLS_CC); + } zend_hash_apply(EG(class_table), (apply_func_t) zend_cleanup_class_data TSRMLS_CC); zend_ptr_stack_destroy(&EG(argument_stack)); /* Destroy all op arrays */ if (EG(full_tables_cleanup)) { - zend_hash_apply(EG(function_table), (apply_func_t) is_not_internal_function TSRMLS_CC); - zend_hash_apply(EG(class_table), (apply_func_t) is_not_internal_class TSRMLS_CC); + zend_hash_apply(EG(function_table), (apply_func_t) clean_non_persistent_function_full TSRMLS_CC); + zend_hash_apply(EG(class_table), (apply_func_t) clean_non_persistent_class_full TSRMLS_CC); } else { - zend_hash_reverse_apply(EG(function_table), (apply_func_t) is_not_internal_function TSRMLS_CC); - zend_hash_reverse_apply(EG(class_table), (apply_func_t) is_not_internal_class TSRMLS_CC); + zend_hash_reverse_apply(EG(function_table), (apply_func_t) clean_non_persistent_function TSRMLS_CC); + zend_hash_reverse_apply(EG(class_table), (apply_func_t) clean_non_persistent_class TSRMLS_CC); } while (EG(symtable_cache_ptr)>=EG(symtable_cache)) { diff --git a/Zend/zend_opcode.c b/Zend/zend_opcode.c index a71557888a..cd35202de8 100644 --- a/Zend/zend_opcode.c +++ b/Zend/zend_opcode.c @@ -132,8 +132,18 @@ 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; + return ZEND_HASH_APPLY_KEEP; + } else { + return ZEND_HASH_APPLY_STOP; + } +} + +ZEND_API int zend_cleanup_function_data_full(zend_function *function TSRMLS_DC) +{ + if (function->type == ZEND_USER_FUNCTION) { + zend_cleanup_op_array_data((zend_op_array *) function); + } + return ZEND_HASH_APPLY_KEEP; } ZEND_API int zend_cleanup_class_data(zend_class_entry **pce TSRMLS_DC) @@ -142,7 +152,7 @@ ZEND_API int zend_cleanup_class_data(zend_class_entry **pce TSRMLS_DC) /* 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_apply(&(*pce)->function_table, (apply_func_t) zend_cleanup_function_data TSRMLS_CC); + zend_hash_apply(&(*pce)->function_table, (apply_func_t) zend_cleanup_function_data_full TSRMLS_CC); (*pce)->static_members = NULL; } else if (CE_STATIC_MEMBERS(*pce)) { zend_hash_destroy(CE_STATIC_MEMBERS(*pce)); |