From: Dmitry Stogov Date: Thu, 17 Apr 2014 12:36:04 +0000 (+0400) Subject: Cache op_array->run_time_cache in zend_execute_data for faster access X-Git-Tag: POST_PHPNG_MERGE~412^2~82^2~10 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5c02e0fc5f06f80d2e894a193c255b39f3e4edb2;p=php Cache op_array->run_time_cache in zend_execute_data for faster access --- diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index bf82b0c1a3..0c3f20f354 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -368,6 +368,7 @@ typedef struct _call_slot { struct _zend_execute_data { struct _zend_op *opline; + void **run_time_cache; zend_function_state function_state; zend_op_array *op_array; zend_object *object; diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index acc22a8ec5..7302aeec34 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -1657,6 +1657,7 @@ static zend_always_inline zend_execute_data *i_create_execute_data_from_op_array if (!op_array->run_time_cache && op_array->last_cache_slot) { op_array->run_time_cache = ecalloc(op_array->last_cache_slot, sizeof(void*)); } + EX(run_time_cache) = op_array->run_time_cache; if (EG(active_symbol_table)) { zend_attach_symbol_table(TSRMLS_C); diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h index 747b116e7f..417f3acbd9 100644 --- a/Zend/zend_execute.h +++ b/Zend/zend_execute.h @@ -346,20 +346,37 @@ void zend_clean_and_cache_symbol_table(zend_array *symbol_table TSRMLS_DC); void zend_free_compiled_variables(zend_execute_data *execute_data TSRMLS_DC); #define CACHED_PTR(num) \ - EG(active_op_array)->run_time_cache[(num)] + EX(run_time_cache)[(num)] #define CACHE_PTR(num, ptr) do { \ - EG(active_op_array)->run_time_cache[(num)] = (ptr); \ + EX(run_time_cache)[(num)] = (ptr); \ } while (0) #define CACHED_POLYMORPHIC_PTR(num, ce) \ - ((EG(active_op_array)->run_time_cache[(num)] == (ce)) ? \ - EG(active_op_array)->run_time_cache[(num) + 1] : \ + ((EX(run_time_cache)[(num)] == (ce)) ? \ + EX(run_time_cache)[(num) + 1] : \ NULL) #define CACHE_POLYMORPHIC_PTR(num, ce, ptr) do { \ - EG(active_op_array)->run_time_cache[(num)] = (ce); \ - EG(active_op_array)->run_time_cache[(num) + 1] = (ptr); \ + EX(run_time_cache)[(num)] = (ce); \ + EX(run_time_cache)[(num) + 1] = (ptr); \ + } while (0) + +#define CACHED_PTR_EX(op_array, num) \ + (op_array)->run_time_cache[(num)] + +#define CACHE_PTR_EX(op_array, num, ptr) do { \ + (op_array)->run_time_cache[(num)] = (ptr); \ + } while (0) + +#define CACHED_POLYMORPHIC_PTR_EX(op_array, num, ce) \ + (((op_array)->run_time_cache[(num)] == (ce)) ? \ + (op_array)->run_time_cache[(num) + 1] : \ + NULL) + +#define CACHE_POLYMORPHIC_PTR_EX(op_array, num, ce, ptr) do { \ + (op_array)->run_time_cache[(num)] = (ce); \ + (op_array)->run_time_cache[(num) + 1] = (ptr); \ } while (0) END_EXTERN_C() diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c index beea7bdb16..47ee60f5b8 100644 --- a/Zend/zend_object_handlers.c +++ b/Zend/zend_object_handlers.c @@ -271,7 +271,7 @@ static zend_always_inline struct _zend_property_info *zend_get_property_info_qui zend_property_info *scope_property_info; zend_bool denied_access = 0; - if (cache_slot != -1 && (property_info = CACHED_POLYMORPHIC_PTR(cache_slot, ce)) != NULL) { + if (cache_slot != -1 && (property_info = CACHED_POLYMORPHIC_PTR_EX(EG(active_op_array), cache_slot, ce)) != NULL) { return property_info; } @@ -303,7 +303,7 @@ static zend_always_inline struct _zend_property_info *zend_get_property_info_qui zend_error(E_STRICT, "Accessing static property %s::$%s as non static", ce->name->val, member->val); } if (cache_slot != -1) { - CACHE_POLYMORPHIC_PTR(cache_slot, ce, property_info); + CACHE_POLYMORPHIC_PTR_EX(EG(active_op_array), cache_slot, ce, property_info); } return property_info; } @@ -319,7 +319,7 @@ static zend_always_inline struct _zend_property_info *zend_get_property_info_qui && (scope_property_info = zend_hash_find_ptr(&EG(scope)->properties_info, member)) != NULL && scope_property_info->flags & ZEND_ACC_PRIVATE) { if (cache_slot != -1) { - CACHE_POLYMORPHIC_PTR(cache_slot, ce, scope_property_info); + CACHE_POLYMORPHIC_PTR_EX(EG(active_op_array), cache_slot, ce, scope_property_info); } return scope_property_info; } else if (property_info) { @@ -332,7 +332,7 @@ static zend_always_inline struct _zend_property_info *zend_get_property_info_qui } else { /* fall through, return property_info... */ if (cache_slot != -1) { - CACHE_POLYMORPHIC_PTR(cache_slot, ce, property_info); + CACHE_POLYMORPHIC_PTR_EX(EG(active_op_array), cache_slot, ce, property_info); } } } else { @@ -1242,7 +1242,7 @@ ZEND_API zval *zend_std_get_static_property(zend_class_entry *ce, zend_string *p zend_property_info *property_info; if (UNEXPECTED(cache_slot == -1) || - (property_info = CACHED_POLYMORPHIC_PTR(cache_slot, ce)) == NULL) { + (property_info = CACHED_POLYMORPHIC_PTR_EX(EG(active_op_array), cache_slot, ce)) == NULL) { if (UNEXPECTED((property_info = zend_hash_find_ptr(&ce->properties_info, property_name)) == NULL)) { if (!silent) { @@ -1268,7 +1268,7 @@ ZEND_API zval *zend_std_get_static_property(zend_class_entry *ce, zend_string *p zend_update_class_constants(ce TSRMLS_CC); if (EXPECTED(cache_slot != -1)) { - CACHE_POLYMORPHIC_PTR(cache_slot, ce, property_info); + CACHE_POLYMORPHIC_PTR_EX(EG(active_op_array), cache_slot, ce, property_info); } }