YJIT: Fix cfunc splat
Follow-up for cb8a040b7906c09d9d3ac3d3fe853f633005024f.
This commit is contained in:
parent
5875fce6ce
commit
ce476cdfb7
Notes:
git
2025-04-09 13:49:37 +00:00
Merged: https://github.com/ruby/ruby/pull/7418 Merged-By: XrXr
@ -3585,7 +3585,7 @@ assert_equal 'true', %q{
|
|||||||
1.send(:==, 1, *[])
|
1.send(:==, 1, *[])
|
||||||
}
|
}
|
||||||
|
|
||||||
# Test send with splat to a cfunc
|
# Test empty splat with cfunc
|
||||||
assert_equal '2', %q{
|
assert_equal '2', %q{
|
||||||
def foo
|
def foo
|
||||||
Integer.sqrt(4, *[])
|
Integer.sqrt(4, *[])
|
||||||
@ -3594,3 +3594,14 @@ assert_equal '2', %q{
|
|||||||
foo
|
foo
|
||||||
foo
|
foo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Test non-empty splat with cfunc
|
||||||
|
assert_equal 'Hello World', %q{
|
||||||
|
def bar
|
||||||
|
args = ["Hello "]
|
||||||
|
greeting = "World"
|
||||||
|
greeting.insert(0, *args)
|
||||||
|
greeting
|
||||||
|
end
|
||||||
|
bar
|
||||||
|
}
|
||||||
|
@ -4864,6 +4864,7 @@ fn gen_send_cfunc(
|
|||||||
|
|
||||||
// push_splat_args does stack manipulation so we can no longer side exit
|
// push_splat_args does stack manipulation so we can no longer side exit
|
||||||
if flags & VM_CALL_ARGS_SPLAT != 0 {
|
if flags & VM_CALL_ARGS_SPLAT != 0 {
|
||||||
|
assert!(cfunc_argc >= 0);
|
||||||
let required_args : u32 = (cfunc_argc as u32).saturating_sub(argc as u32 - 1);
|
let required_args : u32 = (cfunc_argc as u32).saturating_sub(argc as u32 - 1);
|
||||||
// + 1 because we pass self
|
// + 1 because we pass self
|
||||||
if required_args + 1 >= C_ARG_OPNDS.len() as u32 {
|
if required_args + 1 >= C_ARG_OPNDS.len() as u32 {
|
||||||
@ -4871,22 +4872,13 @@ fn gen_send_cfunc(
|
|||||||
return CantCompile;
|
return CantCompile;
|
||||||
}
|
}
|
||||||
|
|
||||||
if required_args == 0 {
|
// We are going to assume that the splat fills
|
||||||
// The splat is not going to supply us any arguments
|
// all the remaining arguments. So the number of args
|
||||||
// so we set the argc to the number of arguments
|
// should just equal the number of args the cfunc takes.
|
||||||
// the cfunc expects.
|
// In the generated code we test if this is true
|
||||||
// We still need to do all the splat logic because someone
|
// and if not side exit.
|
||||||
// could pass in a non-zero sized array and we need to
|
argc = cfunc_argc;
|
||||||
// exit to error.
|
passed_argc = argc;
|
||||||
argc = cfunc_argc;
|
|
||||||
passed_argc = argc;
|
|
||||||
} else {
|
|
||||||
// We are going to assume that the splat fills
|
|
||||||
// all the remaining arguments. In the generated code
|
|
||||||
// we test if this is true and if not side exit.
|
|
||||||
argc = required_args as i32;
|
|
||||||
passed_argc = argc;
|
|
||||||
}
|
|
||||||
push_splat_args(required_args, ctx, asm, ocb, side_exit)
|
push_splat_args(required_args, ctx, asm, ocb, side_exit)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user