Skip to content

Commit 984df80

Browse files
committed
Merge branch 'PHP-8.0'
* PHP-8.0: Initialize EX(call)->func by single instruction Reuse value stored in %r0 instead of immediate operand
2 parents 0e7bae6 + da0ca53 commit 984df80

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 19 additions & 9 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

@@ -8807,7 +8807,7 @@ static int zend_jit_push_call_frame(dasm_State **Dst, const zend_op *opline, zen
88078807
#ifdef _WIN32
88088808
if (0) {
88098809
#else
8810-
if (func && func->type == ZEND_INTERNAL_FUNCTION) {
8810+
if (opline->opcode == ZEND_INIT_FCALL && func && func->type == ZEND_INTERNAL_FUNCTION) {
88118811
#endif
88128812
| SET_EX_OPLINE opline, r0
88138813
| EXT_CALL zend_jit_int_extend_stack_helper, r0
@@ -8839,15 +8839,22 @@ static int zend_jit_push_call_frame(dasm_State **Dst, const zend_op *opline, zen
88398839
#ifdef _WIN32
88408840
if (0) {
88418841
#else
8842-
if (func && func->type == ZEND_INTERNAL_FUNCTION) {
8842+
if (opline->opcode == ZEND_INIT_FCALL && func && func->type == ZEND_INTERNAL_FUNCTION) {
88438843
#endif
88448844
| // call->func = func;
88458845
|1:
88468846
| ADDR_OP2_2 mov, aword EX:RX->func, func, r1
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)