Calling into a C func shouldn't fast path when forwarding

When we forward calls to C functions if the callsite is a forwarding
site it might not always be a splat, so we can't use the fast path.

Fixes:

[ruby-core:118418]
This commit is contained in:
eileencodes 2024-07-02 13:31:15 -04:00 committed by Aaron Patterson
parent 4d94d28a4a
commit cc8c4a60b7
2 changed files with 16 additions and 1 deletions

View File

@ -1344,3 +1344,18 @@ assert_equal 'ok', %q{
C.new.foo
}
assert_equal 'ok', %q{
class C
def initialize(a)
end
end
def foo(...)
C.new(...)
:ok
end
foo(*["bar"])
foo("baz")
}

View File

@ -3907,7 +3907,7 @@ vm_call_cfunc(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, struct rb
const struct rb_callinfo *ci = calling->cd->ci;
RB_DEBUG_COUNTER_INC(ccf_cfunc);
if (IS_ARGS_SPLAT(ci)) {
if (IS_ARGS_SPLAT(ci) && !(vm_ci_flag(ci) & VM_CALL_FORWARDING)) {
if (!IS_ARGS_KW_SPLAT(ci) && vm_ci_argc(ci) == 1) {
// f(*a)
CC_SET_FASTPATH(calling->cc, vm_call_cfunc_only_splat, TRUE);