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

Spill fewer temps on iv writes #9974

Merged
merged 4 commits into from
Feb 16, 2024
Merged
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
8 changes: 4 additions & 4 deletions yjit/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2750,7 +2750,6 @@ fn gen_setinstancevariable(
Opnd::const_ptr(ic as *const u8),
]
);
asm.stack_pop(1); // Keep it on stack during ccall for GC
} else {
// Get the receiver
let mut recv = asm.load(Opnd::mem(64, CFP, RUBY_OFFSET_CFP_SELF));
Expand All @@ -2775,7 +2774,6 @@ fn gen_setinstancevariable(
Counter::setivar_megamorphic,
);

asm.spill_temps(); // for ccall (must be done before write_val is popped)
let write_val;

match ivar_index {
Expand Down Expand Up @@ -2803,7 +2801,7 @@ fn gen_setinstancevariable(
recv = asm.load(Opnd::mem(64, CFP, RUBY_OFFSET_CFP_SELF))
}

write_val = asm.stack_pop(1);
write_val = asm.stack_opnd(0);
gen_write_iv(asm, comptime_receiver, recv, ivar_index, write_val, needs_extension.is_some());

asm_comment!(asm, "write shape");
Expand All @@ -2821,14 +2819,15 @@ fn gen_setinstancevariable(
// the iv index by searching up the shape tree. If we've
// made the transition already, then there's no reason to
// update the shape on the object. Just set the IV.
write_val = asm.stack_pop(1);
write_val = asm.stack_opnd(0);
gen_write_iv(asm, comptime_receiver, recv, ivar_index, write_val, false);
},
}

// If we know the stack value is an immediate, there's no need to
// generate WB code.
if !stack_type.is_imm() {
asm.spill_temps(); // for ccall (unconditionally spill them for RegTemps consistency)
let skip_wb = asm.new_label("skip_wb");
// If the value we're writing is an immediate, we don't need to WB
asm.test(write_val, (RUBY_IMMEDIATE_MASK as u64).into());
Expand All @@ -2850,6 +2849,7 @@ fn gen_setinstancevariable(
asm.write_label(skip_wb);
}
}
asm.stack_pop(1); // Keep it on stack during ccall for GC

Some(KeepCompiling)
}
Expand Down