]> granicus.if.org Git - php/commitdiff
micro-optimization
authorDmitry Stogov <dmitry@zend.com>
Mon, 10 Jun 2019 13:43:20 +0000 (16:43 +0300)
committerDmitry Stogov <dmitry@zend.com>
Mon, 10 Jun 2019 13:43:20 +0000 (16:43 +0300)
Zend/zend_execute.c
Zend/zend_vm_def.h
Zend/zend_vm_execute.h
Zend/zend_vm_gen.php

index d666d6af80db15a0d5eba385e590acae74250e54..3054082985306d6cdd2ec748136609e38f9cedcc 100644 (file)
@@ -3502,9 +3502,6 @@ static zend_always_inline void i_init_func_execute_data(zend_op_array *op_array,
        EX(run_time_cache) = RUN_TIME_CACHE(op_array);
 
        EG(current_execute_data) = execute_data;
-#if defined(ZEND_VM_IP_GLOBAL_REG) && ((ZEND_VM_KIND == ZEND_VM_KIND_CALL) || (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID))
-       EX(opline) = opline;
-#endif
 }
 /* }}} */
 
index 7f0e97a77add46126f905fe2365de9effb628ead..bfcd715aece0f2a4457ea2207ddf6ac2798700fc 100644 (file)
@@ -828,12 +828,12 @@ ZEND_VM_COLD_HELPER(zend_this_not_in_object_context_helper, ANY, ANY)
        HANDLE_EXCEPTION();
 }
 
-ZEND_VM_COLD_HELPER(zend_abstract_method_helper, ANY, ANY, zend_function *fbc)
+ZEND_VM_COLD_HELPER(zend_abstract_method_helper, ANY, ANY, zend_function *_fbc)
 {
        USE_OPLINE
 
        SAVE_OPLINE();
-       zend_throw_error(NULL, "Cannot call abstract method %s::%s()", ZSTR_VAL(fbc->common.scope->name), ZSTR_VAL(fbc->common.function_name));
+       zend_throw_error(NULL, "Cannot call abstract method %s::%s()", ZSTR_VAL(_fbc->common.scope->name), ZSTR_VAL(_fbc->common.function_name));
        UNDEF_RESULT();
        HANDLE_EXCEPTION();
 }
@@ -3842,7 +3842,7 @@ ZEND_VM_HOT_HANDLER(130, ZEND_DO_UCALL, ANY, ANY, SPEC(RETVAL))
        call->prev_execute_data = execute_data;
        execute_data = call;
        i_init_func_execute_data(&fbc->op_array, ret, 0 EXECUTE_DATA_CC);
-       LOAD_OPLINE();
+       LOAD_OPLINE_EX();
 
        ZEND_VM_ENTER_EX();
 }
@@ -3866,7 +3866,7 @@ ZEND_VM_HOT_HANDLER(131, ZEND_DO_FCALL_BY_NAME, ANY, ANY, SPEC(RETVAL))
                call->prev_execute_data = execute_data;
                execute_data = call;
                i_init_func_execute_data(&fbc->op_array, ret, 0 EXECUTE_DATA_CC);
-               LOAD_OPLINE();
+               LOAD_OPLINE_EX();
 
                ZEND_VM_ENTER_EX();
        } else {
@@ -3934,7 +3934,7 @@ ZEND_VM_HOT_HANDLER(60, ZEND_DO_FCALL, ANY, ANY, SPEC(RETVAL))
        EX(call) = call->prev_execute_data;
        if (UNEXPECTED((fbc->common.fn_flags & (ZEND_ACC_ABSTRACT|ZEND_ACC_DEPRECATED)) != 0)) {
                if (UNEXPECTED((fbc->common.fn_flags & ZEND_ACC_ABSTRACT) != 0)) {
-                       ZEND_VM_DISPATCH_TO_HELPER(zend_abstract_method_helper, fbc, fbc);
+                       ZEND_VM_DISPATCH_TO_HELPER(zend_abstract_method_helper, _fbc, fbc);
                } else {
                        zend_deprecated_function(fbc);
                        if (UNEXPECTED(EG(exception) != NULL)) {
@@ -3955,11 +3955,11 @@ ZEND_VM_HOT_HANDLER(60, ZEND_DO_FCALL, ANY, ANY, SPEC(RETVAL))
                i_init_func_execute_data(&fbc->op_array, ret, 1 EXECUTE_DATA_CC);
 
                if (EXPECTED(zend_execute_ex == execute_ex)) {
-                       LOAD_OPLINE();
+                       LOAD_OPLINE_EX();
                        ZEND_VM_ENTER_EX();
                } else {
                        execute_data = EX(prev_execute_data);
-                       LOAD_OPLINE();
+                       SAVE_OPLINE_EX();
                        ZEND_ADD_CALL_FLAG(call, ZEND_CALL_TOP);
                        zend_execute_ex(call);
                }
@@ -8050,11 +8050,11 @@ ZEND_VM_HANDLER(158, ZEND_CALL_TRAMPOLINE, ANY, ANY)
                execute_data = call;
                i_init_func_execute_data(&fbc->op_array, ret, 0 EXECUTE_DATA_CC);
                if (EXPECTED(zend_execute_ex == execute_ex)) {
-                       LOAD_OPLINE();
+                       LOAD_OPLINE_EX();
                        ZEND_VM_ENTER_EX();
                } else {
                        execute_data = EX(prev_execute_data);
-                       LOAD_OPLINE();
+                       SAVE_OPLINE_EX();
                        ZEND_ADD_CALL_FLAG(call, ZEND_CALL_TOP);
                        zend_execute_ex(call);
                }
index bc396c60dacd4e7cefe1e054739caf9132303a30..1394bde30b22134eaaa99a4ebc8fa9d77ec06bcc 100644 (file)
@@ -398,19 +398,24 @@ typedef ZEND_OPCODE_HANDLER_RET (ZEND_FASTCALL *opcode_handler_t) (ZEND_OPCODE_H
 #undef LOAD_OPLINE
 #undef LOAD_OPLINE_EX
 #undef SAVE_OPLINE
+#undef SAVE_OPLINE_EX
 #define DCL_OPLINE
 #ifdef ZEND_VM_IP_GLOBAL_REG
 # define OPLINE opline
 # define USE_OPLINE
 # define LOAD_OPLINE() opline = EX(opline)
+# define LOAD_OPLINE_EX()
 # define LOAD_NEXT_OPLINE() opline = EX(opline) + 1
 # define SAVE_OPLINE() EX(opline) = opline
+# define SAVE_OPLINE_EX() SAVE_OPLINE()
 #else
 # define OPLINE EX(opline)
 # define USE_OPLINE const zend_op *opline = EX(opline);
 # define LOAD_OPLINE()
+# define LOAD_OPLINE_EX()
 # define LOAD_NEXT_OPLINE() ZEND_VM_INC_OPCODE()
 # define SAVE_OPLINE()
+# define SAVE_OPLINE_EX()
 #endif
 #undef HANDLE_EXCEPTION
 #undef HANDLE_EXCEPTION_LEAVE
@@ -460,12 +465,12 @@ static zend_never_inline ZEND_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_th
        HANDLE_EXCEPTION();
 }
 
-static zend_never_inline ZEND_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_abstract_method_helper_SPEC(zend_function *fbc ZEND_OPCODE_HANDLER_ARGS_DC)
+static zend_never_inline ZEND_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_abstract_method_helper_SPEC(zend_function *_fbc ZEND_OPCODE_HANDLER_ARGS_DC)
 {
        USE_OPLINE
 
        SAVE_OPLINE();
-       zend_throw_error(NULL, "Cannot call abstract method %s::%s()", ZSTR_VAL(fbc->common.scope->name), ZSTR_VAL(fbc->common.function_name));
+       zend_throw_error(NULL, "Cannot call abstract method %s::%s()", ZSTR_VAL(_fbc->common.scope->name), ZSTR_VAL(_fbc->common.function_name));
        UNDEF_RESULT();
        HANDLE_EXCEPTION();
 }
@@ -1064,7 +1069,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_DO_UCALL_SPEC_RETV
        call->prev_execute_data = execute_data;
        execute_data = call;
        i_init_func_execute_data(&fbc->op_array, ret, 0 EXECUTE_DATA_CC);
-       LOAD_OPLINE();
+       LOAD_OPLINE_EX();
 
        ZEND_VM_ENTER_EX();
 }
@@ -1087,7 +1092,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_DO_UCALL_SPEC_RETV
        call->prev_execute_data = execute_data;
        execute_data = call;
        i_init_func_execute_data(&fbc->op_array, ret, 0 EXECUTE_DATA_CC);
-       LOAD_OPLINE();
+       LOAD_OPLINE_EX();
 
        ZEND_VM_ENTER_EX();
 }
@@ -1111,7 +1116,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_DO_FCALL_BY_NAME_S
                call->prev_execute_data = execute_data;
                execute_data = call;
                i_init_func_execute_data(&fbc->op_array, ret, 0 EXECUTE_DATA_CC);
-               LOAD_OPLINE();
+               LOAD_OPLINE_EX();
 
                ZEND_VM_ENTER_EX();
        } else {
@@ -1187,7 +1192,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_DO_FCALL_BY_NAME_S
                call->prev_execute_data = execute_data;
                execute_data = call;
                i_init_func_execute_data(&fbc->op_array, ret, 0 EXECUTE_DATA_CC);
-               LOAD_OPLINE();
+               LOAD_OPLINE_EX();
 
                ZEND_VM_ENTER_EX();
        } else {
@@ -1276,11 +1281,11 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_DO_FCALL_SPEC_RETV
                i_init_func_execute_data(&fbc->op_array, ret, 1 EXECUTE_DATA_CC);
 
                if (EXPECTED(zend_execute_ex == execute_ex)) {
-                       LOAD_OPLINE();
+                       LOAD_OPLINE_EX();
                        ZEND_VM_ENTER_EX();
                } else {
                        execute_data = EX(prev_execute_data);
-                       LOAD_OPLINE();
+                       SAVE_OPLINE_EX();
                        ZEND_ADD_CALL_FLAG(call, ZEND_CALL_TOP);
                        zend_execute_ex(call);
                }
@@ -1386,11 +1391,11 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_DO_FCALL_SPEC_RETV
                i_init_func_execute_data(&fbc->op_array, ret, 1 EXECUTE_DATA_CC);
 
                if (EXPECTED(zend_execute_ex == execute_ex)) {
-                       LOAD_OPLINE();
+                       LOAD_OPLINE_EX();
                        ZEND_VM_ENTER_EX();
                } else {
                        execute_data = EX(prev_execute_data);
-                       LOAD_OPLINE();
+                       SAVE_OPLINE_EX();
                        ZEND_ADD_CALL_FLAG(call, ZEND_CALL_TOP);
                        zend_execute_ex(call);
                }
@@ -2430,11 +2435,11 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CALL_TRAMPOLINE_SPEC_HANDLER(Z
                execute_data = call;
                i_init_func_execute_data(&fbc->op_array, ret, 0 EXECUTE_DATA_CC);
                if (EXPECTED(zend_execute_ex == execute_ex)) {
-                       LOAD_OPLINE();
+                       LOAD_OPLINE_EX();
                        ZEND_VM_ENTER_EX();
                } else {
                        execute_data = EX(prev_execute_data);
-                       LOAD_OPLINE();
+                       SAVE_OPLINE_EX();
                        ZEND_ADD_CALL_FLAG(call, ZEND_CALL_TOP);
                        zend_execute_ex(call);
                }
index d5a27e337177b6cae08c84b2e5788ba6755c3ee1..2e0ad0b2c1c948f165acd0edf06ffdc744d21995 100755 (executable)
@@ -1947,19 +1947,24 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name)
                                                        out($f,"#undef LOAD_OPLINE\n");
                                                        out($f,"#undef LOAD_OPLINE_EX\n");
                                                        out($f,"#undef SAVE_OPLINE\n");
+                                                       out($f,"#undef SAVE_OPLINE_EX\n");
                                                        out($f,"#define DCL_OPLINE\n");
                                                        out($f,"#ifdef ZEND_VM_IP_GLOBAL_REG\n");
                                                        out($f,"# define OPLINE opline\n");
                                                        out($f,"# define USE_OPLINE\n");
                                                        out($f,"# define LOAD_OPLINE() opline = EX(opline)\n");
+                                                       out($f,"# define LOAD_OPLINE_EX()\n");
                                                        out($f,"# define LOAD_NEXT_OPLINE() opline = EX(opline) + 1\n");
                                                        out($f,"# define SAVE_OPLINE() EX(opline) = opline\n");
+                                                       out($f,"# define SAVE_OPLINE_EX() SAVE_OPLINE()\n");
                                                        out($f,"#else\n");
                                                        out($f,"# define OPLINE EX(opline)\n");
                                                        out($f,"# define USE_OPLINE const zend_op *opline = EX(opline);\n");
                                                        out($f,"# define LOAD_OPLINE()\n");
+                                                       out($f,"# define LOAD_OPLINE_EX()\n");
                                                        out($f,"# define LOAD_NEXT_OPLINE() ZEND_VM_INC_OPCODE()\n");
                                                        out($f,"# define SAVE_OPLINE()\n");
+                                                       out($f,"# define SAVE_OPLINE_EX()\n");
                                                        out($f,"#endif\n");
                                                        out($f,"#undef HANDLE_EXCEPTION\n");
                                                        out($f,"#undef HANDLE_EXCEPTION_LEAVE\n");
@@ -1996,8 +2001,10 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name)
                                                        out($f,"#undef DCL_OPLINE\n");
                                                        out($f,"#undef USE_OPLINE\n");
                                                        out($f,"#undef LOAD_OPLINE\n");
+                                                       out($f,"#undef LOAD_OPLINE_EX\n");
                                                        out($f,"#undef LOAD_NEXT_OPLINE\n");
                                                        out($f,"#undef SAVE_OPLINE\n");
+                                                       out($f,"#undef SAVE_OPLINE_EX\n");
                                                        out($f,"#define OPLINE opline\n");
                                                        out($f,"#ifdef ZEND_VM_IP_GLOBAL_REG\n");
                                                        out($f,"# define DCL_OPLINE register const zend_op *opline __asm__(ZEND_VM_IP_GLOBAL_REG);\n");
@@ -2006,8 +2013,10 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name)
                                                        out($f,"#endif\n");
                                                        out($f,"#define USE_OPLINE\n");
                                                        out($f,"#define LOAD_OPLINE() opline = EX(opline)\n");
+                                                       out($f,"# define LOAD_OPLINE_EX() LOAD_OPLINE()\n");
                                                        out($f,"#define LOAD_NEXT_OPLINE() opline = EX(opline) + 1\n");
                                                        out($f,"#define SAVE_OPLINE() EX(opline) = opline\n");
+                                                       out($f,"#define SAVE_OPLINE_EX()\n");
                                                        out($f,"#undef HANDLE_EXCEPTION\n");
                                                        out($f,"#undef HANDLE_EXCEPTION_LEAVE\n");
                                                        out($f,"#define HANDLE_EXCEPTION() LOAD_OPLINE(); ZEND_VM_CONTINUE()\n");
@@ -2028,8 +2037,10 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name)
                                                        out($f,"#undef DCL_OPLINE\n");
                                                        out($f,"#undef USE_OPLINE\n");
                                                        out($f,"#undef LOAD_OPLINE\n");
+                                                       out($f,"#undef LOAD_OPLINE_EX\n");
                                                        out($f,"#undef LOAD_NEXT_OPLINE\n");
                                                        out($f,"#undef SAVE_OPLINE\n");
+                                                       out($f,"#undef SAVE_OPLINE_EX\n");
                                                        out($f,"#define OPLINE opline\n");
                                                        out($f,"#ifdef ZEND_VM_IP_GLOBAL_REG\n");
                                                        out($f,"# define DCL_OPLINE register const zend_op *opline __asm__(ZEND_VM_IP_GLOBAL_REG);\n");
@@ -2038,8 +2049,10 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name)
                                                        out($f,"#endif\n");
                                                        out($f,"#define USE_OPLINE\n");
                                                        out($f,"#define LOAD_OPLINE() opline = EX(opline)\n");
+                                                       out($f,"#define LOAD_OPLINE_EX() LOAD_OPLINE()\n");
                                                        out($f,"#define LOAD_NEXT_OPLINE() opline = EX(opline) + 1\n");
                                                        out($f,"#define SAVE_OPLINE() EX(opline) = opline\n");
+                                                       out($f,"#define SAVE_OPLINE_EX()\n");
                                                        out($f,"#undef HANDLE_EXCEPTION\n");
                                                        out($f,"#undef HANDLE_EXCEPTION_LEAVE\n");
                                                        if (ZEND_VM_SPEC) {
@@ -3059,14 +3072,18 @@ function gen_vm($def, $skel) {
                out($f,"#undef DCL_OPLINE\n");
                out($f,"#undef USE_OPLINE\n");
                out($f,"#undef LOAD_OPLINE\n");
+               out($f,"#undef LOAD_OPLINE_EX\n");
                out($f,"#undef LOAD_NEXT_OPLINE\n");
                out($f,"#undef SAVE_OPLINE\n");
+               out($f,"#undef SAVE_OPLINE_EX\n");
                out($f,"#define OPLINE EX(opline)\n");
                out($f,"#define DCL_OPLINE\n");
                out($f,"#define USE_OPLINE const zend_op *opline = EX(opline);\n");
                out($f,"#define LOAD_OPLINE()\n");
+               out($f,"#define LOAD_OPLINE_EX()\n");
                out($f,"#define LOAD_NEXT_OPLINE() ZEND_VM_INC_OPCODE()\n");
                out($f,"#define SAVE_OPLINE()\n");
+               out($f,"#define SAVE_OPLINE_EX()\n");
                out($f,"#undef HANDLE_EXCEPTION\n");
                out($f,"#undef HANDLE_EXCEPTION_LEAVE\n");
                out($f,"#define HANDLE_EXCEPTION() LOAD_OPLINE(); ZEND_VM_CONTINUE()\n");