summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2014-04-22 01:41:40 +0400
committerDmitry Stogov <dmitry@zend.com>2014-04-22 01:41:40 +0400
commit1f181c0f4cce794461bbbed3b580d7d0d0a63ee9 (patch)
treeff90db12533da358416b888ea7f5bea417058672
parenta821009a6e268232037fb3a0945611a337b77d6d (diff)
downloadphp-git-1f181c0f4cce794461bbbed3b580d7d0d0a63ee9.tar.gz
Chiper __autoload() function caching
-rw-r--r--Zend/zend_execute_API.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
index 44e3f08895..0091fea00d 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);