Thanks to visit codestin.com
Credit goes to github.com

Skip to content

YJIT: Speculate block arg for c_func_method(&nil) calls #12326

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 10 additions & 18 deletions yjit/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6949,41 +6949,33 @@ fn gen_send_cfunc(
return None;
}

let block_arg_type = if block_arg {
let mut block_arg_type = if block_arg {
Some(asm.ctx.get_opnd_type(StackOpnd(0)))
} else {
None
};

match block_arg_type {
Some(Type::Nil | Type::BlockParamProxy) => {
// We'll handle this later
}
None => {
// Nothing to do
}
_ => {
gen_counter_incr(jit, asm, Counter::send_cfunc_block_arg);
return None;
}
}

match block_arg_type {
Some(Type::Nil) => {
// We have a nil block arg, so let's pop it off the args
// We don't need the actual stack value for these
asm.stack_pop(1);
}
Some(Type::BlockParamProxy) => {
// We don't need the actual stack value
Some(Type::Unknown | Type::UnknownImm) if jit.peek_at_stack(&asm.ctx, 0).nil_p() => {
// The sample blockarg is nil, so speculate that's the case.
asm.cmp(asm.stack_opnd(0), Qnil.into());
asm.jne(Target::side_exit(Counter::guard_send_cfunc_block_not_nil));
block_arg_type = Some(Type::Nil);
asm.stack_pop(1);
}
None => {
// Nothing to do
}
_ => {
assert!(false);
gen_counter_incr(jit, asm, Counter::send_cfunc_block_arg);
return None;
}
}
let block_arg_type = block_arg_type; // drop `mut`

// Pop the empty kw_splat hash
if kw_splat {
Expand Down
1 change: 1 addition & 0 deletions yjit/src/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ make_counters! {
guard_send_str_aref_not_fixnum,

guard_send_cfunc_bad_splat_vargs,
guard_send_cfunc_block_not_nil,

guard_invokesuper_me_changed,

Expand Down
Loading