Skip to content

Commit

Permalink
YJIT: Rename helper function and correct counter name
Browse files Browse the repository at this point in the history
Counter::guard_send_iseq_has_rest_and_splat_not_equal was using
jump-if-lesser-than, so wasn't checking for equality. Rename function
because moving is destructive in Rust, which is confusing for this function
which doesn't modify the array.
  • Loading branch information
XrXr committed Dec 12, 2023
1 parent 9765ada commit 4755309
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions yjit/src/codegen.rs
Expand Up @@ -5720,15 +5720,15 @@ fn get_array_ptr(asm: &mut Assembler, array_reg: Opnd) -> Opnd {
}

/// Pushes arguments from an array to the stack. Differs from push splat because
/// the array can have items left over.
fn move_rest_args_to_stack(array: Opnd, num_args: u32, asm: &mut Assembler) {
asm_comment!(asm, "move_rest_args_to_stack");
/// the array can have items left over. Array is assumed to be T_ARRAY without guards.
fn copy_splat_args_for_rest_callee(array: Opnd, num_args: u32, asm: &mut Assembler) {
asm_comment!(asm, "copy_splat_args_for_rest_callee");

let array_len_opnd = get_array_len(asm, array);

asm_comment!(asm, "Side exit if length is less than required");
asm_comment!(asm, "guard splat array large enough");
asm.cmp(array_len_opnd, num_args.into());
asm.jl(Target::side_exit(Counter::guard_send_iseq_has_rest_and_splat_not_equal));
asm.jl(Target::side_exit(Counter::guard_send_iseq_has_rest_and_splat_too_few));

// Unused operands cause the backend to panic
if num_args == 0 {
Expand Down Expand Up @@ -6364,8 +6364,8 @@ fn gen_send_iseq(
let diff: u32 = (required_num - non_rest_arg_count + opts_filled)
.try_into().unwrap();

// This moves the arguments onto the stack. But it doesn't modify the array.
move_rest_args_to_stack(array, diff, asm);
// Copy required arguments to the stack without modifying the array
copy_splat_args_for_rest_callee(array, diff, asm);

// We will now slice the array to give us a new array of the correct size
let sliced = asm.ccall(rb_yjit_rb_ary_subseq_length as *const u8, vec![array, Opnd::UImm(diff as u64)]);
Expand Down
2 changes: 1 addition & 1 deletion yjit/src/stats.rs
Expand Up @@ -404,7 +404,7 @@ make_counters! {
guard_send_send_chain,
guard_send_send_chain_not_string,
guard_send_send_chain_not_sym,
guard_send_iseq_has_rest_and_splat_not_equal,
guard_send_iseq_has_rest_and_splat_too_few,
guard_send_is_a_class_mismatch,
guard_send_instance_of_class_mismatch,
guard_send_interrupted,
Expand Down

0 comments on commit 4755309

Please sign in to comment.