Skip to content

Commit 39cfe84

Browse files
committed
Optimize argument preparation for small positional calls
1 parent 7e7e593 commit 39cfe84

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

‎Zend/zend_execute_API.c‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,37 @@ zend_result zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_
923923

924924
ZEND_ASSERT((consumed_args & (consumed_args - 1)) == 0);
925925

926+
if (!consumed_args && !fci->named_params) {
927+
switch (fci->param_count) {
928+
case 2:
929+
if (UNEXPECTED(QUICK_ARG_SHOULD_BE_SENT_BY_REF(func, 2) || Z_ISUNDEF(fci->params[1]))) {
930+
break;
931+
}
932+
ZEND_FALLTHROUGH;
933+
case 1:
934+
if (UNEXPECTED(QUICK_ARG_SHOULD_BE_SENT_BY_REF(func, 1) || Z_ISUNDEF(fci->params[0]))) {
935+
break;
936+
}
937+
938+
if (!(func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE)) {
939+
ZVAL_COPY_DEREF(ZEND_CALL_ARG(call, 1), &fci->params[0]);
940+
if (fci->param_count == 2) {
941+
ZVAL_COPY_DEREF(ZEND_CALL_ARG(call, 2), &fci->params[1]);
942+
}
943+
} else {
944+
/* Don't separate references for __call */
945+
ZVAL_COPY(ZEND_CALL_ARG(call, 1), &fci->params[0]);
946+
if (fci->param_count == 2) {
947+
ZVAL_COPY(ZEND_CALL_ARG(call, 2), &fci->params[1]);
948+
}
949+
}
950+
951+
ZEND_FALLTHROUGH;
952+
case 0:
953+
goto args_prepared;
954+
}
955+
}
956+
926957
for (uint32_t i = 0; i < fci->param_count; i++) {
927958
zval *param = ZEND_CALL_ARG(call, i+1);
928959
zval *arg = &fci->params[i];
@@ -1054,6 +1085,7 @@ zend_result zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_
10541085
}
10551086
}
10561087

1088+
args_prepared:
10571089
if (UNEXPECTED(func->op_array.fn_flags & ZEND_ACC_CLOSURE)) {
10581090
uint32_t call_info;
10591091

0 commit comments

Comments
 (0)