]> granicus.if.org Git - php/commitdiff
Use CALL_INFO flag to check if we need to destroy symbol_table.
authorDmitry Stogov <dmitry@zend.com>
Thu, 31 Mar 2016 15:47:25 +0000 (18:47 +0300)
committerDmitry Stogov <dmitry@zend.com>
Thu, 31 Mar 2016 15:47:25 +0000 (18:47 +0300)
This saves one memory load on most RETURN opcodes.

Zend/zend_compile.h
Zend/zend_execute_API.c
Zend/zend_vm_def.h
Zend/zend_vm_execute.h

index b3ba352df88ea2de5c8eb7c55fdca18c1490014e..90c5c8b613b7e0a72602556d87dd36db9c061ebb 100644 (file)
@@ -468,7 +468,7 @@ struct _zend_execute_data {
 #define ZEND_CALL_TOP                (1 << 1)
 #define ZEND_CALL_FREE_EXTRA_ARGS    (1 << 2) /* equal to IS_TYPE_REFCOUNTED */
 #define ZEND_CALL_CTOR               (1 << 3)
-/* Unused flag (1 << 4) */
+#define ZEND_CALL_FREE_SYMBOL_TABLE  (1 << 4)
 #define ZEND_CALL_CLOSURE            (1 << 5)
 #define ZEND_CALL_RELEASE_THIS       (1 << 6)
 #define ZEND_CALL_ALLOCATED          (1 << 7)
index dc2ce46a7b90308607d0dfdccab2b1b858e3874b..c83761cf89ff1acaf199f55406ff125bcf5a75f7 100644 (file)
@@ -1480,6 +1480,7 @@ ZEND_API zend_array *zend_rebuild_symbol_table(void) /* {{{ */
                return ex->symbol_table;
        }
 
+       ZEND_ADD_CALL_FLAG(ex, ZEND_CALL_FREE_SYMBOL_TABLE);
        if (EG(symtable_cache_ptr) >= EG(symtable_cache)) {
                /*printf("Cache hit!  Reusing %x\n", symtable_cache[symtable_cache_ptr]);*/
                symbol_table = ex->symbol_table = *(EG(symtable_cache_ptr)--);
index 2557509381fad950f8931eb83124eca2d37a9f13..b4303954cec26f88e35fee24c4100a5d338e352f 100644 (file)
@@ -2521,7 +2521,7 @@ ZEND_VM_HELPER(zend_leave_helper, ANY, ANY)
                zend_object *object;
 
                i_free_compiled_variables(execute_data);
-               if (UNEXPECTED(EX(symbol_table) != NULL)) {
+               if (UNEXPECTED(call_info & ZEND_CALL_FREE_SYMBOL_TABLE)) {
                        zend_clean_and_cache_symbol_table(EX(symbol_table));
                }
                zend_vm_stack_free_extra_args_ex(call_info, execute_data);
@@ -2579,7 +2579,7 @@ ZEND_VM_HELPER(zend_leave_helper, ANY, ANY)
        } else {
                if (ZEND_CALL_KIND_EX(call_info) == ZEND_CALL_TOP_FUNCTION) {
                        i_free_compiled_variables(execute_data);
-                       if (UNEXPECTED(EX(symbol_table) != NULL)) {
+                       if (UNEXPECTED(call_info & ZEND_CALL_FREE_SYMBOL_TABLE)) {
                                zend_clean_and_cache_symbol_table(EX(symbol_table));
                        }
                        zend_vm_stack_free_extra_args_ex(call_info, execute_data);
index ac7ac1580e1f8a9d713e0be1edaf45639ce37269..69df98c6602b0905cc47652b89691d8c0c8fb985 100644 (file)
@@ -478,7 +478,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_leave_helper_SPEC(ZEND_OPCODE_
                zend_object *object;
 
                i_free_compiled_variables(execute_data);
-               if (UNEXPECTED(EX(symbol_table) != NULL)) {
+               if (UNEXPECTED(call_info & ZEND_CALL_FREE_SYMBOL_TABLE)) {
                        zend_clean_and_cache_symbol_table(EX(symbol_table));
                }
                zend_vm_stack_free_extra_args_ex(call_info, execute_data);
@@ -536,7 +536,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_leave_helper_SPEC(ZEND_OPCODE_
        } else {
                if (ZEND_CALL_KIND_EX(call_info) == ZEND_CALL_TOP_FUNCTION) {
                        i_free_compiled_variables(execute_data);
-                       if (UNEXPECTED(EX(symbol_table) != NULL)) {
+                       if (UNEXPECTED(call_info & ZEND_CALL_FREE_SYMBOL_TABLE)) {
                                zend_clean_and_cache_symbol_table(EX(symbol_table));
                        }
                        zend_vm_stack_free_extra_args_ex(call_info, execute_data);