Skip to content

Commit 3715475

Browse files
committed
JIT for INIT_NS_FCALL_BY_NAME
1 parent 57042ac commit 3715475

File tree

5 files changed

+27
-5
lines changed

5 files changed

+27
-5
lines changed

ext/opcache/jit/zend_jit.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2437,6 +2437,7 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
24372437
goto done;
24382438
case ZEND_INIT_FCALL:
24392439
case ZEND_INIT_FCALL_BY_NAME:
2440+
case ZEND_INIT_NS_FCALL_BY_NAME:
24402441
if (!zend_jit_init_fcall(&dasm_state, opline, b, op_array, ssa, call_level, NULL)) {
24412442
goto jit_failure;
24422443
}

ext/opcache/jit/zend_jit_disasm_x86.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,7 @@ static int zend_jit_disasm_init(void)
397397
REGISTER_HELPER(memcmp);
398398
REGISTER_HELPER(zend_jit_init_func_run_time_cache_helper);
399399
REGISTER_HELPER(zend_jit_find_func_helper);
400+
REGISTER_HELPER(zend_jit_find_ns_func_helper);
400401
REGISTER_HELPER(zend_jit_extend_stack_helper);
401402
REGISTER_HELPER(zend_jit_int_extend_stack_helper);
402403
REGISTER_HELPER(zend_jit_leave_nested_func_helper);

ext/opcache/jit/zend_jit_helpers.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,24 @@ static zend_function* ZEND_FASTCALL zend_jit_find_func_helper(zend_string *name)
6666
return fbc;
6767
}
6868

69+
static zend_function* ZEND_FASTCALL zend_jit_find_ns_func_helper(zval *func_name)
70+
{
71+
zval *func = zend_hash_find_ex(EG(function_table), Z_STR_P(func_name + 1), 1);
72+
zend_function *fbc;
73+
74+
if (func == NULL) {
75+
func = zend_hash_find_ex(EG(function_table), Z_STR_P(func_name + 2), 1);
76+
if (UNEXPECTED(func == NULL)) {
77+
return NULL;
78+
}
79+
}
80+
fbc = Z_FUNC_P(func);
81+
if (EXPECTED(fbc->type == ZEND_USER_FUNCTION) && UNEXPECTED(!RUN_TIME_CACHE(&fbc->op_array))) {
82+
fbc = _zend_jit_init_func_run_time_cache(&fbc->op_array);
83+
}
84+
return fbc;
85+
}
86+
6987
static zend_execute_data* ZEND_FASTCALL zend_jit_extend_stack_helper(uint32_t used_stack, zend_function *fbc)
7088
{
7189
zend_execute_data *call = (zend_execute_data*)zend_vm_stack_extend(used_stack);

ext/opcache/jit/zend_jit_trace.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2171,6 +2171,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
21712171
goto done;
21722172
case ZEND_INIT_FCALL:
21732173
case ZEND_INIT_FCALL_BY_NAME:
2174+
case ZEND_INIT_NS_FCALL_BY_NAME:
21742175
if (!zend_jit_init_fcall(&dasm_state, opline, op_array_ssa->cfg.map ? op_array_ssa->cfg.map[opline - op_array->opcodes] : -1, op_array, op_array_ssa, call_level, p + 1)) {
21752176
goto jit_failure;
21762177
}
@@ -2660,8 +2661,6 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
26602661
}
26612662
goto done;
26622663
#endif
2663-
// case ZEND_INIT_NS_FCALL_BY_NAME:
2664-
// TODO: we may need a guard after INIT_NS_FCALL???
26652664
case ZEND_INIT_METHOD_CALL:
26662665
case ZEND_INIT_DYNAMIC_CALL:
26672666
if (!zend_jit_trace_handler(&dasm_state, op_array, opline, zend_may_throw(opline, ssa_op, op_array, ssa), p + 1)) {

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7740,8 +7740,7 @@ static int zend_jit_init_fcall(dasm_State **Dst, const zend_op *opline, uint32_t
77407740

77417741
if (!func
77427742
&& trace
7743-
&& trace->op == ZEND_JIT_TRACE_INIT_CALL
7744-
&& (opline->opcode == ZEND_INIT_FCALL || opline->opcode == ZEND_INIT_FCALL_BY_NAME)) {
7743+
&& trace->op == ZEND_JIT_TRACE_INIT_CALL) {
77457744
/* TODO: add guard ??? */
77467745
func = (zend_function*)trace->func;
77477746
}
@@ -7774,12 +7773,16 @@ static int zend_jit_init_fcall(dasm_State **Dst, const zend_op *opline, uint32_t
77747773

77757774
if (opline->opcode == ZEND_INIT_FCALL) {
77767775
| LOAD_ADDR FCARG1a, Z_STR_P(zv);
7776+
| EXT_CALL zend_jit_find_func_helper, r0
77777777
} else if (opline->opcode == ZEND_INIT_FCALL_BY_NAME) {
77787778
| LOAD_ADDR FCARG1a, Z_STR_P(zv + 1);
7779+
| EXT_CALL zend_jit_find_func_helper, r0
7780+
} else if (opline->opcode == ZEND_INIT_NS_FCALL_BY_NAME) {
7781+
| LOAD_ADDR FCARG1a, zv;
7782+
| EXT_CALL zend_jit_find_ns_func_helper, r0
77797783
} else {
77807784
ZEND_ASSERT(0);
77817785
}
7782-
| EXT_CALL zend_jit_find_func_helper, r0
77837786
| // CACHE_PTR(opline->result.num, fbc);
77847787
| mov r1, EX->run_time_cache
77857788
| mov aword [r1 + opline->result.num], r0

0 commit comments

Comments
 (0)