From: Dmitry Stogov Date: Thu, 15 Feb 2018 12:56:38 +0000 (+0300) Subject: Added ability to manually sort opcode handlers (not used yet) X-Git-Tag: php-7.3.0alpha1~421 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3778abfc15015b3a9e7f7c4d3424ee6797ceba17;p=php Added ability to manually sort opcode handlers (not used yet) --- diff --git a/Zend/zend_vm_gen.php b/Zend/zend_vm_gen.php index b891a3bf29..d06cd89628 100644 --- a/Zend/zend_vm_gen.php +++ b/Zend/zend_vm_gen.php @@ -1027,7 +1027,7 @@ function is_hot_handler($hot, $op1, $op2, $extra_spec) { // Generates opcode handler function gen_handler($f, $spec, $kind, $name, $op1, $op2, $use, $code, $lineno, $opcode, $extra_spec = null, &$switch_labels = array()) { - global $definition_file, $prefix, $opnames; + global $definition_file, $prefix, $opnames, $gen_order; if ($spec && skip_extra_spec_function($op1, $op2, $extra_spec)) { return; @@ -1046,7 +1046,11 @@ function gen_handler($f, $spec, $kind, $name, $op1, $op2, $use, $code, $lineno, . "\t\t\t\tVM_TRACE($spec_name)\n" . "\t\t\t\t{$spec_name}_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n" . "\t\t\t\tHYBRID_BREAK();\n"; - out($f, $code); + if (is_array($gen_order)) { + $gen_order[$spec_name] = $code; + } else { + out($f, $code); + } return; case ZEND_VM_KIND_CALL: 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) { return $f($specs); } +function read_order_file($fn) { + $f = fopen($fn, "r"); + if (!is_resource($f)) { + return false; + } + $order = []; + while (!feof($f)) { + $op = trim(fgets($f)); + if ($op !== "") { + $order[$op] = null; + } + } + fclose($f); + return $order; +} + // Generates all opcode handlers and helpers (specialized or unspecilaized) function gen_executor_code($f, $spec, $kind, $prolog, &$switch_labels = array()) { - global $list, $opcodes, $helpers, $op_types_ex; + global $list, $opcodes, $helpers, $op_types_ex, $gen_order; + + if ($kind == ZEND_VM_KIND_HYBRID && file_exists(__DIR__ . "/zend_vm_order.txt")) { + $gen_order = read_order_file(__DIR__ . "/zend_vm_order.txt"); + } else { + $gen_order = null; + } if ($spec) { // Produce specialized executor @@ -1595,6 +1621,14 @@ function gen_executor_code($f, $spec, $kind, $prolog, &$switch_labels = array()) } } + if (is_array($gen_order)) { + foreach ($gen_order as $txt) { + if ($txt !== null) { + out($f, $txt); + } + } + } + if (ZEND_VM_LINES) { // Reset #line directives out_line($f);