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 return type of Integer#/ with T_FIXNUM inputs #8250

Merged
merged 1 commit into from
Aug 18, 2023
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
10 changes: 10 additions & 0 deletions bootstraptest/test_yjit.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# regression test for return type of Integer#/
# It can return a T_BIGNUM when inputs are T_FIXNUM.
assert_equal 0x3fffffffffffffff.to_s, %q{
def call(fixnum_min)
(fixnum_min / -1) - 1
end

call(-(2**62))
}

# regression test for return type of String#<<
assert_equal 'Sub', %q{
def call(sub) = (sub << sub).itself
Expand Down
5 changes: 4 additions & 1 deletion yjit/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4531,6 +4531,9 @@ fn jit_rb_int_div(
}
guard_two_fixnums(jit, asm, ocb);

// rb_fix_div_fix may GC-allocate for Bignum
jit_prepare_routine_call(jit, asm);

asm.comment("Integer#/");
let obj = asm.stack_pop(1);
let recv = asm.stack_pop(1);
Expand All @@ -4541,7 +4544,7 @@ fn jit_rb_int_div(

let ret = asm.ccall(rb_fix_div_fix as *const u8, vec![recv, obj]);

let ret_opnd = asm.stack_push(Type::Fixnum);
let ret_opnd = asm.stack_push(Type::Unknown);
asm.mov(ret_opnd, ret);
true
}
Expand Down