]> granicus.if.org Git - php/commitdiff
Cache op_array->run_time_cache in zend_execute_data for faster access
authorDmitry Stogov <dmitry@zend.com>
Thu, 17 Apr 2014 12:36:04 +0000 (16:36 +0400)
committerDmitry Stogov <dmitry@zend.com>
Thu, 17 Apr 2014 12:36:04 +0000 (16:36 +0400)
Zend/zend_compile.h
Zend/zend_execute.c
Zend/zend_execute.h
Zend/zend_object_handlers.c

index bf82b0c1a359341a8a544af2d87925adbd705fe9..0c3f20f354dd952cac92e69b3a7d9d797941e766 100644 (file)
@@ -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;
index acc22a8ec530fc4047c2b3959638507802b94c16..7302aeec340ac0ea591b7b007db2a20afb58faab 100644 (file)
@@ -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);
index 747b116e7fa205cb23eb975d4bbfab4c359ac225..417f3acbd9eb853d2e10a9b825522737026cf255 100644 (file)
@@ -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()
index beea7bdb16722f4b865a2900f4302b7e6f17c653..47ee60f5b8ea42146c962a9e31b0d5cb50134f0b 100644 (file)
@@ -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);
                }
        }