@@ -1186,7 +1186,7 @@ function gen_null_label($f, $kind, $prolog) {
1186
1186
out ($ f ,$ prolog ."ZEND_NULL_HANDLER, \n" );
1187
1187
break ;
1188
1188
case ZEND_VM_KIND_SWITCH :
1189
- out ($ f ,$ prolog ."(void*)(uintptr_t) -1, \n" );
1189
+ out ($ f ,$ prolog ."-1, \n" );
1190
1190
break ;
1191
1191
case ZEND_VM_KIND_GOTO :
1192
1192
out ($ f ,$ prolog ."(void*)&&ZEND_NULL_LABEL, \n" );
@@ -1388,7 +1388,7 @@ function gen_labels($f, $spec, $kind, $prolog, &$specs, $switch_labels = array()
1388
1388
out ($ f ,"$ prolog {$ spec_name }_HANDLER, \n" );
1389
1389
break ;
1390
1390
case ZEND_VM_KIND_SWITCH :
1391
- out ($ f ,$ prolog ."(void*)(uintptr_t) $ switch_labels [$ spec_name ], \n" );
1391
+ out ($ f ,$ prolog ."$ switch_labels [$ spec_name ], \n" );
1392
1392
break ;
1393
1393
case ZEND_VM_KIND_GOTO :
1394
1394
out ($ f ,$ prolog ."(void*)&& {$ spec_name }_LABEL, \n" );
@@ -1436,7 +1436,7 @@ function gen_labels($f, $spec, $kind, $prolog, &$specs, $switch_labels = array()
1436
1436
out ($ f ,$ prolog ."ZEND_NULL_HANDLER, \n" );
1437
1437
break ;
1438
1438
case ZEND_VM_KIND_SWITCH :
1439
- out ($ f ,$ prolog ."(void*)(uintptr_t) -1, \n" );
1439
+ out ($ f ,$ prolog ."-1, \n" );
1440
1440
break ;
1441
1441
case ZEND_VM_KIND_GOTO :
1442
1442
out ($ f ,$ prolog ."(void*)&&ZEND_NULL_LABEL, \n" );
@@ -1467,7 +1467,7 @@ function gen_labels($f, $spec, $kind, $prolog, &$specs, $switch_labels = array()
1467
1467
out ($ f ,$ prolog .$ dsc ["op " ]."_HANDLER, \n" );
1468
1468
break ;
1469
1469
case ZEND_VM_KIND_SWITCH :
1470
- out ($ f ,$ prolog ." (void*)(uintptr_t) " . ((string )$ num ).", \n" );
1470
+ out ($ f ,$ prolog .((string )$ num ).", \n" );
1471
1471
break ;
1472
1472
case ZEND_VM_KIND_GOTO :
1473
1473
out ($ f ,$ prolog ."(void*)&& " .$ dsc ["op " ]."_LABEL, \n" );
@@ -1480,7 +1480,7 @@ function gen_labels($f, $spec, $kind, $prolog, &$specs, $switch_labels = array()
1480
1480
out ($ f ,$ prolog ."ZEND_NULL_HANDLER, \n" );
1481
1481
break ;
1482
1482
case ZEND_VM_KIND_SWITCH :
1483
- out ($ f ,$ prolog ."(void*)(uintptr_t) -1, \n" );
1483
+ out ($ f ,$ prolog ."-1, \n" );
1484
1484
break ;
1485
1485
case ZEND_VM_KIND_GOTO :
1486
1486
out ($ f ,$ prolog ."(void*)&&ZEND_NULL_LABEL, \n" );
@@ -1497,7 +1497,7 @@ function gen_labels($f, $spec, $kind, $prolog, &$specs, $switch_labels = array()
1497
1497
out ($ f ,$ prolog ."ZEND_NULL_HANDLER \n" );
1498
1498
break ;
1499
1499
case ZEND_VM_KIND_SWITCH :
1500
- out ($ f ,$ prolog ."(void*)(uintptr_t) -1 \n" );
1500
+ out ($ f ,$ prolog ."-1 \n" );
1501
1501
break ;
1502
1502
case ZEND_VM_KIND_GOTO :
1503
1503
out ($ f ,$ prolog ."(void*)&&ZEND_NULL_LABEL \n" );
@@ -1822,7 +1822,7 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name)
1822
1822
out ($ f ,"#endif \n" );
1823
1823
}
1824
1824
out ($ f ,"#if (ZEND_VM_KIND != ZEND_VM_KIND_HYBRID) || !ZEND_VM_SPEC \n" );
1825
- out ($ f ,"static const void * zend_vm_get_opcode_handler(uint8_t opcode, const zend_op* op); \n" );
1825
+ out ($ f ,"static zend_vm_opcode_handler_t zend_vm_get_opcode_handler(uint8_t opcode, const zend_op* op); \n" );
1826
1826
out ($ f ,"#endif \n\n" );
1827
1827
if ($ kind == ZEND_VM_KIND_HYBRID ) {
1828
1828
out ($ f ,"#if (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID) \n" );
@@ -2040,7 +2040,7 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name)
2040
2040
break ;
2041
2041
case "HELPER_VARS " :
2042
2042
if ($ kind == ZEND_VM_KIND_SWITCH ) {
2043
- out ($ f ,$ m [1 ]."const void * dispatch_handler; \n" );
2043
+ out ($ f ,$ m [1 ]."zend_vm_opcode_handler_t dispatch_handler; \n" );
2044
2044
}
2045
2045
if ($ kind != ZEND_VM_KIND_CALL && count ($ params )) {
2046
2046
if ($ kind == ZEND_VM_KIND_HYBRID ) {
@@ -2098,7 +2098,7 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name)
2098
2098
gen_labels ($ f , $ spec , ($ kind == ZEND_VM_KIND_HYBRID ) ? ZEND_VM_KIND_GOTO : $ kind , $ prolog ."\t\t" , $ specs );
2099
2099
out ($ f ,$ prolog ."\t}; \n" );
2100
2100
out ($ f ,$ prolog ."\tzend_opcode_handlers = (zend_vm_opcode_handler_t*) labels; \n" );
2101
- out ($ f ,$ prolog ."\tzend_handlers_count = sizeof(labels) / sizeof(void* ); \n" );
2101
+ out ($ f ,$ prolog ."\tzend_handlers_count = sizeof(labels) / sizeof(labels[0] ); \n" );
2102
2102
if ($ kind == ZEND_VM_KIND_HYBRID ) {
2103
2103
out ($ f ,$ prolog ."\tmemset(&hybrid_halt_op, 0, sizeof(hybrid_halt_op)); \n" );
2104
2104
out ($ f ,$ prolog ."\thybrid_halt_op.handler = (void*)&&HYBRID_HALT_LABEL; \n" );
@@ -2230,7 +2230,7 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name)
2230
2230
out ($ f ,"#else \n" );
2231
2231
}
2232
2232
out ($ f ,$ prolog ."zend_opcode_handlers = labels; \n" );
2233
- out ($ f ,$ prolog ."zend_handlers_count = sizeof(labels) / sizeof(void* ); \n" );
2233
+ out ($ f ,$ prolog ."zend_handlers_count = sizeof(labels) / sizeof(labels[0] ); \n" );
2234
2234
out ($ f ,$ prolog ."zend_spec_handlers = specs; \n" );
2235
2235
if ($ kind == ZEND_VM_KIND_HYBRID ) {
2236
2236
out ($ f ,"#endif \n" );
@@ -2369,9 +2369,12 @@ function gen_vm_opcodes_header(
2369
2369
$ str .= "#elif ZEND_VM_KIND == ZEND_VM_KIND_CALL \n" ;
2370
2370
$ str .= "typedef const struct _zend_op *(ZEND_FASTCALL *zend_vm_opcode_handler_t)(struct _zend_execute_data *execute_data, const struct _zend_op *opline); \n" ;
2371
2371
$ str .= "typedef const struct _zend_op *(ZEND_FASTCALL *zend_vm_opcode_handler_func_t)(struct _zend_execute_data *execute_data, const struct _zend_op *opline); \n" ;
2372
- $ str .= "#else \n" ;
2372
+ $ str .= "#elif ZEND_VM_KIND == ZEND_VM_KIND_SWITCH \n" ;
2373
+ $ str .= "typedef int zend_vm_opcode_handler_t; \n" ;
2374
+ $ str .= "#elif ZEND_VM_KIND == ZEND_VM_KIND_GOTO \n" ;
2373
2375
$ str .= "typedef const void* zend_vm_opcode_handler_t; \n" ;
2374
- $ str .= "typedef const void* zend_vm_opcode_handler_func_t; \n" ;
2376
+ $ str .= "#else \n" ;
2377
+ $ str .= "# error \n" ;
2375
2378
$ str .= "#endif \n" ;
2376
2379
$ str .= "\n" ;
2377
2380
foreach ($ vm_op_flags as $ name => $ val ) {
@@ -2855,7 +2858,7 @@ function gen_vm($def, $skel) {
2855
2858
}
2856
2859
out ($ f , "} \n\n" );
2857
2860
out ($ f , "#if (ZEND_VM_KIND != ZEND_VM_KIND_HYBRID) || !ZEND_VM_SPEC \n" );
2858
- out ($ f , "static const void * zend_vm_get_opcode_handler(uint8_t opcode, const zend_op* op) \n" );
2861
+ out ($ f , "static zend_vm_opcode_handler_t zend_vm_get_opcode_handler(uint8_t opcode, const zend_op* op) \n" );
2859
2862
out ($ f , "{ \n" );
2860
2863
if (!ZEND_VM_SPEC ) {
2861
2864
out ($ f , "\treturn zend_opcode_handlers[zend_vm_get_opcode_handler_idx(opcode, op)]; \n" );
0 commit comments