diff --git a/Zend/zend_constants.stub.php b/Zend/zend_constants.stub.php index 763b207641f69..6e791ca4abfd0 100644 --- a/Zend/zend_constants.stub.php +++ b/Zend/zend_constants.stub.php @@ -121,6 +121,12 @@ */ const ZEND_DEBUG_BUILD = UNKNOWN; +/** + * @var string + * @cvalue zend_vm_kind_name[ZEND_VM_KIND] + */ +const ZEND_VM_KIND = UNKNOWN; + /* Special constants true/false/null. */ /** diff --git a/Zend/zend_constants_arginfo.h b/Zend/zend_constants_arginfo.h index 04ccc3025f188..56cb3fe232a82 100644 --- a/Zend/zend_constants_arginfo.h +++ b/Zend/zend_constants_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 5e224893a5fb72b3f93249235c2a1634233ce505 */ + * Stub hash: bf2f959978bd6cbd7353ca7bfbb95718cdd51cff */ static void register_zend_constants_symbols(int module_number) { @@ -23,6 +23,7 @@ static void register_zend_constants_symbols(int module_number) REGISTER_LONG_CONSTANT("DEBUG_BACKTRACE_IGNORE_ARGS", DEBUG_BACKTRACE_IGNORE_ARGS, CONST_PERSISTENT); REGISTER_BOOL_CONSTANT("ZEND_THREAD_SAFE", ZTS_V, CONST_PERSISTENT); REGISTER_BOOL_CONSTANT("ZEND_DEBUG_BUILD", ZEND_DEBUG, CONST_PERSISTENT); + REGISTER_STRING_CONSTANT("ZEND_VM_KIND", zend_vm_kind_name[ZEND_VM_KIND], CONST_PERSISTENT); REGISTER_BOOL_CONSTANT("TRUE", true, CONST_PERSISTENT); REGISTER_BOOL_CONSTANT("FALSE", false, CONST_PERSISTENT); REGISTER_NULL_CONSTANT("NULL", CONST_PERSISTENT); diff --git a/Zend/zend_vm_gen.php b/Zend/zend_vm_gen.php index cdb5ea3cd7783..eceb07f39020e 100755 --- a/Zend/zend_vm_gen.php +++ b/Zend/zend_vm_gen.php @@ -143,6 +143,7 @@ ZEND_VM_KIND_SWITCH => "ZEND_VM_KIND_SWITCH", ZEND_VM_KIND_GOTO => "ZEND_VM_KIND_GOTO", ZEND_VM_KIND_HYBRID => "ZEND_VM_KIND_HYBRID", + ZEND_VM_KIND_TAILCALL => "ZEND_VM_KIND_TAILCALL", ); $op_types = array( @@ -845,7 +846,7 @@ function($matches) use ($spec, $prefix, $op1, $op2, $extra_spec, $name, $kind) { $handler = $matches[1]; $opcode = $opcodes[$opnames[$handler]]; $inline = - ZEND_VM_KIND == ZEND_VM_KIND_HYBRID && + ZEND_VM_GEN_KIND == ZEND_VM_KIND_HYBRID && isset($opcode["use"]) && is_hot_handler($opcode["hot"], $op1, $op2, $extra_spec) && is_hot_handler($opcodes[$opnames[$name]]["hot"], $op1, $op2, $extra_spec) ? @@ -1090,7 +1091,7 @@ function gen_handler($f, $spec, $kind, $name, $op1, $op2, $use, $code, $lineno, case ZEND_VM_KIND_CALL: case ZEND_VM_KIND_TAILCALL: $cconv = $kind === ZEND_VM_KIND_TAILCALL ? 'ZEND_OPCODE_HANDLER_CCONV' : 'ZEND_OPCODE_HANDLER_FUNC_CCONV'; - if ($opcode["hot"] && ZEND_VM_KIND == ZEND_VM_KIND_HYBRID && is_hot_handler($opcode["hot"], $op1, $op2, $extra_spec)) { + if ($opcode["hot"] && ZEND_VM_GEN_KIND == ZEND_VM_KIND_HYBRID && is_hot_handler($opcode["hot"], $op1, $op2, $extra_spec)) { if (isset($opcode["use"])) { out($f,"static zend_always_inline ZEND_OPCODE_HANDLER_RET {$cconv} {$spec_name}_INLINE_HANDLER(ZEND_OPCODE_HANDLER_ARGS)\n"); $additional_func = true; @@ -1465,7 +1466,7 @@ function gen_labels($f, $spec, $kind, $prolog, &$specs, $switch_labels = array() switch ($kind) { case ZEND_VM_KIND_CALL: case ZEND_VM_KIND_TAILCALL: - out($f,$prolog."ZEND_NULL${variant}_HANDLER,\n"); + out($f,$prolog."ZEND_NULL{$variant}_HANDLER,\n"); break; case ZEND_VM_KIND_SWITCH: out($f,$prolog."-1,\n"); @@ -1512,7 +1513,7 @@ function gen_labels($f, $spec, $kind, $prolog, &$specs, $switch_labels = array() switch ($kind) { case ZEND_VM_KIND_CALL: case ZEND_VM_KIND_TAILCALL: - out($f,$prolog."ZEND_NULL${variant}_HANDLER,\n"); + out($f,$prolog."ZEND_NULL{$variant}_HANDLER,\n"); break; case ZEND_VM_KIND_SWITCH: out($f,$prolog."-1,\n"); @@ -2473,20 +2474,31 @@ function gen_vm_opcodes_header( $str .= "#define ZEND_VM_KIND_GOTO\t" . ZEND_VM_KIND_GOTO . "\n"; $str .= "#define ZEND_VM_KIND_HYBRID\t" . ZEND_VM_KIND_HYBRID . "\n"; $str .= "#define ZEND_VM_KIND_TAILCALL\t" . ZEND_VM_KIND_TAILCALL . "\n"; + $str .= <<opcode], opline);\n"); out($f, "\thandler(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n"); @@ -3152,7 +3164,7 @@ function gen_vm($def, $skel) { out($f,"#else\n"); } out($f, "\t(OPLINE->handler)(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU);\n"); - if (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID) { + if (ZEND_VM_GEN_KIND == ZEND_VM_KIND_HYBRID) { out($f, "\tif (EXPECTED(opline)) {\n"); out($f,"#endif\n"); } else { @@ -3235,16 +3247,16 @@ function usage() { $kind = substr($argv[$i], strlen("--with-vm-kind=")); switch ($kind) { case "CALL": - define("ZEND_VM_KIND", ZEND_VM_KIND_CALL); + define("ZEND_VM_GEN_KIND", ZEND_VM_KIND_CALL); break; case "SWITCH": - define("ZEND_VM_KIND", ZEND_VM_KIND_SWITCH); + define("ZEND_VM_GEN_KIND", ZEND_VM_KIND_SWITCH); break; case "GOTO": - define("ZEND_VM_KIND", ZEND_VM_KIND_GOTO); + define("ZEND_VM_GEN_KIND", ZEND_VM_KIND_GOTO); break; case "HYBRID": - define("ZEND_VM_KIND", ZEND_VM_KIND_HYBRID); + define("ZEND_VM_GEN_KIND", ZEND_VM_KIND_HYBRID); break; default: echo("ERROR: Invalid vm kind '$kind'\n"); @@ -3268,9 +3280,9 @@ function usage() { } // Using defaults -if (!defined("ZEND_VM_KIND")) { +if (!defined("ZEND_VM_GEN_KIND")) { // Using CALL threading by default - define("ZEND_VM_KIND", ZEND_VM_KIND_HYBRID); + define("ZEND_VM_GEN_KIND", ZEND_VM_KIND_HYBRID); } if (!defined("ZEND_VM_SPEC")) { // Using specialized executor by default diff --git a/Zend/zend_vm_opcodes.h b/Zend/zend_vm_opcodes.h index 900b029e2b112..287dec375f3a9 100644 --- a/Zend/zend_vm_opcodes.h +++ b/Zend/zend_vm_opcodes.h @@ -30,6 +30,14 @@ #define ZEND_VM_KIND_GOTO 3 #define ZEND_VM_KIND_HYBRID 4 #define ZEND_VM_KIND_TAILCALL 5 +static const char *const zend_vm_kind_name[] = { + NULL, + "ZEND_VM_KIND_CALL", + "ZEND_VM_KIND_SWITCH", + "ZEND_VM_KIND_GOTO", + "ZEND_VM_KIND_HYBRID", + "ZEND_VM_KIND_TAILCALL", +}; #if 0 /* HYBRID requires support for computed GOTO and global register variables*/ #elif (defined(__GNUC__) && defined(HAVE_GCC_GLOBAL_REGS))