Skip to content

Commit

Permalink
YJIT: Filter & calls from specialized C method codegen
Browse files Browse the repository at this point in the history
Evident with the crash reported in [Bug #20997], the C replacement
codegen functions aren't authored to handle block arguments (nor
should they because the extra code from the complexity defeats
optimization). Filter sites with VM_CALL_ARGS_BLOCKARG.
  • Loading branch information
XrXr committed Jan 9, 2025
1 parent 96f2330 commit dd80d9b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions bootstraptest/test_yjit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5347,3 +5347,11 @@ def reverse_even
Swap.new("xy").swap + Swap.new("cat").reverse_odd + Swap.new("abcd").reverse_even
RUBY

assert_normal_exit %{
class Bug20997
def foo(&) = self.class.name(&)
new.foo
end
}
3 changes: 2 additions & 1 deletion yjit/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6894,11 +6894,12 @@ fn gen_send_cfunc(
// Increment total cfunc send count
gen_counter_incr(jit, asm, Counter::num_send_cfunc);

// Delegate to codegen for C methods if we have it.
// Delegate to codegen for C methods if we have it and the callsite is simple enough.
if kw_arg.is_null() &&
!kw_splat &&
flags & VM_CALL_OPT_SEND == 0 &&
flags & VM_CALL_ARGS_SPLAT == 0 &&
flags & VM_CALL_ARGS_BLOCKARG == 0 &&
(cfunc_argc == -1 || argc == cfunc_argc) {
let expected_stack_after = asm.ctx.get_stack_size() as i32 - argc;
if let Some(known_cfunc_codegen) = lookup_cfunc_codegen(unsafe { (*cme).def }) {
Expand Down

0 comments on commit dd80d9b

Please sign in to comment.