cvs: ZendEngine2(PHP_5_3) / zend_execute_API.c

[email protected] ("Dmitry Stogov")
Newsgroups php.zend-engine.cvs
Message-ID <cvsdmitry1210093257@cvsserver>
dmitry		Tue May  6 17:00:57 2008 UTC

  Modified files:              (Branch: PHP_5_3)
    /ZendEngine2	zend_execute_API.c 
  Log:
  Use lazy symbol table initialization for op_arrays called from internal php functions
  
  
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_execute_API.c?r1=1.331.2.20.2.24.2.38&r2=1.331.2.20.2.24.2.39&diff_format=u
Index: ZendEngine2/zend_execute_API.c
diff -u ZendEngine2/zend_execute_API.c:1.331.2.20.2.24.2.38 ZendEngine2/zend_execute_API.c:1.331.2.20.2.24.2.39
--- ZendEngine2/zend_execute_API.c:1.331.2.20.2.24.2.38	Tue May  6 16:03:16 2008
+++ ZendEngine2/zend_execute_API.c	Tue May  6 17:00:56 2008
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_execute_API.c,v 1.331.2.20.2.24.2.38 2008/05/06 16:03:16 dmitry Exp $ */
+/* $Id: zend_execute_API.c,v 1.331.2.20.2.24.2.39 2008/05/06 17:00:56 dmitry Exp $ */
 
 #include <stdio.h>
 #include <signal.h>
@@ -1090,8 +1090,7 @@
 		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 @@
 		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;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.