Skip to content

Commit 9d09d82

Browse files
committed
Add flag to distinguish named fcalls
1 parent 1ed3090 commit 9d09d82

File tree

4 files changed

+41
-20
lines changed

4 files changed

+41
-20
lines changed

Zend/zend_compile.c

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3481,6 +3481,32 @@ uint32_t zend_compile_args(zend_ast *ast, zend_function *fbc) /* {{{ */
34813481
}
34823482
/* }}} */
34833483

3484+
static inline zend_bool zend_args_contain_unpack_or_named(zend_ast_list *args) /* {{{ */
3485+
{
3486+
uint32_t i;
3487+
for (i = 0; i < args->children; ++i) {
3488+
zend_ast *arg = args->child[i];
3489+
if (arg->kind == ZEND_AST_UNPACK || arg->kind == ZEND_AST_NAMED_ARG) {
3490+
return 1;
3491+
}
3492+
}
3493+
return 0;
3494+
}
3495+
/* }}} */
3496+
3497+
static inline zend_bool zend_args_contain_named(zend_ast_list *args) /* {{{ */
3498+
{
3499+
uint32_t i;
3500+
for (i = 0; i < args->children; ++i) {
3501+
zend_ast *arg = args->child[i];
3502+
if (arg->kind == ZEND_AST_NAMED_ARG) {
3503+
return 1;
3504+
}
3505+
}
3506+
return 0;
3507+
}
3508+
/* }}} */
3509+
34843510
ZEND_API zend_uchar zend_get_call_op(const zend_op *init_op, zend_function *fbc) /* {{{ */
34853511
{
34863512
if (fbc) {
@@ -3525,6 +3551,9 @@ void zend_compile_call_common(znode *result, zend_ast *args_ast, zend_function *
35253551
}
35263552

35273553
opline = zend_emit_op(result, zend_get_call_op(opline, fbc), NULL, NULL);
3554+
if (zend_args_contain_named(zend_ast_get_list(args_ast))) {
3555+
opline->extended_value = ZEND_FCALL_HAS_NAMED_ARGS;
3556+
}
35283557
zend_do_extended_fcall_end();
35293558
}
35303559
/* }}} */
@@ -3589,19 +3618,6 @@ void zend_compile_dynamic_call(znode *result, znode *name_node, zend_ast *args_a
35893618
}
35903619
/* }}} */
35913620

3592-
static inline zend_bool zend_args_contain_unpack_or_named(zend_ast_list *args) /* {{{ */
3593-
{
3594-
uint32_t i;
3595-
for (i = 0; i < args->children; ++i) {
3596-
zend_ast *arg = args->child[i];
3597-
if (arg->kind == ZEND_AST_UNPACK || arg->kind == ZEND_AST_NAMED_ARG) {
3598-
return 1;
3599-
}
3600-
}
3601-
return 0;
3602-
}
3603-
/* }}} */
3604-
36053621
int zend_compile_func_strlen(znode *result, zend_ast_list *args) /* {{{ */
36063622
{
36073623
znode arg_node;

Zend/zend_compile.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,8 @@ ZEND_API zend_string *zend_type_to_string(zend_type type);
954954

955955
#define ZEND_THROW_IS_EXPR 1u
956956

957+
#define ZEND_FCALL_HAS_NAMED_ARGS 1
958+
957959
/* The send mode and is_variadic flag are stored as part of zend_type */
958960
#define _ZEND_SEND_MODE_SHIFT _ZEND_TYPE_EXTRA_FLAGS_SHIFT
959961
#define _ZEND_IS_VARIADIC_BIT (1 << (_ZEND_TYPE_EXTRA_FLAGS_SHIFT + 2))

ext/opcache/jit/zend_jit.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2522,7 +2522,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
25222522
case ZEND_SEND_VAL:
25232523
case ZEND_SEND_VAL_EX:
25242524
if (opline->op2_type == IS_CONST) {
2525-
/* Named parameters not supported in JIT */
2525+
/* Named parameters not supported in JIT (yet) */
25262526
break;
25272527
}
25282528
if (opline->opcode == ZEND_SEND_VAL_EX
@@ -2536,7 +2536,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
25362536
goto done;
25372537
case ZEND_SEND_REF:
25382538
if (opline->op2_type == IS_CONST) {
2539-
/* Named parameters not supported in JIT */
2539+
/* Named parameters not supported in JIT (yet) */
25402540
break;
25412541
}
25422542
if (!zend_jit_send_ref(&dasm_state, opline, op_array,
@@ -2550,7 +2550,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
25502550
case ZEND_SEND_VAR_NO_REF_EX:
25512551
case ZEND_SEND_FUNC_ARG:
25522552
if (opline->op2_type == IS_CONST) {
2553-
/* Named parameters not supported in JIT */
2553+
/* Named parameters not supported in JIT (yet) */
25542554
break;
25552555
}
25562556
if ((opline->opcode == ZEND_SEND_VAR_EX
@@ -2573,7 +2573,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
25732573
goto done;
25742574
case ZEND_CHECK_FUNC_ARG:
25752575
if (opline->op2_type == IS_CONST) {
2576-
/* Named parameters not supported in JIT */
2576+
/* Named parameters not supported in JIT (yet) */
25772577
break;
25782578
}
25792579
if (opline->op2.num > MAX_ARG_FLAG_NUM) {

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8562,8 +8562,10 @@ static int zend_jit_do_fcall(dasm_State **Dst, const zend_op *opline, const zend
85628562
unknown_num_args = 1;
85638563
}
85648564

8565-
/* TODO: Only do this for named args */
8566-
unknown_num_args = 1;
8565+
bool has_named_args = opline->extended_value == ZEND_FCALL_HAS_NAMED_ARGS;
8566+
if (has_named_args) {
8567+
unknown_num_args = 1;
8568+
}
85678569

85688570
if (info) {
85698571
call_info = info->callee_info;
@@ -8870,7 +8872,8 @@ static int zend_jit_do_fcall(dasm_State **Dst, const zend_op *opline, const zend
88708872
| mov ecx, dword [FP + offsetof(zend_execute_data, This.u2.num_args)] // reload
88718873
| jmp >1
88728874
|.code
8873-
if (!func || (func->op_array.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) == 0) {
8875+
if (!has_named_args &&
8876+
(!func || (func->op_array.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) == 0)) {
88748877
if (!func) {
88758878
| // if (EXPECTED((op_array->fn_flags & ZEND_ACC_HAS_TYPE_HINTS) == 0))
88768879
| test dword [r0 + offsetof(zend_op_array, fn_flags)], ZEND_ACC_HAS_TYPE_HINTS

0 commit comments

Comments
 (0)