From 0639a847ceb0d9fdfcc3c01a39e7686c0397a333 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 6 May 2008 17:00:56 +0000 Subject: [PATCH] Use lazy symbol table initialization for op_arrays called from internal php functions --- Zend/zend_execute_API.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 5aff1bde31..c35d902ec5 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -1090,8 +1090,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS if (fci->symbol_table) { EG(active_symbol_table) = fci->symbol_table; } else { - ALLOC_HASHTABLE(EG(active_symbol_table)); - zend_hash_init(EG(active_symbol_table), 0, NULL, ZVAL_PTR_DTOR, 0); + EG(active_symbol_table) = NULL; } original_return_value = EG(return_value_ptr_ptr); @@ -1100,9 +1099,16 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS EG(active_op_array) = (zend_op_array *) EX(function_state).function; original_opline_ptr = EG(opline_ptr); zend_execute(EG(active_op_array) TSRMLS_CC); - if (!fci->symbol_table) { - zend_hash_destroy(EG(active_symbol_table)); - FREE_HASHTABLE(EG(active_symbol_table)); + if (!fci->symbol_table && EG(active_symbol_table)) { + if (EG(symtable_cache_ptr)>=EG(symtable_cache_limit)) { + zend_hash_destroy(EG(active_symbol_table)); + FREE_HASHTABLE(EG(active_symbol_table)); + } else { + /* clean before putting into the cache, since clean + could call dtors, which could use cached hash */ + zend_hash_clean(EG(active_symbol_table)); + *(++EG(symtable_cache_ptr)) = EG(active_symbol_table); + } } EG(active_symbol_table) = calling_symbol_table; EG(active_op_array) = original_op_array; -- 2.40.0