Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

- Boost up __autoload() calls by caching the lookup

  • Loading branch information...
commit b7a8297bc1a76330daa6b7d1727cbfbffbe89a5b 1 parent 88b9c69
Marcus Boerger authored
Showing with 21 additions and 1 deletion.
  1. +20 −1 Zend/zend_execute_API.c
  2. +1 −0  Zend/zend_globals.h
View
21 Zend/zend_execute_API.c
@@ -138,6 +138,7 @@ void init_executor(TSRMLS_D)
EG(in_execution) = 0;
EG(in_autoload) = NULL;
+ EG(autoload_func) = NULL;
zend_ptr_stack_init(&EG(argument_stack));
zend_ptr_stack_push(&EG(argument_stack), (void *) NULL);
@@ -878,6 +879,8 @@ ZEND_API int zend_lookup_class(char *name, int name_length, zend_class_entry ***
char *lc_name;
zval *exception;
char dummy = 1;
+ zend_fcall_info fcall_info;
+ zend_fcall_info_cache fcall_cache;
lc_name = do_alloca(name_length + 1);
zend_str_tolower_copy(lc_name, name, name_length);
@@ -911,10 +914,26 @@ ZEND_API int zend_lookup_class(char *name, int name_length, zend_class_entry ***
ZVAL_STRINGL(class_name_ptr, name, name_length, 0);
args[0] = &class_name_ptr;
+
+ fcall_info.size = sizeof(fcall_info);
+ fcall_info.function_table = EG(function_table);
+ fcall_info.function_name = &autoload_function;
+ fcall_info.symbol_table = NULL;
+ fcall_info.retval_ptr_ptr = &retval_ptr;
+ fcall_info.param_count = 1;
+ fcall_info.params = args;
+ fcall_info.object_pp = NULL;
+ fcall_info.no_separation = 1;
+
+ fcall_cache.initialized = EG(autoload_func) ? 1 : 0;
+ fcall_cache.function_handler = EG(autoload_func);
+ fcall_cache.calling_scope = NULL;
+ fcall_cache.object_pp = NULL;
exception = EG(exception);
EG(exception) = NULL;
- retval = call_user_function_ex(EG(function_table), NULL, &autoload_function, &retval_ptr, 1, args, 0, NULL TSRMLS_CC);
+ retval = zend_call_function(&fcall_info, &fcall_cache TSRMLS_CC);
+ EG(autoload_func) = fcall_cache.function_handler;
zend_hash_del(EG(in_autoload), lc_name, name_length+1);
View
1  Zend/zend_globals.h
@@ -192,6 +192,7 @@ struct _zend_executor_globals {
zend_bool in_execution;
HashTable *in_autoload;
+ zend_function *autoload_func;
zend_bool bailout_set;
zend_bool full_tables_cleanup;
zend_bool ze1_compatibility_mode;
Please sign in to comment.
Something went wrong with that request. Please try again.