Skip to content

Commit

Permalink
JIT: Update run_time_cache slot in zend_jit_find_func helper
Browse files Browse the repository at this point in the history
  • Loading branch information
dstogov committed Sep 7, 2021
1 parent c8f858e commit d4ed6b6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 3 additions & 5 deletions ext/opcache/jit/zend_jit_arm64.dasc
Original file line number Diff line number Diff line change
Expand Up @@ -8464,21 +8464,19 @@ static int zend_jit_init_fcall(dasm_State **Dst, const zend_op *opline, uint32_t

if (opline->opcode == ZEND_INIT_FCALL) {
| LOAD_ADDR FCARG1x, Z_STR_P(zv);
| add FCARG2x, REG2, #opline->result.num
| EXT_CALL zend_jit_find_func_helper, REG0
} else if (opline->opcode == ZEND_INIT_FCALL_BY_NAME) {
| LOAD_ADDR FCARG1x, Z_STR_P(zv + 1);
| add FCARG2x, REG2, #opline->result.num
| EXT_CALL zend_jit_find_func_helper, REG0
} else if (opline->opcode == ZEND_INIT_NS_FCALL_BY_NAME) {
| LOAD_ADDR FCARG1x, zv;
| add FCARG2x, REG2, #opline->result.num
| EXT_CALL zend_jit_find_ns_func_helper, REG0
} else {
ZEND_UNREACHABLE();
}
| // CACHE_PTR(opline->result.num, fbc);
| ldr REG1, EX->run_time_cache
| // Get the return value of function zend_jit_find_func_helper/zend_jit_find_ns_func_helper
| mov REG0, RETVALx
| str REG0, [REG1, #opline->result.num]
if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE) {
int32_t exit_point = zend_jit_trace_get_exit_point(opline, 0);
const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point);
Expand Down
6 changes: 4 additions & 2 deletions ext/opcache/jit/zend_jit_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ static zend_never_inline zend_op_array* ZEND_FASTCALL zend_jit_init_func_run_tim
}
/* }}} */

static zend_function* ZEND_FASTCALL zend_jit_find_func_helper(zend_string *name)
static zend_function* ZEND_FASTCALL zend_jit_find_func_helper(zend_string *name, void **cache_slot)
{
zval *func = zend_hash_find_known_hash(EG(function_table), name);
zend_function *fbc;
Expand All @@ -73,10 +73,11 @@ static zend_function* ZEND_FASTCALL zend_jit_find_func_helper(zend_string *name)
if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!RUN_TIME_CACHE(&fbc->op_array))) {
fbc = _zend_jit_init_func_run_time_cache(&fbc->op_array);
}
*cache_slot = fbc;
return fbc;
}

static zend_function* ZEND_FASTCALL zend_jit_find_ns_func_helper(zval *func_name)
static zend_function* ZEND_FASTCALL zend_jit_find_ns_func_helper(zval *func_name, void **cache_slot)
{
zval *func = zend_hash_find_known_hash(EG(function_table), Z_STR_P(func_name + 1));
zend_function *fbc;
Expand All @@ -91,6 +92,7 @@ static zend_function* ZEND_FASTCALL zend_jit_find_ns_func_helper(zval *func_name
if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!RUN_TIME_CACHE(&fbc->op_array))) {
fbc = _zend_jit_init_func_run_time_cache(&fbc->op_array);
}
*cache_slot = fbc;
return fbc;
}

Expand Down
6 changes: 3 additions & 3 deletions ext/opcache/jit/zend_jit_x86.dasc
Original file line number Diff line number Diff line change
Expand Up @@ -9030,19 +9030,19 @@ static int zend_jit_init_fcall(dasm_State **Dst, const zend_op *opline, uint32_t

if (opline->opcode == ZEND_INIT_FCALL) {
| LOAD_ADDR FCARG1a, Z_STR_P(zv);
| lea FCARG2a, aword [r2 + opline->result.num]
| EXT_CALL zend_jit_find_func_helper, r0
} else if (opline->opcode == ZEND_INIT_FCALL_BY_NAME) {
| LOAD_ADDR FCARG1a, Z_STR_P(zv + 1);
| lea FCARG2a, aword [r2 + opline->result.num]
| EXT_CALL zend_jit_find_func_helper, r0
} else if (opline->opcode == ZEND_INIT_NS_FCALL_BY_NAME) {
| LOAD_ADDR FCARG1a, zv;
| lea FCARG2a, aword [r2 + opline->result.num]
| EXT_CALL zend_jit_find_ns_func_helper, r0
} else {
ZEND_UNREACHABLE();
}
| // CACHE_PTR(opline->result.num, fbc);
| mov r1, EX->run_time_cache
| mov aword [r1 + opline->result.num], r0
if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE) {
int32_t exit_point = zend_jit_trace_get_exit_point(opline, 0);
const void *exit_addr = zend_jit_trace_get_exit_addr(exit_point);
Expand Down

2 comments on commit d4ed6b6

@nikic
Copy link
Member

@nikic nikic commented on d4ed6b6 Sep 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like one of the recent commits broke the ARM JIT: https://app.travis-ci.com/github/php/php-src/jobs/535941759 There are many "Call to undefined function" errors.

@dstogov
Copy link
Member Author

@dstogov dstogov commented on d4ed6b6 Sep 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. This should be fixed by 487efac

Please sign in to comment.