Skip to content

Commit 350f221

Browse files
committed
Allow GOTO style helpers in HYBRID VM
1 parent ef1a1a0 commit 350f221

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

Zend/zend_vm_gen.php

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -883,14 +883,19 @@ function($matches) use ($spec, $prefix, $op1, $op2, $extra_spec) {
883883
return "goto " . opcode_name($name, $spec, $op1, $op2, $extra_spec) . "_LABEL";
884884
} else {
885885
// ZEND_VM_DISPATCH_TO_HELPER
886+
if (is_hot_helper($matches[1])) {
887+
if (isset($matches[2])) {
888+
// extra args
889+
$args = preg_replace("/,\s*([A-Za-z0-9_]*)\s*,\s*([^,)\s]*)\s*/", "$1 = $2; ", $matches[2]);
890+
return $args . "goto " . helper_name($matches[1], $spec, $op1, $op2, $extra_spec) . "_LABEL";
891+
}
892+
return "goto " . helper_name($matches[1], $spec, $op1, $op2, $extra_spec) . "_LABEL";
893+
}
886894
if (isset($matches[2])) {
887895
// extra args
888896
$args = substr(preg_replace("/,\s*[A-Za-z0-9_]*\s*,\s*([^,)\s]*)\s*/", ", $1", $matches[2]), 2);
889897
return "ZEND_VM_TAIL_CALL(" . helper_name($matches[1], $spec, $op1, $op2, $extra_spec) . "(" . $args. " ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_CC))";
890898
}
891-
if (is_hot_helper($matches[1])) {
892-
return "goto " . helper_name($matches[1], $spec, $op1, $op2, $extra_spec) . "_LABEL";
893-
}
894899
return "ZEND_VM_TAIL_CALL(" . helper_name($matches[1], $spec, $op1, $op2, $extra_spec) . "(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU))";
895900
}
896901
},
@@ -2065,14 +2070,22 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name)
20652070
out($f, $m[1].$executor_name.$m[3]."\n");
20662071
break;
20672072
case "HELPER_VARS":
2068-
if ($kind != ZEND_VM_KIND_CALL && $kind != ZEND_VM_KIND_HYBRID) {
2069-
if ($kind == ZEND_VM_KIND_SWITCH) {
2070-
out($f,$m[1]."const void *dispatch_handler;\n");
2073+
if ($kind == ZEND_VM_KIND_SWITCH) {
2074+
out($f,$m[1]."const void *dispatch_handler;\n");
2075+
}
2076+
if ($kind != ZEND_VM_KIND_CALL && count($params)) {
2077+
if ($kind == ZEND_VM_KIND_HYBRID) {
2078+
out($f, "#if (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID)\n");
20712079
}
20722080
// Emit local variables those are used for helpers' parameters
20732081
foreach ($params as $param => $x) {
20742082
out($f,$m[1].$param.";\n");
20752083
}
2084+
if ($kind == ZEND_VM_KIND_HYBRID) {
2085+
out($f, "#endif\n");
2086+
}
2087+
}
2088+
if ($kind != ZEND_VM_KIND_CALL && $kind != ZEND_VM_KIND_HYBRID) {
20762089
out($f,"#ifdef ZEND_VM_FP_GLOBAL_REG\n");
20772090
out($f,$m[1]."register zend_execute_data *execute_data __asm__(ZEND_VM_FP_GLOBAL_REG) = ex;\n");
20782091
out($f,"#else\n");
@@ -2485,10 +2498,14 @@ function gen_vm($def, $skel) {
24852498
}
24862499

24872500
// Store parameters
2488-
foreach (explode(",", $param) as $p) {
2489-
$p = trim($p);
2490-
if ($p !== "") {
2491-
$params[$p] = 1;
2501+
if (ZEND_VM_KIND == ZEND_VM_KIND_GOTO
2502+
|| ZEND_VM_KIND == ZEND_VM_KIND_SWITCH
2503+
|| (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID && $hot)) {
2504+
foreach (explode(",", $param) as $p) {
2505+
$p = trim($p);
2506+
if ($p !== "") {
2507+
$params[$p] = 1;
2508+
}
24922509
}
24932510
}
24942511

0 commit comments

Comments
 (0)