Skip to content

Commit d3ef806

Browse files
committed
Fix zend_vm_gen.php when executed with PHP 8.5
PHP 8.5 defines constant ZEND_VM_KIND since GH-19574, but this name is also used by zend_vm_gen.php. This causes zend_vm_gen.php to generate invalid code when executed with PHP 8.5 in an older branch. Here I rename the constant in zend_vm_gen.php.
1 parent 9a7c09c commit d3ef806

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

Zend/zend_vm_gen.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ function($matches) use ($spec, $prefix, $op1, $op2, $extra_spec, $name) {
841841
$handler = $matches[1];
842842
$opcode = $opcodes[$opnames[$handler]];
843843
$inline =
844-
ZEND_VM_KIND == ZEND_VM_KIND_HYBRID &&
844+
ZEND_VM_GEN_KIND == ZEND_VM_KIND_HYBRID &&
845845
isset($opcode["use"]) &&
846846
is_hot_handler($opcode["hot"], $op1, $op2, $extra_spec) &&
847847
is_hot_handler($opcodes[$opnames[$name]]["hot"], $op1, $op2, $extra_spec) ?
@@ -1077,7 +1077,7 @@ function gen_handler($f, $spec, $kind, $name, $op1, $op2, $use, $code, $lineno,
10771077
}
10781078
return;
10791079
case ZEND_VM_KIND_CALL:
1080-
if ($opcode["hot"] && ZEND_VM_KIND == ZEND_VM_KIND_HYBRID && is_hot_handler($opcode["hot"], $op1, $op2, $extra_spec)) {
1080+
if ($opcode["hot"] && ZEND_VM_GEN_KIND == ZEND_VM_KIND_HYBRID && is_hot_handler($opcode["hot"], $op1, $op2, $extra_spec)) {
10811081
if (isset($opcode["use"])) {
10821082
out($f,"static zend_always_inline ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL {$spec_name}_INLINE_HANDLER(ZEND_OPCODE_HANDLER_ARGS)\n");
10831083
$additional_func = true;
@@ -2326,15 +2326,15 @@ function gen_vm_opcodes_header(
23262326
$str .= "#define ZEND_VM_KIND_SWITCH\t" . ZEND_VM_KIND_SWITCH . "\n";
23272327
$str .= "#define ZEND_VM_KIND_GOTO\t" . ZEND_VM_KIND_GOTO . "\n";
23282328
$str .= "#define ZEND_VM_KIND_HYBRID\t" . ZEND_VM_KIND_HYBRID . "\n";
2329-
if ($GLOBALS["vm_kind_name"][ZEND_VM_KIND] === "ZEND_VM_KIND_HYBRID") {
2329+
if ($GLOBALS["vm_kind_name"][ZEND_VM_GEN_KIND] === "ZEND_VM_KIND_HYBRID") {
23302330
$str .= "/* HYBRID requires support for computed GOTO and global register variables*/\n";
23312331
$str .= "#if (defined(__GNUC__) && defined(HAVE_GCC_GLOBAL_REGS))\n";
23322332
$str .= "# define ZEND_VM_KIND\t\tZEND_VM_KIND_HYBRID\n";
23332333
$str .= "#else\n";
23342334
$str .= "# define ZEND_VM_KIND\t\tZEND_VM_KIND_CALL\n";
23352335
$str .= "#endif\n";
23362336
} else {
2337-
$str .= "#define ZEND_VM_KIND\t\t" . $GLOBALS["vm_kind_name"][ZEND_VM_KIND] . "\n";
2337+
$str .= "#define ZEND_VM_KIND\t\t" . $GLOBALS["vm_kind_name"][ZEND_VM_GEN_KIND] . "\n";
23382338
}
23392339
$str .= "\n";
23402340
$str .= "#if (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID) && !defined(__SANITIZE_ADDRESS__)\n";
@@ -2536,9 +2536,9 @@ function gen_vm($def, $skel) {
25362536
}
25372537

25382538
// Store parameters
2539-
if ((ZEND_VM_KIND == ZEND_VM_KIND_GOTO
2540-
|| ZEND_VM_KIND == ZEND_VM_KIND_SWITCH
2541-
|| (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID && $hot))
2539+
if ((ZEND_VM_GEN_KIND == ZEND_VM_KIND_GOTO
2540+
|| ZEND_VM_GEN_KIND == ZEND_VM_KIND_SWITCH
2541+
|| (ZEND_VM_GEN_KIND == ZEND_VM_KIND_HYBRID && $hot))
25422542
&& $param) {
25432543
foreach (explode(",", $param ) as $p) {
25442544
$p = trim($p);
@@ -2600,7 +2600,7 @@ function gen_vm($def, $skel) {
26002600
die("ERROR ($def:$lineno): Opcode with name '$op' is not defined.\n");
26012601
}
26022602
$opcodes[$opnames[$dsc['op']]]['alias'] = $op;
2603-
if (!ZEND_VM_SPEC && ZEND_VM_KIND == ZEND_VM_KIND_SWITCH) {
2603+
if (!ZEND_VM_SPEC && ZEND_VM_GEN_KIND == ZEND_VM_KIND_SWITCH) {
26042604
$code = $opnames[$op];
26052605
$opcodes[$code]['use'] = 1;
26062606
}
@@ -2713,7 +2713,7 @@ function gen_vm($def, $skel) {
27132713
out($f, "255\n};\n\n");
27142714

27152715
// Generate specialized executor
2716-
gen_executor($f, $skl, ZEND_VM_SPEC, ZEND_VM_KIND, "execute", "zend_vm_init");
2716+
gen_executor($f, $skl, ZEND_VM_SPEC, ZEND_VM_GEN_KIND, "execute", "zend_vm_init");
27172717
out($f, "\n");
27182718

27192719
// Generate zend_vm_get_opcode_handler() function
@@ -2807,7 +2807,7 @@ function gen_vm($def, $skel) {
28072807
out($f, "}\n");
28082808
out($f, "#endif\n\n");
28092809

2810-
if (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID) {
2810+
if (ZEND_VM_GEN_KIND == ZEND_VM_KIND_HYBRID) {
28112811
// Generate zend_vm_get_opcode_handler_func() function
28122812
out($f, "#if ZEND_VM_KIND == ZEND_VM_KIND_HYBRID\n");
28132813
out($f,"static const void *zend_vm_get_opcode_handler_func(uint8_t opcode, const zend_op* op)\n");
@@ -2918,10 +2918,10 @@ function gen_vm($def, $skel) {
29182918
out($f, "}\n\n");
29192919

29202920
// Generate zend_vm_call_opcode_handler() function
2921-
if (ZEND_VM_KIND == ZEND_VM_KIND_CALL || ZEND_VM_KIND == ZEND_VM_KIND_HYBRID) {
2921+
if (ZEND_VM_GEN_KIND == ZEND_VM_KIND_CALL || ZEND_VM_GEN_KIND == ZEND_VM_KIND_HYBRID) {
29222922
out($f, "ZEND_API int ZEND_FASTCALL zend_vm_call_opcode_handler(zend_execute_data* ex)\n");
29232923
out($f, "{\n");
2924-
if (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID) {
2924+
if (ZEND_VM_GEN_KIND == ZEND_VM_KIND_HYBRID) {
29252925
out($f,"#if (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID)\n");
29262926
out($f, "\topcode_handler_t handler;\n");
29272927
out($f,"#endif\n");
@@ -2939,15 +2939,15 @@ function gen_vm($def, $skel) {
29392939
out($f, "\n");
29402940
out($f, "\tLOAD_OPLINE();\n");
29412941
out($f,"#if defined(ZEND_VM_FP_GLOBAL_REG) && defined(ZEND_VM_IP_GLOBAL_REG)\n");
2942-
if (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID) {
2942+
if (ZEND_VM_GEN_KIND == ZEND_VM_KIND_HYBRID) {
29432943
out($f,"#if (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID)\n");
29442944
out($f, "\thandler = (opcode_handler_t)zend_vm_get_opcode_handler_func(zend_user_opcodes[opline->opcode], opline);\n");
29452945
out($f, "\thandler(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n");
29462946
out($f, "\tif (EXPECTED(opline != &hybrid_halt_op)) {\n");
29472947
out($f,"#else\n");
29482948
}
29492949
out($f, "\t((opcode_handler_t)OPLINE->handler)(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n");
2950-
if (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID) {
2950+
if (ZEND_VM_GEN_KIND == ZEND_VM_KIND_HYBRID) {
29512951
out($f, "\tif (EXPECTED(opline)) {\n");
29522952
out($f,"#endif\n");
29532953
} else {
@@ -3009,16 +3009,16 @@ function usage() {
30093009
$kind = substr($argv[$i], strlen("--with-vm-kind="));
30103010
switch ($kind) {
30113011
case "CALL":
3012-
define("ZEND_VM_KIND", ZEND_VM_KIND_CALL);
3012+
define("ZEND_VM_GEN_KIND", ZEND_VM_KIND_CALL);
30133013
break;
30143014
case "SWITCH":
3015-
define("ZEND_VM_KIND", ZEND_VM_KIND_SWITCH);
3015+
define("ZEND_VM_GEN_KIND", ZEND_VM_KIND_SWITCH);
30163016
break;
30173017
case "GOTO":
3018-
define("ZEND_VM_KIND", ZEND_VM_KIND_GOTO);
3018+
define("ZEND_VM_GEN_KIND", ZEND_VM_KIND_GOTO);
30193019
break;
30203020
case "HYBRID":
3021-
define("ZEND_VM_KIND", ZEND_VM_KIND_HYBRID);
3021+
define("ZEND_VM_GEN_KIND", ZEND_VM_KIND_HYBRID);
30223022
break;
30233023
default:
30243024
echo("ERROR: Invalid vm kind '$kind'\n");
@@ -3042,9 +3042,9 @@ function usage() {
30423042
}
30433043

30443044
// Using defaults
3045-
if (!defined("ZEND_VM_KIND")) {
3045+
if (!defined("ZEND_VM_GEN_KIND")) {
30463046
// Using CALL threading by default
3047-
define("ZEND_VM_KIND", ZEND_VM_KIND_HYBRID);
3047+
define("ZEND_VM_GEN_KIND", ZEND_VM_KIND_HYBRID);
30483048
}
30493049
if (!defined("ZEND_VM_SPEC")) {
30503050
// Using specialized executor by default

0 commit comments

Comments
 (0)