Skip to content

Commit

Permalink
Initialize icall undef args in jit
Browse files Browse the repository at this point in the history
  • Loading branch information
nikic committed Jul 27, 2020
1 parent a3c7adf commit df1f4e0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Zend/zend_execute.c
Expand Up @@ -4449,7 +4449,7 @@ zval * ZEND_FASTCALL zend_handle_named_arg(
return arg;
}

static int zend_handle_icall_undef_args(zend_execute_data *call) {
ZEND_API int ZEND_FASTCALL zend_handle_icall_undef_args(zend_execute_data *call) {
zend_function *fbc = call->func;
if (fbc->common.fn_flags & ZEND_ACC_USER_ARG_INFO) {
/* Magic function, let it deal with it. */
Expand Down
1 change: 1 addition & 0 deletions Zend/zend_execute.h
Expand Up @@ -349,6 +349,7 @@ ZEND_API void zend_cleanup_unfinished_execution(zend_execute_data *execute_data,
zval * ZEND_FASTCALL zend_handle_named_arg(
zend_execute_data **call_ptr, zend_string *arg_name,
uint32_t *arg_num_ptr, void **cache_slot);
ZEND_API int ZEND_FASTCALL zend_handle_icall_undef_args(zend_execute_data *call);

#define CACHE_ADDR(num) \
((void**)((char*)EX(run_time_cache) + (num)))
Expand Down
22 changes: 18 additions & 4 deletions ext/opcache/jit/zend_jit_x86.dasc
Expand Up @@ -8986,6 +8986,23 @@ static int zend_jit_do_fcall(dasm_State **Dst, const zend_op *opline, const zend
}
}

| // EG(current_execute_data) = execute_data;
| MEM_OP2_1_ZTS mov, aword, executor_globals, current_execute_data, RX, r1

if (may_have_named_args) {
| test byte [RX + offsetof(zend_execute_data, This.u1.type_info) + 3], (ZEND_CALL_MAY_HAVE_UNDEF >> 24)
| jnz >1
|.cold_code
|1:
| mov FCARG1a, RX
| EXT_CALL zend_handle_icall_undef_args, r0
| jnz ->exception_handler
| mov r0, EX:RX->func // reload
| jmp >2
|.code
|2:
}

if (!RETURN_VALUE_USED(opline)) {
|.if not(X64WIN)
| sub r4, 16 /* alloca() */
Expand All @@ -8996,9 +9013,6 @@ static int zend_jit_do_fcall(dasm_State **Dst, const zend_op *opline, const zend
| LOAD_ZVAL_ADDR FCARG2a, res_addr
| SET_Z_TYPE_INFO FCARG2a, IS_NULL

| // EG(current_execute_data) = execute_data;
| MEM_OP2_1_ZTS mov, aword, executor_globals, current_execute_data, RX, r1

zend_jit_reset_opline(Dst, NULL);

| // fbc->internal_function.handler(call, ret);
Expand All @@ -9025,8 +9039,8 @@ static int zend_jit_do_fcall(dasm_State **Dst, const zend_op *opline, const zend
if (may_have_named_args) {
| test byte [RX + offsetof(zend_execute_data, This.u1.type_info) + 3], (ZEND_CALL_HAS_EXTRA_NAMED_PARAMS >> 24)
| jnz >1
|1:
|.cold_code
|1:
| mov FCARG1a, aword [RX + offsetof(zend_execute_data, extra_named_params)]
| EXT_CALL zend_array_destroy, r0
| jmp >2
Expand Down

0 comments on commit df1f4e0

Please sign in to comment.