summaryrefslogtreecommitdiff
path: root/Zend
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2019-04-09 01:17:36 +0300
committerDmitry Stogov <dmitry@zend.com>2019-04-09 01:17:36 +0300
commit2a310b24d63c6ff22f6a51e4baddcda24ddc24e6 (patch)
tree51b702e86895f63acae242aaa1ddd2b359fdeb88 /Zend
parent2f03c0aa72230eb787d20d77bf9f4f367bb3e081 (diff)
parentfe0a0897bab5fb8de14478f800f36af6d559164e (diff)
downloadphp-git-2a310b24d63c6ff22f6a51e4baddcda24ddc24e6.tar.gz
Merge branch 'PHP-7.4'
* PHP-7.4: Repare SWITCH VM
Diffstat (limited to 'Zend')
-rw-r--r--Zend/zend_execute.c4
-rwxr-xr-xZend/zend_vm_gen.php20
2 files changed, 13 insertions, 11 deletions
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index 5307c6a0ef..c596be73a6 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -65,7 +65,7 @@
# pragma GCC diagnostic warning "-Wvolatile-register-var"
#endif
-#ifdef ZEND_VM_FP_GLOBAL_REG
+#if defined(ZEND_VM_FP_GLOBAL_REG) && ((ZEND_VM_KIND == ZEND_VM_KIND_CALL) || (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID))
# define EXECUTE_DATA_D void
# define EXECUTE_DATA_C
# define EXECUTE_DATA_DC
@@ -79,7 +79,7 @@
# define NO_EXECUTE_DATA_CC , NULL
#endif
-#ifdef ZEND_VM_IP_GLOBAL_REG
+#if defined(ZEND_VM_FP_GLOBAL_REG) && ((ZEND_VM_KIND == ZEND_VM_KIND_CALL) || (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID))
# define OPLINE_D void
# define OPLINE_C
# define OPLINE_DC
diff --git a/Zend/zend_vm_gen.php b/Zend/zend_vm_gen.php
index 34117ff61c..1847eb0773 100755
--- a/Zend/zend_vm_gen.php
+++ b/Zend/zend_vm_gen.php
@@ -1742,7 +1742,7 @@ function gen_executor_code($f, $spec, $kind, $prolog, &$switch_labels = array())
gen_null_handler($f);
break;
case ZEND_VM_KIND_SWITCH:
- out($f,"default:\n");
+ out($f,"default: ZEND_NULL_LABEL:\n");
out($f,"\tzend_error_noreturn(E_ERROR, \"Invalid opcode %d/%d/%d.\", OPLINE->opcode, OPLINE->op1_type, OPLINE->op2_type);\n");
out($f,"\tZEND_VM_NEXT_OPCODE(); /* Never reached */\n");
break;
@@ -2058,7 +2058,7 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name)
$prolog = $m[1];
out($f,$prolog."if (UNEXPECTED(execute_data == NULL)) {\n");
out($f,$prolog."\tstatic const void * const labels[] = {\n");
- gen_labels($f, $spec, ZEND_VM_KIND_GOTO, $prolog."\t\t", $specs);
+ gen_labels($f, $spec, ($kind == ZEND_VM_KIND_HYBRID) ? ZEND_VM_KIND_GOTO : $kind, $prolog."\t\t", $specs);
out($f,$prolog."\t};\n");
out($f,$prolog."\tzend_opcode_handlers = (const void **) labels;\n");
out($f,$prolog."\tzend_handlers_count = sizeof(labels) / sizeof(void*);\n");
@@ -2173,7 +2173,7 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name)
out($f,$prolog.$executor_name."_ex(NULL);\n");
} else {
out($f,$prolog."static const void * const labels[] = {\n");
- gen_labels($f, $spec, ZEND_VM_KIND_CALL, $prolog."\t", $specs, $switch_labels);
+ gen_labels($f, $spec, ($kind == ZEND_VM_KIND_HYBRID) ? ZEND_VM_KIND_CALL : $kind, $prolog."\t", $specs, $switch_labels);
out($f,$prolog."};\n");
out($f,$prolog."static const uint32_t specs[] = {\n");
gen_specs($f, $prolog."\t", $specs);
@@ -2517,13 +2517,15 @@ function gen_vm($def, $skel) {
// Search for opcode handlers those are used by other opcode handlers
foreach ($opcodes as $dsc) {
- if (preg_match("/ZEND_VM_DISPATCH_TO_HANDLER\(\s*([A-Z_]*)\s*\)/m", $dsc["code"], $m)) {
- $op = $m[1];
- if (!isset($opnames[$op])) {
- die("ERROR ($def:$lineno): Opcode with name '$op' is not defined.\n");
+ if (preg_match_all("/ZEND_VM_DISPATCH_TO_HANDLER\(\s*([A-Z_]*)\s*\)/m", $dsc["code"], $mm, PREG_SET_ORDER)) {
+ foreach ($mm as $m) {
+ $op = $m[1];
+ if (!isset($opnames[$op])) {
+ die("ERROR ($def:$lineno): Opcode with name '$op' is not defined.\n");
+ }
+ $code = $opnames[$op];
+ $opcodes[$code]['use'] = 1;
}
- $code = $opnames[$op];
- $opcodes[$code]['use'] = 1;
}
}