@@ -1027,7 +1027,7 @@ function is_hot_handler($hot, $op1, $op2, $extra_spec) {
1027
1027
1028
1028
// Generates opcode handler
1029
1029
function gen_handler ($ f , $ spec , $ kind , $ name , $ op1 , $ op2 , $ use , $ code , $ lineno , $ opcode , $ extra_spec = null , &$ switch_labels = array ()) {
1030
- global $ definition_file , $ prefix , $ opnames ;
1030
+ global $ definition_file , $ prefix , $ opnames, $ gen_order ;
1031
1031
1032
1032
if ($ spec && skip_extra_spec_function ($ op1 , $ op2 , $ extra_spec )) {
1033
1033
return ;
@@ -1046,7 +1046,11 @@ function gen_handler($f, $spec, $kind, $name, $op1, $op2, $use, $code, $lineno,
1046
1046
. "\t\t\t\tVM_TRACE( $ spec_name) \n"
1047
1047
. "\t\t\t\t{$ spec_name }_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); \n"
1048
1048
. "\t\t\t\tHYBRID_BREAK(); \n" ;
1049
- out ($ f , $ code );
1049
+ if (is_array ($ gen_order )) {
1050
+ $ gen_order [$ spec_name ] = $ code ;
1051
+ } else {
1052
+ out ($ f , $ code );
1053
+ }
1050
1054
return ;
1051
1055
case ZEND_VM_KIND_CALL :
1052
1056
if ($ opcode ["hot " ] && ZEND_VM_KIND == ZEND_VM_KIND_HYBRID && is_hot_handler ($ opcode ["hot " ], $ op1 , $ op2 , $ extra_spec )) {
@@ -1532,9 +1536,31 @@ function extra_spec_handler($dsc) {
1532
1536
return $ f ($ specs );
1533
1537
}
1534
1538
1539
+ function read_order_file ($ fn ) {
1540
+ $ f = fopen ($ fn , "r " );
1541
+ if (!is_resource ($ f )) {
1542
+ return false ;
1543
+ }
1544
+ $ order = [];
1545
+ while (!feof ($ f )) {
1546
+ $ op = trim (fgets ($ f ));
1547
+ if ($ op !== "" ) {
1548
+ $ order [$ op ] = null ;
1549
+ }
1550
+ }
1551
+ fclose ($ f );
1552
+ return $ order ;
1553
+ }
1554
+
1535
1555
// Generates all opcode handlers and helpers (specialized or unspecilaized)
1536
1556
function gen_executor_code ($ f , $ spec , $ kind , $ prolog , &$ switch_labels = array ()) {
1537
- global $ list , $ opcodes , $ helpers , $ op_types_ex ;
1557
+ global $ list , $ opcodes , $ helpers , $ op_types_ex , $ gen_order ;
1558
+
1559
+ if ($ kind == ZEND_VM_KIND_HYBRID && file_exists (__DIR__ . "/zend_vm_order.txt " )) {
1560
+ $ gen_order = read_order_file (__DIR__ . "/zend_vm_order.txt " );
1561
+ } else {
1562
+ $ gen_order = null ;
1563
+ }
1538
1564
1539
1565
if ($ spec ) {
1540
1566
// Produce specialized executor
@@ -1595,6 +1621,14 @@ function gen_executor_code($f, $spec, $kind, $prolog, &$switch_labels = array())
1595
1621
}
1596
1622
}
1597
1623
1624
+ if (is_array ($ gen_order )) {
1625
+ foreach ($ gen_order as $ txt ) {
1626
+ if ($ txt !== null ) {
1627
+ out ($ f , $ txt );
1628
+ }
1629
+ }
1630
+ }
1631
+
1598
1632
if (ZEND_VM_LINES ) {
1599
1633
// Reset #line directives
1600
1634
out_line ($ f );
0 commit comments