Skip to content

Commit da0ca53

Browse files
committed
Initialize EX(call)->func by single instruction
1 parent 56fde2a commit da0ca53

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8734,7 +8734,7 @@ static int zend_jit_stack_check(dasm_State **Dst, const zend_op *opline, uint32_
87348734
return 1;
87358735
}
87368736

8737-
static int zend_jit_push_call_frame(dasm_State **Dst, const zend_op *opline, zend_function *func, zend_bool is_closure, zend_bool use_this, zend_bool stack_check)
8737+
static int zend_jit_push_call_frame(dasm_State **Dst, const zend_op *opline, const zend_op_array *op_array, zend_function *func, zend_bool is_closure, zend_bool use_this, zend_bool stack_check)
87388738
{
87398739
uint32_t used_stack;
87408740

@@ -8847,7 +8847,14 @@ static int zend_jit_push_call_frame(dasm_State **Dst, const zend_op *opline, zen
88478847
} else {
88488848
if (!is_closure) {
88498849
| // call->func = func;
8850-
| mov aword EX:RX->func, r0
8850+
if (func
8851+
&& op_array == &func->op_array
8852+
&& (func->op_array.fn_flags & ZEND_ACC_IMMUTABLE)
8853+
&& (sizeof(void*) != 8 || IS_SIGNED_32BIT(func))) {
8854+
| ADDR_OP2_2 mov, aword EX:RX->func, func, r1
8855+
} else {
8856+
| mov aword EX:RX->func, r0
8857+
}
88518858
} else {
88528859
| // call->func = &closure->func;
88538860
| lea r1, aword [r0 + offsetof(zend_closure, func)]
@@ -9209,8 +9216,11 @@ static int zend_jit_init_fcall(dasm_State **Dst, const zend_op *opline, uint32_t
92099216
#endif
92109217
/* load constant address later */
92119218
} else if (func && op_array == &func->op_array) {
9212-
/* recursive call */
9213-
| mov r0, EX->func
9219+
/* recursive call */
9220+
if (!(func->op_array.fn_flags & ZEND_ACC_IMMUTABLE) ||
9221+
(sizeof(void*) == 8 && !IS_SIGNED_32BIT(func))) {
9222+
| mov r0, EX->func
9223+
}
92149224
} else {
92159225
| // if (CACHED_PTR(opline->result.num))
92169226
| mov r0, EX->run_time_cache
@@ -9298,7 +9308,7 @@ static int zend_jit_init_fcall(dasm_State **Dst, const zend_op *opline, uint32_t
92989308
|3:
92999309
}
93009310

9301-
if (!zend_jit_push_call_frame(Dst, opline, func, 0, 0, stack_check)) {
9311+
if (!zend_jit_push_call_frame(Dst, opline, op_array, func, 0, 0, stack_check)) {
93029312
return 0;
93039313
}
93049314

@@ -9543,7 +9553,7 @@ static int zend_jit_init_method_call(dasm_State **Dst,
95439553
}
95449554

95459555
if (!func || (func->common.fn_flags & ZEND_ACC_STATIC) == 0) {
9546-
if (!zend_jit_push_call_frame(Dst, opline, func, 0, use_this, stack_check)) {
9556+
if (!zend_jit_push_call_frame(Dst, opline, NULL, func, 0, use_this, stack_check)) {
95479557
return 0;
95489558
}
95499559
}
@@ -9642,7 +9652,7 @@ static int zend_jit_init_closure_call(dasm_State **Dst,
96429652
}
96439653
}
96449654

9645-
if (!zend_jit_push_call_frame(Dst, opline, func, 1, 0, stack_check)) {
9655+
if (!zend_jit_push_call_frame(Dst, opline, NULL, func, 1, 0, stack_check)) {
96469656
return 0;
96479657
}
96489658

0 commit comments

Comments
 (0)