com php-src: Chiper __autoload() function caching : Zend/zend_execute_API.c
| From: | Dmitry Stogov | Date: | Mon, 21 Apr 2014 21:41:40 +0000 |
| Subject: | com php-src: Chiper __autoload() function caching : Zend/zend_execute_API.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-77322@lists.php.net to get a copy of this message | ||
Commit: 1f181c0f4cce794461bbbed3b580d7d0d0a63ee9
Author: Dmitry Stogov <dmitry@zend.com> Tue, 22 Apr 2014 01:41:40 +0400
Parents: a821009a6e268232037fb3a0945611a337b77d6d
Branches: phpng
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=1f181c0f4cce794461bbbed3b580d7d0d0a63ee9
Log:
Chiper __autoload() function caching
Changed paths:
M Zend/zend_execute_API.c
Diff:
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
index 44e3f08..0091fea 100644
--- a/Zend/zend_execute_API.c
+++ b/Zend/zend_execute_API.c
@@ -1072,6 +1072,19 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, const zval
*k
return NULL;
}
+ if (!EG(autoload_func)) {
+ zend_function *func = zend_hash_str_find_ptr(EG(function_table), ZEND_AUTOLOAD_FUNC_NAME,
sizeof(ZEND_AUTOLOAD_FUNC_NAME) - 1);
+ if (func) {
+ EG(autoload_func) = func;
+ } else {
+ if (!key) {
+ STR_FREE(lc_name);
+ }
+ return NULL;
+ }
+
+ }
+
/* Verify class name before passing it to __autoload() */
if (strspn(name->val,
"0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377\\")
!= name->len) {
if (!key) {
@@ -1102,7 +1115,7 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, const zval
*k
fcall_info.size = sizeof(fcall_info);
fcall_info.function_table = EG(function_table);
- ZVAL_STRINGL(&fcall_info.function_name, ZEND_AUTOLOAD_FUNC_NAME,
sizeof(ZEND_AUTOLOAD_FUNC_NAME) - 1);
+ ZVAL_STR(&fcall_info.function_name, STR_COPY(EG(autoload_func)->common.function_name));
fcall_info.symbol_table = NULL;
fcall_info.retval = &local_retval;
fcall_info.param_count = 1;
@@ -1110,7 +1123,7 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, const zval
*k
fcall_info.object = NULL;
fcall_info.no_separation = 1;
- fcall_cache.initialized = EG(autoload_func) ? 1 : 0;
+ fcall_cache.initialized = 1;
fcall_cache.function_handler = EG(autoload_func);
fcall_cache.calling_scope = NULL;
fcall_cache.called_scope = NULL;
@@ -1120,8 +1133,6 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, const zval
*k
retval = zend_call_function(&fcall_info, &fcall_cache TSRMLS_CC);
zend_exception_restore(TSRMLS_C);
- EG(autoload_func) = fcall_cache.function_handler;
-
zval_ptr_dtor(&args[0]);
zval_dtor(&fcall_info.function_name);