Skip to content
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

YJIT: Fix clippy issues and remove unused params #7348

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 9 additions & 16 deletions yjit/src/codegen.rs
Expand Up @@ -238,7 +238,7 @@ fn jit_save_pc(jit: &JITState, asm: &mut Assembler) {
/// This realigns the interpreter SP with the JIT SP
/// Note: this will change the current value of REG_SP,
/// which could invalidate memory operands
fn gen_save_sp(_jit: &JITState, asm: &mut Assembler, ctx: &mut Context) {
fn gen_save_sp(asm: &mut Assembler, ctx: &mut Context) {
if ctx.get_sp_offset() != 0 {
asm.comment("save SP to CFP");
let stack_pointer = ctx.sp_opnd(0);
Expand All @@ -262,7 +262,7 @@ fn jit_prepare_routine_call(
) {
jit.record_boundary_patch_point = true;
jit_save_pc(jit, asm);
gen_save_sp(jit, asm, ctx);
gen_save_sp(asm, ctx);

// In case the routine calls Ruby methods, it can set local variables
// through Kernel#binding and other means.
Expand Down Expand Up @@ -1874,7 +1874,6 @@ fn gen_set_ivar(
jit: &mut JITState,
ctx: &mut Context,
asm: &mut Assembler,
_recv: VALUE,
ivar_name: ID,
flags: u32,
argc: i32,
Expand Down Expand Up @@ -3877,7 +3876,6 @@ fn jit_guard_known_klass(
// Generate ancestry guard for protected callee.
// Calls to protected callees only go through when self.is_a?(klass_that_defines_the_callee).
fn jit_protected_callee_ancestry_guard(
_jit: &mut JITState,
asm: &mut Assembler,
ocb: &mut OutlinedCb,
cme: *const rb_callable_method_entry_t,
Expand Down Expand Up @@ -4614,7 +4612,6 @@ struct ControlFrame {
// * Interrupts are not checked (should be done by the caller)
fn gen_push_frame(
jit: &mut JITState,
_ctx: &mut Context,
asm: &mut Assembler,
set_sp_cfp: bool, // if true CFP and SP will be switched to the callee
frame: ControlFrame,
Expand Down Expand Up @@ -4932,7 +4929,7 @@ fn gen_send_cfunc(
frame_type |= VM_FRAME_FLAG_CFRAME_KW
}

gen_push_frame(jit, ctx, asm, false, ControlFrame {
gen_push_frame(jit, asm, false, ControlFrame {
frame_type,
specval,
cme,
Expand Down Expand Up @@ -4965,7 +4962,7 @@ fn gen_send_cfunc(

// Write interpreter SP into CFP.
// Needed in case the callee yields to the block.
gen_save_sp(jit, asm, ctx);
gen_save_sp(asm, ctx);

// Non-variadic method
let args = if cfunc_argc >= 0 {
Expand Down Expand Up @@ -5598,7 +5595,7 @@ fn gen_send_iseq(
argc = argc - 1 + array_length as i32 + remaining_opt as i32;
push_splat_args(array_length, ctx, asm, ocb, side_exit);

for _ in 0..remaining_opt as u32 {
for _ in 0..remaining_opt {
// We need to push nil for the optional arguments
let stack_ret = ctx.stack_push(Type::Unknown);
asm.mov(stack_ret, Qnil.into());
Expand Down Expand Up @@ -5794,7 +5791,7 @@ fn gen_send_iseq(

// We are going to allocate so setting pc and sp.
jit_save_pc(jit, asm);
gen_save_sp(jit, asm, ctx);
gen_save_sp(asm, ctx);

let n = (argc - required_num) as u32;
argc = required_num + 1;
Expand Down Expand Up @@ -5859,7 +5856,7 @@ fn gen_send_iseq(
};

// Setup the new frame
gen_push_frame(jit, ctx, asm, true, ControlFrame {
gen_push_frame(jit, asm, true, ControlFrame {
frame_type,
specval,
cme,
Expand Down Expand Up @@ -5952,7 +5949,6 @@ fn gen_struct_aref(
ci: *const rb_callinfo,
cme: *const rb_callable_method_entry_t,
comptime_recv: VALUE,
_comptime_recv_klass: VALUE,
flags: u32,
argc: i32,
) -> CodegenStatus {
Expand Down Expand Up @@ -6015,7 +6011,6 @@ fn gen_struct_aset(
ci: *const rb_callinfo,
cme: *const rb_callable_method_entry_t,
comptime_recv: VALUE,
_comptime_recv_klass: VALUE,
flags: u32,
argc: i32,
) -> CodegenStatus {
Expand Down Expand Up @@ -6156,7 +6151,7 @@ fn gen_send_general(
if flags & VM_CALL_FCALL == 0 {
// otherwise we need an ancestry check to ensure the receiver is valid to be called
// as protected
jit_protected_callee_ancestry_guard(jit, asm, ocb, cme, side_exit);
jit_protected_callee_ancestry_guard(asm, ocb, cme, side_exit);
}
}
_ => {
Expand Down Expand Up @@ -6265,7 +6260,7 @@ fn gen_send_general(
return CantCompile;
} else {
let ivar_name = unsafe { get_cme_def_body_attr_id(cme) };
return gen_set_ivar(jit, ctx, asm, comptime_recv, ivar_name, flags, argc);
return gen_set_ivar(jit, ctx, asm, ivar_name, flags, argc);
}
}
// Block method, e.g. define_method(:foo) { :my_block }
Expand Down Expand Up @@ -6471,7 +6466,6 @@ fn gen_send_general(
ci,
cme,
comptime_recv,
comptime_recv_klass,
flags,
argc,
);
Expand All @@ -6489,7 +6483,6 @@ fn gen_send_general(
ci,
cme,
comptime_recv,
comptime_recv_klass,
flags,
argc,
);
Expand Down
8 changes: 3 additions & 5 deletions yjit/src/core.rs
Expand Up @@ -443,11 +443,9 @@ impl Branch {

fn get_stub_count(&self) -> usize {
let mut count = 0;
for target in self.targets.iter() {
if let Some(target) = target {
if let BranchTarget::Stub(_) = target.as_ref() {
count += 1;
}
for target in self.targets.iter().flatten() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 👍

if let BranchTarget::Stub(_) = target.as_ref() {
count += 1;
}
}
count
Expand Down