Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
424f0b6
Partial named params implementation
nikic Apr 6, 2020
4afe5b4
Check for duplicate parameter names in internal functions
nikic Jul 24, 2020
a8e7462
Add AST export support
nikic Jul 27, 2020
8b14583
Fix test name
nikic Jul 27, 2020
75964c0
Add tests for Attribut(flags: )
nikic Jul 27, 2020
e550f4a
Only check for undef in RECV(_INIT)
nikic Jul 27, 2020
d346bbd
Check for undef in recv jit
nikic Jul 27, 2020
8bdd1a9
Add flag to distinguish named fcalls
nikic Jul 27, 2020
883c0a5
SEND may throw for named params
nikic Jul 27, 2020
3683f0e
For unpacks, we should also assume there may be named args
nikic Jul 27, 2020
368500b
Free extra named args in jit
nikic Jul 27, 2020
d0492b1
Initialize icall undef args in jit
nikic Jul 27, 2020
bb79eed
Always emit type check in RECV_INIT
nikic Jul 28, 2020
268b69c
Fix attribtue tests for new syntax
nikic Jul 28, 2020
fc37bc0
WIP
nikic Jul 30, 2020
5fddc6f
Fixes
nikic Jul 30, 2020
06a4ab7
Cleanup
nikic Jul 30, 2020
a46694c
jit
nikic Jul 30, 2020
1aec287
Fix windows?
nikic Jul 30, 2020
a164e5d
Rename opcode to be more precise
nikic Jul 30, 2020
90dac08
Make flag meaning more precise
nikic Jul 31, 2020
a9a0252
Make compiler code a bit smarter
nikic Jul 31, 2020
2700037
Move function back to where it was
nikic Jul 31, 2020
0f9131e
Rename function to match opcode name
nikic Jul 31, 2020
141ded0
jit cleanup
nikic Jul 31, 2020
077886d
Support extra named params in backtraces
nikic Jul 31, 2020
3e45549
Prepare for extra named params reuse
nikic Jul 31, 2020
e77c2b6
Reuse extra_named_params if possible
nikic Jul 31, 2020
e31838a
Combine check for extra named params and allocated call
nikic Jul 31, 2020
ed108d4
Drop one of the free extra named params helpers
nikic Jul 31, 2020
a6b566d
Revert an incorrect change
nikic Jul 31, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add flag to distinguish named fcalls
  • Loading branch information
nikic committed Jul 31, 2020
commit 8bdd1a95f0359f5aa19d200cb13dfb91cb55c10b
42 changes: 29 additions & 13 deletions Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -3484,6 +3484,32 @@ uint32_t zend_compile_args(zend_ast *ast, zend_function *fbc) /* {{{ */
}
/* }}} */

static inline zend_bool zend_args_contain_unpack_or_named(zend_ast_list *args) /* {{{ */
{
uint32_t i;
for (i = 0; i < args->children; ++i) {
zend_ast *arg = args->child[i];
if (arg->kind == ZEND_AST_UNPACK || arg->kind == ZEND_AST_NAMED_ARG) {
return 1;
}
}
return 0;
}
/* }}} */

static inline zend_bool zend_args_contain_named(zend_ast_list *args) /* {{{ */
{
uint32_t i;
for (i = 0; i < args->children; ++i) {
zend_ast *arg = args->child[i];
if (arg->kind == ZEND_AST_NAMED_ARG) {
return 1;
}
}
return 0;
}
/* }}} */

ZEND_API zend_uchar zend_get_call_op(const zend_op *init_op, zend_function *fbc) /* {{{ */
{
if (fbc) {
Expand Down Expand Up @@ -3528,6 +3554,9 @@ void zend_compile_call_common(znode *result, zend_ast *args_ast, zend_function *
}

opline = zend_emit_op(result, zend_get_call_op(opline, fbc), NULL, NULL);
if (zend_args_contain_named(zend_ast_get_list(args_ast))) {
opline->extended_value = ZEND_FCALL_HAS_NAMED_ARGS;
}
zend_do_extended_fcall_end();
}
/* }}} */
Expand Down Expand Up @@ -3592,19 +3621,6 @@ void zend_compile_dynamic_call(znode *result, znode *name_node, zend_ast *args_a
}
/* }}} */

static inline zend_bool zend_args_contain_unpack_or_named(zend_ast_list *args) /* {{{ */
{
uint32_t i;
for (i = 0; i < args->children; ++i) {
zend_ast *arg = args->child[i];
if (arg->kind == ZEND_AST_UNPACK || arg->kind == ZEND_AST_NAMED_ARG) {
return 1;
}
}
return 0;
}
/* }}} */

int zend_compile_func_strlen(znode *result, zend_ast_list *args) /* {{{ */
{
znode arg_node;
Expand Down
2 changes: 2 additions & 0 deletions Zend/zend_compile.h
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,8 @@ ZEND_API zend_string *zend_type_to_string(zend_type type);

#define ZEND_THROW_IS_EXPR 1u

#define ZEND_FCALL_HAS_NAMED_ARGS 1

/* The send mode and is_variadic flag are stored as part of zend_type */
#define _ZEND_SEND_MODE_SHIFT _ZEND_TYPE_EXTRA_FLAGS_SHIFT
#define _ZEND_IS_VARIADIC_BIT (1 << (_ZEND_TYPE_EXTRA_FLAGS_SHIFT + 2))
Expand Down
8 changes: 4 additions & 4 deletions ext/opcache/jit/zend_jit.c
Original file line number Diff line number Diff line change
Expand Up @@ -2522,7 +2522,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
case ZEND_SEND_VAL:
case ZEND_SEND_VAL_EX:
if (opline->op2_type == IS_CONST) {
/* Named parameters not supported in JIT */
/* Named parameters not supported in JIT (yet) */
break;
}
if (opline->opcode == ZEND_SEND_VAL_EX
Expand All @@ -2536,7 +2536,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
goto done;
case ZEND_SEND_REF:
if (opline->op2_type == IS_CONST) {
/* Named parameters not supported in JIT */
/* Named parameters not supported in JIT (yet) */
break;
}
if (!zend_jit_send_ref(&dasm_state, opline, op_array,
Expand All @@ -2550,7 +2550,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
case ZEND_SEND_VAR_NO_REF_EX:
case ZEND_SEND_FUNC_ARG:
if (opline->op2_type == IS_CONST) {
/* Named parameters not supported in JIT */
/* Named parameters not supported in JIT (yet) */
break;
}
if ((opline->opcode == ZEND_SEND_VAR_EX
Expand All @@ -2573,7 +2573,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
goto done;
case ZEND_CHECK_FUNC_ARG:
if (opline->op2_type == IS_CONST) {
/* Named parameters not supported in JIT */
/* Named parameters not supported in JIT (yet) */
break;
}
if (opline->op2.num > MAX_ARG_FLAG_NUM) {
Expand Down
9 changes: 6 additions & 3 deletions ext/opcache/jit/zend_jit_x86.dasc
Original file line number Diff line number Diff line change
Expand Up @@ -8571,8 +8571,10 @@ static int zend_jit_do_fcall(dasm_State **Dst, const zend_op *opline, const zend
unknown_num_args = 1;
}

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

if (info) {
call_info = info->callee_info;
Expand Down Expand Up @@ -8879,7 +8881,8 @@ static int zend_jit_do_fcall(dasm_State **Dst, const zend_op *opline, const zend
| mov ecx, dword [FP + offsetof(zend_execute_data, This.u2.num_args)] // reload
| jmp >1
|.code
if (!func || (func->op_array.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) == 0) {
if (!has_named_args &&
(!func || (func->op_array.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) == 0)) {
if (!func) {
| // if (EXPECTED((op_array->fn_flags & ZEND_ACC_HAS_TYPE_HINTS) == 0))
| test dword [r0 + offsetof(zend_op_array, fn_flags)], ZEND_ACC_HAS_TYPE_HINTS
Expand Down