@@ -1873,8 +1873,8 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name)
1873
1873
out ($ f ,"# define ZEND_OPCODE_HANDLER_ARGS_DC \n" );
1874
1874
out ($ f ,"# define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_CC \n" );
1875
1875
out ($ f ,"#else \n" );
1876
- out ($ f ,"# define ZEND_OPCODE_HANDLER_ARGS zend_execute_data *execute_data \n" );
1877
- out ($ f ,"# define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU execute_data \n" );
1876
+ out ($ f ,"# define ZEND_OPCODE_HANDLER_ARGS zend_execute_data *execute_data, const zend_op *opline \n" );
1877
+ out ($ f ,"# define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU execute_data, opline \n" );
1878
1878
out ($ f ,"# define ZEND_OPCODE_HANDLER_ARGS_DC , ZEND_OPCODE_HANDLER_ARGS \n" );
1879
1879
out ($ f ,"# define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_CC , ZEND_OPCODE_HANDLER_ARGS_PASSTHRU \n" );
1880
1880
out ($ f ,"#endif \n" );
@@ -1902,10 +1902,10 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name)
1902
1902
out ($ f ,"# define ZEND_VM_COLD ZEND_COLD ZEND_OPT_SIZE \n" );
1903
1903
}
1904
1904
out ($ f ,"#else \n" );
1905
- out ($ f ,"# define ZEND_OPCODE_HANDLER_RET int \n" );
1905
+ out ($ f ,"# define ZEND_OPCODE_HANDLER_RET const zend_op * \n" );
1906
1906
out ($ f ,"# define ZEND_VM_TAIL_CALL(call) return call \n" );
1907
- out ($ f ,"# define ZEND_VM_CONTINUE() return 0 \n" );
1908
- out ($ f ,"# define ZEND_VM_RETURN() return -1 \n" );
1907
+ out ($ f ,"# define ZEND_VM_CONTINUE() return opline \n" );
1908
+ out ($ f ,"# define ZEND_VM_RETURN() return NULL \n" );
1909
1909
if ($ kind == ZEND_VM_KIND_HYBRID ) {
1910
1910
out ($ f ,"# define ZEND_VM_HOT \n" );
1911
1911
}
@@ -1914,8 +1914,8 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name)
1914
1914
out ($ f ,"\n" );
1915
1915
out ($ f ,"typedef ZEND_OPCODE_HANDLER_RET (ZEND_FASTCALL *opcode_handler_t) (ZEND_OPCODE_HANDLER_ARGS); \n" );
1916
1916
out ($ f ,"\n" );
1917
- out ($ f ,"#define DCL_OPLINE \n" );
1918
1917
out ($ f ,"#ifdef ZEND_VM_IP_GLOBAL_REG \n" );
1918
+ out ($ f ,"# define DCL_OPLINE \n" );
1919
1919
out ($ f ,"# define OPLINE opline \n" );
1920
1920
out ($ f ,"# define USE_OPLINE \n" );
1921
1921
out ($ f ,"# define LOAD_OPLINE() opline = EX(opline) \n" );
@@ -1924,12 +1924,13 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name)
1924
1924
out ($ f ,"# define SAVE_OPLINE() EX(opline) = opline \n" );
1925
1925
out ($ f ,"# define SAVE_OPLINE_EX() SAVE_OPLINE() \n" );
1926
1926
out ($ f ,"#else \n" );
1927
- out ($ f ,"# define OPLINE EX(opline) \n" );
1928
- out ($ f ,"# define USE_OPLINE const zend_op *opline = EX(opline); \n" );
1929
- out ($ f ,"# define LOAD_OPLINE() \n" );
1930
- out ($ f ,"# define LOAD_OPLINE_EX() \n" );
1931
- out ($ f ,"# define LOAD_NEXT_OPLINE() ZEND_VM_INC_OPCODE() \n" );
1932
- out ($ f ,"# define SAVE_OPLINE() \n" );
1927
+ out ($ f ,"# define DCL_OPLINE const zend_op *opline; \n" );
1928
+ out ($ f ,"# define OPLINE opline \n" );
1929
+ out ($ f ,"# define USE_OPLINE \n" );
1930
+ out ($ f ,"# define LOAD_OPLINE() opline = EX(opline) \n" );
1931
+ out ($ f ,"# define LOAD_OPLINE_EX() opline = EX(opline) \n" );
1932
+ out ($ f ,"# define LOAD_NEXT_OPLINE() opline = EX(opline) + 1 \n" );
1933
+ out ($ f ,"# define SAVE_OPLINE() EX(opline) = opline \n" );
1933
1934
out ($ f ,"# define SAVE_OPLINE_EX() \n" );
1934
1935
out ($ f ,"#endif \n" );
1935
1936
out ($ f ,"#define HANDLE_EXCEPTION() ZEND_ASSERT(EG(exception)); LOAD_OPLINE(); ZEND_VM_CONTINUE() \n" );
@@ -1943,9 +1944,9 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name)
1943
1944
out ($ f ,"# define ZEND_VM_ENTER() opline = EG(current_execute_data)->opline; ZEND_VM_ENTER_EX() \n" );
1944
1945
out ($ f ,"# define ZEND_VM_LEAVE() return 2 \n" );
1945
1946
out ($ f ,"#else \n" );
1946
- out ($ f ,"# define ZEND_VM_ENTER_EX() return 1 \n" );
1947
- out ($ f ,"# define ZEND_VM_ENTER() return 1 \n" );
1948
- out ($ f ,"# define ZEND_VM_LEAVE() return 2 \n" );
1947
+ out ($ f ,"# define ZEND_VM_ENTER_EX() return (zend_op*)-(uintptr_t)opline \n" );
1948
+ out ($ f ,"# define ZEND_VM_ENTER() execute_data = EG(current_execute_data); LOAD_OPLINE(); ZEND_VM_ENTER_EX() \n" );
1949
+ out ($ f ,"# define ZEND_VM_LEAVE() return (zend_op*)-(uintptr_t)opline \n" );
1949
1950
out ($ f ,"#endif \n" );
1950
1951
out ($ f ,"#define ZEND_VM_INTERRUPT() ZEND_VM_TAIL_CALL(zend_interrupt_helper " .($ spec ?"_SPEC " :"" )."(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU)); \n" );
1951
1952
out ($ f ,"#define ZEND_VM_LOOP_INTERRUPT() zend_interrupt_helper " .($ spec ?"_SPEC " :"" )."(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); \n" );
@@ -2119,12 +2120,7 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name)
2119
2120
}
2120
2121
break ;
2121
2122
case "ZEND_VM_CONTINUE_LABEL " :
2122
- if ($ kind == ZEND_VM_KIND_CALL || $ kind == ZEND_VM_KIND_HYBRID ) {
2123
- // Only SWITCH dispatch method use it
2124
- out ($ f ,"#if !defined(ZEND_VM_FP_GLOBAL_REG) || !defined(ZEND_VM_IP_GLOBAL_REG) \n" );
2125
- out ($ f ,$ m [1 ]."\tint ret; " .$ m [3 ]."\n" );
2126
- out ($ f ,"#endif \n" );
2127
- } else if ($ kind == ZEND_VM_KIND_SWITCH ) {
2123
+ if ($ kind == ZEND_VM_KIND_SWITCH ) {
2128
2124
// Only SWITCH dispatch method use it
2129
2125
out ($ f ,"zend_vm_continue: " .$ m [3 ]."\n" );
2130
2126
} else {
@@ -2143,16 +2139,17 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name)
2143
2139
case ZEND_VM_KIND_HYBRID :
2144
2140
out ($ f ,"#if (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID) \n" );
2145
2141
out ($ f , $ m [1 ]."HYBRID_SWITCH() " .$ m [3 ]."\n" );
2146
- out ($ f ,"#else \n" );
2142
+ out ($ f ,"#else /* ZEND_VM_KIND != ZEND_VM_KIND_HYBRID */ \n" );
2147
2143
case ZEND_VM_KIND_CALL :
2148
2144
out ($ f ,"#if defined(ZEND_VM_FP_GLOBAL_REG) && defined(ZEND_VM_IP_GLOBAL_REG) \n" );
2149
2145
out ($ f , $ m [1 ]."((opcode_handler_t)OPLINE->handler)(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); \n" );
2150
2146
out ($ f , $ m [1 ]."if (UNEXPECTED(!OPLINE)) " .$ m [3 ]."\n" );
2151
2147
out ($ f ,"#else \n" );
2152
- out ($ f , $ m [1 ]."if (UNEXPECTED((ret = ((opcode_handler_t)OPLINE->handler)(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU)) != 0)) " .$ m [3 ]."\n" );
2148
+ out ($ f , $ m [1 ]."opline = ((opcode_handler_t)opline->handler)(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); \n" );
2149
+ out ($ f , $ m [1 ]."if (UNEXPECTED((intptr_t)OPLINE <= 0)) " .$ m [3 ]."\n" );
2153
2150
out ($ f ,"#endif \n" );
2154
2151
if ($ kind == ZEND_VM_KIND_HYBRID ) {
2155
- out ($ f ,"#endif \n" );
2152
+ out ($ f ,"#endif /* ZEND_VM_KIND != ZEND_VM_KIND_HYBRID */ \n" );
2156
2153
}
2157
2154
break ;
2158
2155
}
@@ -2168,7 +2165,7 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name)
2168
2165
if ($ kind == ZEND_VM_KIND_CALL || $ kind == ZEND_VM_KIND_HYBRID ) {
2169
2166
// Executor is defined as a set of functions
2170
2167
if ($ kind == ZEND_VM_KIND_HYBRID ) {
2171
- out ($ f ,"#else \n" );
2168
+ out ($ f ,"#else /* ZEND_VM_KIND != ZEND_VM_KIND_HYBRID */ \n" );
2172
2169
}
2173
2170
out ($ f ,
2174
2171
"#ifdef ZEND_VM_FP_GLOBAL_REG \n" .
@@ -2178,7 +2175,8 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name)
2178
2175
"# endif \n" .
2179
2176
$ m [1 ]."return; \n" .
2180
2177
"#else \n" .
2181
- $ m [1 ]."if (EXPECTED(ret > 0)) { \n" .
2178
+ $ m [1 ]."if (EXPECTED(opline != NULL)) { \n" .
2179
+ $ m [1 ]."\topline = (zend_op*)-(uintptr_t)opline; \n" .
2182
2180
$ m [1 ]."\texecute_data = EG(current_execute_data); \n" .
2183
2181
$ m [1 ]."\tZEND_VM_LOOP_INTERRUPT_CHECK(); \n" .
2184
2182
$ m [1 ]."} else { \n" .
@@ -2189,7 +2187,7 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name)
2189
2187
$ m [1 ]."} \n" .
2190
2188
"#endif \n" );
2191
2189
if ($ kind == ZEND_VM_KIND_HYBRID ) {
2192
- out ($ f ,"#endif \n" );
2190
+ out ($ f ,"#endif /* ZEND_VM_KIND != ZEND_VM_KIND_HYBRID */ \n" );
2193
2191
}
2194
2192
}
2195
2193
break ;
@@ -2335,6 +2333,9 @@ function gen_vm_opcodes_header(
2335
2333
): string {
2336
2334
$ str = HEADER_TEXT ;
2337
2335
$ str .= "#ifndef ZEND_VM_OPCODES_H \n#define ZEND_VM_OPCODES_H \n\n" ;
2336
+ $ str .= "#include \"Zend/zend_config.h \"\n" ;
2337
+ $ str .= "#include \"Zend/zend_portability.h \"\n" ;
2338
+ $ str .= "\n" ;
2338
2339
$ str .= "#define ZEND_VM_SPEC \t\t" . ZEND_VM_SPEC . "\n" ;
2339
2340
$ str .= "#define ZEND_VM_LINES \t\t" . ZEND_VM_LINES . "\n" ;
2340
2341
$ str .= "#define ZEND_VM_KIND_CALL \t" . ZEND_VM_KIND_CALL . "\n" ;
@@ -2962,6 +2963,7 @@ function gen_vm($def, $skel) {
2962
2963
out ($ f , "\topcode_handler_t handler; \n" );
2963
2964
out ($ f ,"#endif \n" );
2964
2965
}
2966
+ out ($ f , "\tDCL_OPLINE; \n" );
2965
2967
out ($ f , "\tint ret; \n" );
2966
2968
out ($ f , "#ifdef ZEND_VM_IP_GLOBAL_REG \n" );
2967
2969
out ($ f , "\tconst zend_op *orig_opline = opline; \n" );
@@ -2995,8 +2997,13 @@ function gen_vm($def, $skel) {
2995
2997
out ($ f , "\t\tret = -1; \n" );
2996
2998
out ($ f , "\t} \n" );
2997
2999
out ($ f , "#else \n" );
2998
- out ($ f , "\tret = ((opcode_handler_t)OPLINE->handler)(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); \n" );
2999
- out ($ f , "\tSAVE_OPLINE(); \n" );
3000
+ out ($ f , "\topline = ((opcode_handler_t)OPLINE->handler)(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); \n" );
3001
+ out ($ f , "\tif (EXPECTED(opline != NULL)) { \n" );
3002
+ out ($ f , "\t\tret = EG(current_execute_data) != ex ? (int)(EG(current_execute_data)->prev_execute_data != ex) + 1 : 0; \n" );
3003
+ out ($ f , "\t\tSAVE_OPLINE(); \n" );
3004
+ out ($ f , "\t} else { \n" );
3005
+ out ($ f , "\t\tret = -1; \n" );
3006
+ out ($ f , "\t} \n" );
3000
3007
out ($ f , "#endif \n" );
3001
3008
out ($ f , "#ifdef ZEND_VM_FP_GLOBAL_REG \n" );
3002
3009
out ($ f , "\texecute_data = orig_execute_data; \n" );
0 commit comments