Skip to content

Commit 5efde93

Browse files
authored
Enable the TAILCALL VM when building with --disable-gcc-global-regs on GCC >= 16 (#23603)
1 parent 48e53b0 commit 5efde93

4 files changed

Lines changed: 24 additions & 18 deletions

File tree

‎NEWS‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ PHP NEWS
114114
when $allow_string is false is now deprecated. (Daniel Scherzer)
115115
. Fixed bug GH-23232 (lone namespace separator asks the autoloader for an
116116
empty class name). (spawnia)
117+
. Enabled the TAILCALL VM (--disable-gcc-global-regs) when building with GCC >= 16.
118+
(henderkes)
117119

118120
- CLI:
119121
. Fixed bug GH-23242 (PHP development server does not support Expect

‎Zend/zend_vm_gen.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2522,7 +2522,7 @@ function gen_vm_opcodes_header(
25222522
$str .= "# define ZEND_VM_KIND\t\tZEND_VM_KIND_HYBRID\n";
25232523
}
25242524
if ($GLOBALS["vm_kind_name"][ZEND_VM_GEN_KIND] === "ZEND_VM_KIND_HYBRID" || $GLOBALS["vm_kind_name"][ZEND_VM_GEN_KIND] === "ZEND_VM_KIND_CALL") {
2525-
$str .= "#elif defined(HAVE_MUSTTAIL) && defined(HAVE_PRESERVE_NONE) && (defined(__x86_64__) || defined(_M_X64) || defined(__aarch64__)) && defined(__clang__)\n";
2525+
$str .= "#elif defined(HAVE_MUSTTAIL) && defined(HAVE_PRESERVE_NONE) && (defined(__x86_64__) || defined(__aarch64__))\n";
25262526
$str .= "# define ZEND_VM_KIND\t\tZEND_VM_KIND_TAILCALL\n";
25272527
$str .= "#else\n";
25282528
$str .= "# define ZEND_VM_KIND\t\tZEND_VM_KIND_CALL\n";

‎Zend/zend_vm_opcodes.h‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎ext/opcache/jit/zend_jit.c‎

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3100,23 +3100,10 @@ static int zend_real_jit_func(zend_op_array *op_array, zend_script *script, cons
31003100
return FAILURE;
31013101
}
31023102

3103-
/* Run-time JIT handler */
3104-
#if ZEND_VM_KIND == ZEND_VM_KIND_CALL || ZEND_VM_KIND == ZEND_VM_KIND_TAILCALL
3105-
static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV zend_runtime_jit(ZEND_OPCODE_HANDLER_ARGS)
3106-
#else
3107-
static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV zend_runtime_jit(ZEND_OPCODE_HANDLER_ARGS)
3108-
#endif
3103+
/* GCC cannot tail-call from a function that uses setjmp. */
3104+
static zend_never_inline void zend_runtime_jit_compile(zend_op_array *op_array)
31093105
{
3110-
#if GCC_GLOBAL_REGS
3111-
zend_execute_data *execute_data;
3112-
zend_op *opline;
3113-
#else
3114-
const zend_op *orig_opline = opline;
3115-
#endif
3116-
3117-
execute_data = EG(current_execute_data);
3118-
zend_op_array *op_array = &EX(func)->op_array;
3119-
opline = op_array->opcodes;
3106+
const zend_op *opline = op_array->opcodes;
31203107
zend_jit_op_array_extension *jit_extension;
31213108
bool do_bailout = 0;
31223109

@@ -3154,6 +3141,23 @@ static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV zend_runtime_jit(Z
31543141
if (do_bailout) {
31553142
zend_bailout();
31563143
}
3144+
}
3145+
3146+
/* Run-time JIT handler */
3147+
#if ZEND_VM_KIND == ZEND_VM_KIND_CALL || ZEND_VM_KIND == ZEND_VM_KIND_TAILCALL
3148+
static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_CCONV zend_runtime_jit(ZEND_OPCODE_HANDLER_ARGS)
3149+
#else
3150+
static ZEND_OPCODE_HANDLER_RET ZEND_OPCODE_HANDLER_FUNC_CCONV zend_runtime_jit(ZEND_OPCODE_HANDLER_ARGS)
3151+
#endif
3152+
{
3153+
#if GCC_GLOBAL_REGS
3154+
zend_execute_data *execute_data;
3155+
#else
3156+
const zend_op *orig_opline = opline;
3157+
#endif
3158+
3159+
execute_data = EG(current_execute_data);
3160+
zend_runtime_jit_compile(&EX(func)->op_array);
31573161

31583162
/* JIT-ed code is going to be called by VM */
31593163
#if GCC_GLOBAL_REGS

0 commit comments

Comments
 (0)