@@ -738,7 +738,7 @@ function format_condition($condition) {
738
738
}
739
739
740
740
// Generates code for opcode handler or helper
741
- function gen_code ($ f , $ spec , $ kind , $ export , $ code , $ op1 , $ op2 , $ name , $ extra_spec =null ) {
741
+ function gen_code ($ f , $ spec , $ kind , $ code , $ op1 , $ op2 , $ name , $ extra_spec =null ) {
742
742
global $ op1_type , $ op2_type , $ op1_get_zval_ptr , $ op2_get_zval_ptr ,
743
743
$ op1_get_zval_ptr_deref , $ op2_get_zval_ptr_deref ,
744
744
$ op1_get_zval_ptr_undef , $ op2_get_zval_ptr_undef ,
@@ -796,8 +796,6 @@ function gen_code($f, $spec, $kind, $export, $code, $op1, $op2, $name, $extra_sp
796
796
"/^#(\s*)if\s+0\s*&&.*[^ \\\\]$/m " => "# \\1if 0 " ,
797
797
"/^#(\s*)elif\s+1\s* \\| \\|.*[^ \\\\]$/m " => "# \\1elif 1 " ,
798
798
"/^#(\s*)elif\s+0\s*&&.*[^ \\\\]$/m " => "# \\1elif 0 " ,
799
- "/^#(\s*)ifdef\s+ZEND_VM_EXPORT\s* \n/m " => $ export ?"# \\1if 1 \n" :"# \\1if 0 \n" ,
800
- "/^#(\s*)ifndef\s+ZEND_VM_EXPORT\s* \n/m " => $ export ?"# \\1if 0 \n" :"# \\1if 1 \n" ,
801
799
"/OP_DATA_TYPE/ " => $ op_data_type [isset ($ extra_spec ['OP_DATA ' ]) ? $ extra_spec ['OP_DATA ' ] : "ANY " ],
802
800
"/GET_OP_DATA_ZVAL_PTR\(([^)]*)\)/ " => $ op_data_get_zval_ptr [isset ($ extra_spec ['OP_DATA ' ]) ? $ extra_spec ['OP_DATA ' ] : "ANY " ],
803
801
"/GET_OP_DATA_ZVAL_PTR_DEREF\(([^)]*)\)/ " => $ op_data_get_zval_ptr_deref [isset ($ extra_spec ['OP_DATA ' ]) ? $ extra_spec ['OP_DATA ' ] : "ANY " ],
@@ -1064,7 +1062,7 @@ function gen_handler($f, $spec, $kind, $name, $op1, $op2, $use, $code, $lineno,
1064
1062
case ZEND_VM_KIND_HYBRID :
1065
1063
if (is_inline_hybrid_handler ($ name , $ opcode ["hot " ], $ op1 , $ op2 , $ extra_spec )) {
1066
1064
$ out = fopen ('php://memory ' , 'w+ ' );
1067
- gen_code ($ out , $ spec , $ kind , 0 , $ code , $ op1 , $ op2 , $ name , $ extra_spec );
1065
+ gen_code ($ out , $ spec , $ kind , $ code , $ op1 , $ op2 , $ name , $ extra_spec );
1068
1066
rewind ($ out );
1069
1067
$ code =
1070
1068
"\t\t\tHYBRID_CASE( {$ spec_name }): \n"
@@ -1123,7 +1121,7 @@ function gen_handler($f, $spec, $kind, $name, $op1, $op2, $use, $code, $lineno,
1123
1121
}
1124
1122
1125
1123
// Generate opcode handler's code
1126
- gen_code ($ f , $ spec , $ kind , 0 , $ code , $ op1 , $ op2 , $ name , $ extra_spec );
1124
+ gen_code ($ f , $ spec , $ kind , $ code , $ op1 , $ op2 , $ name , $ extra_spec );
1127
1125
1128
1126
if ($ additional_func ) {
1129
1127
out ($ f ,"static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL {$ spec_name }_HANDLER(ZEND_OPCODE_HANDLER_ARGS) \n" );
@@ -1186,7 +1184,7 @@ function gen_helper($f, $spec, $kind, $name, $op1, $op2, $param, $code, $lineno,
1186
1184
}
1187
1185
1188
1186
// Generate helper's code
1189
- gen_code ($ f , $ spec , $ kind , 0 , $ code , $ op1 , $ op2 , $ name , $ extra_spec );
1187
+ gen_code ($ f , $ spec , $ kind , $ code , $ op1 , $ op2 , $ name , $ extra_spec );
1190
1188
}
1191
1189
1192
1190
@@ -2332,7 +2330,6 @@ function gen_vm($def, $skel) {
2332
2330
$ max_opcode_len = 0 ;
2333
2331
$ max_opcode = 0 ;
2334
2332
$ extra_num = 256 ;
2335
- $ export = array ();
2336
2333
foreach ($ in as $ line ) {
2337
2334
++$ lineno ;
2338
2335
if (strpos ($ line ,"ZEND_VM_HANDLER( " ) === 0 ||
@@ -2482,28 +2479,6 @@ function gen_vm($def, $skel) {
2482
2479
2483
2480
$ handler = null ;
2484
2481
$ list [$ lineno ] = array ("helper " =>$ helper );
2485
- } else if (strpos ($ line ,"ZEND_VM_EXPORT_HANDLER( " ) === 0 ) {
2486
- if (preg_match (
2487
- "/^ZEND_VM_EXPORT_HANDLER\(\s*([A-Za-z_]+)\s*,\s*([A-Z_]+)\s*\)/ " ,
2488
- $ line ,
2489
- $ m ) == 0 ) {
2490
- die ("ERROR ( $ def: $ lineno): Invalid ZEND_VM_EXPORT_HANDLER definition. \n" );
2491
- }
2492
- if (!isset ($ opnames [$ m [2 ]])) {
2493
- die ("ERROR ( $ def: $ lineno): opcode ' {$ m [2 ]}' is not defined. \n" );
2494
- }
2495
- $ export [] = array ("handler " ,$ m [1 ],$ m [2 ]);
2496
- } else if (strpos ($ line ,"ZEND_VM_EXPORT_HELPER( " ) === 0 ) {
2497
- if (preg_match (
2498
- "/^ZEND_VM_EXPORT_HELPER\(\s*([A-Za-z_]+)\s*,\s*([A-Za-z_]+)\s*\)/ " ,
2499
- $ line ,
2500
- $ m ) == 0 ) {
2501
- die ("ERROR ( $ def: $ lineno): Invalid ZEND_VM_EXPORT_HELPER definition. \n" );
2502
- }
2503
- if (!isset ($ helpers [$ m [2 ]])) {
2504
- die ("ERROR ( $ def: $ lineno): helper ' {$ m [2 ]}' is not defined. \n" );
2505
- }
2506
- $ export [] = array ("helper " ,$ m [1 ],$ m [2 ]);
2507
2482
} else if (strpos ($ line ,"ZEND_VM_DEFINE_OP( " ) === 0 ) {
2508
2483
if (preg_match (
2509
2484
"/^ZEND_VM_DEFINE_OP\(\s*([0-9]+)\s*,\s*([A-Z_]+)\s*\);/ " ,
@@ -2949,80 +2924,6 @@ function gen_vm($def, $skel) {
2949
2924
out ($ f , "} \n\n" );
2950
2925
}
2951
2926
2952
- // Export handlers and helpers
2953
- if (count ($ export ) > 0 &&
2954
- ZEND_VM_KIND != ZEND_VM_KIND_CALL ) {
2955
- out ($ f ,"#undef OPLINE \n" );
2956
- out ($ f ,"#undef DCL_OPLINE \n" );
2957
- out ($ f ,"#undef USE_OPLINE \n" );
2958
- out ($ f ,"#undef LOAD_OPLINE \n" );
2959
- out ($ f ,"#undef LOAD_OPLINE_EX \n" );
2960
- out ($ f ,"#undef LOAD_NEXT_OPLINE \n" );
2961
- out ($ f ,"#undef SAVE_OPLINE \n" );
2962
- out ($ f ,"#undef SAVE_OPLINE_EX \n" );
2963
- out ($ f ,"#define OPLINE EX(opline) \n" );
2964
- out ($ f ,"#define DCL_OPLINE \n" );
2965
- out ($ f ,"#define USE_OPLINE const zend_op *opline = EX(opline); \n" );
2966
- out ($ f ,"#define LOAD_OPLINE() \n" );
2967
- out ($ f ,"#define LOAD_OPLINE_EX() \n" );
2968
- out ($ f ,"#define LOAD_NEXT_OPLINE() ZEND_VM_INC_OPCODE() \n" );
2969
- out ($ f ,"#define SAVE_OPLINE() \n" );
2970
- out ($ f ,"#define SAVE_OPLINE_EX() \n" );
2971
- out ($ f ,"#undef HANDLE_EXCEPTION \n" );
2972
- out ($ f ,"#undef HANDLE_EXCEPTION_LEAVE \n" );
2973
- out ($ f ,"#define HANDLE_EXCEPTION() LOAD_OPLINE(); ZEND_VM_CONTINUE() \n" );
2974
- out ($ f ,"#define HANDLE_EXCEPTION_LEAVE() LOAD_OPLINE(); ZEND_VM_LEAVE() \n" );
2975
- out ($ f ,"#undef ZEND_VM_CONTINUE \n" );
2976
- out ($ f ,"#undef ZEND_VM_RETURN \n" );
2977
- out ($ f ,"#undef ZEND_VM_ENTER_EX \n" );
2978
- out ($ f ,"#undef ZEND_VM_ENTER \n" );
2979
- out ($ f ,"#undef ZEND_VM_LEAVE \n" );
2980
- out ($ f ,"#undef ZEND_VM_DISPATCH \n" );
2981
- out ($ f ,"#define ZEND_VM_CONTINUE() return 0 \n" );
2982
- out ($ f ,"#define ZEND_VM_RETURN() return -1 \n" );
2983
- out ($ f ,"#define ZEND_VM_ENTER_EX() return 1 \n" );
2984
- out ($ f ,"#define ZEND_VM_ENTER() return 1 \n" );
2985
- out ($ f ,"#define ZEND_VM_LEAVE() return 2 \n" );
2986
- out ($ f ,"#define ZEND_VM_INTERRUPT() return zend_interrupt_helper(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); \n" );
2987
- out ($ f ,"#define ZEND_VM_DISPATCH(opcode, opline) return zend_vm_get_opcode_handler(opcode, opline)(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); \n\n" );
2988
- out ($ f ,"\n" );
2989
- }
2990
- foreach ($ export as $ dsk ) {
2991
- list ($ kind , $ func , $ name ) = $ dsk ;
2992
- out ($ f , "ZEND_API int $ func( " );
2993
- if ($ kind == "handler " ) {
2994
- out ($ f , "ZEND_OPCODE_HANDLER_ARGS) \n" );
2995
- $ code = $ opcodes [$ opnames [$ name ]]['code ' ];
2996
- } else {
2997
- $ h = $ helpers [$ name ];
2998
- if ($ h ['param ' ] == null ) {
2999
- out ($ f , "ZEND_OPCODE_HANDLER_ARGS) \n" );
3000
- } else {
3001
- out ($ f , $ h ['param ' ]. " ZEND_OPCODE_HANDLER_ARGS_DC) \n" );
3002
- }
3003
- $ code = $ h ['code ' ];
3004
- }
3005
- $ done = 0 ;
3006
- if (ZEND_VM_KIND == ZEND_VM_KIND_CALL ) {
3007
- if ($ kind == "handler " ) {
3008
- $ op = $ opcodes [$ opnames [$ name ]];
3009
- if (isset ($ op ['op1 ' ]["ANY " ]) && isset ($ op ['op2 ' ]["ANY " ])) {
3010
- out ($ f , "{ \n\treturn " .$ name .(ZEND_VM_SPEC ?"_SPEC " :"" )."_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); \n} \n\n" );
3011
- $ done = 1 ;
3012
- }
3013
- } else if ($ helpers [$ name ]["param " ] == null ) {
3014
- $ h = $ helpers [$ name ];
3015
- if (isset ($ h ['op1 ' ]["ANY " ]) && isset ($ h ['op2 ' ]["ANY " ])) {
3016
- out ($ f , "{ \n\treturn " .$ name .(ZEND_VM_SPEC ?"_SPEC " :"" )."(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); \n} \n\n" );
3017
- $ done = 1 ;
3018
- }
3019
- }
3020
- }
3021
- if (!$ done ) {
3022
- gen_code ($ f , 0 , ZEND_VM_KIND_CALL , 1 , $ code , 'ANY ' , 'ANY ' , $ name );
3023
- }
3024
- }
3025
-
3026
2927
fclose ($ f );
3027
2928
echo "zend_vm_execute.h generated successfully. \n" ;
3028
2929
}
0 commit comments