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: Save PC and SP before calling leaf builtins #7090

Merged
merged 1 commit into from Jan 10, 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
16 changes: 16 additions & 0 deletions test/ruby/test_yjit.rb
Expand Up @@ -1042,6 +1042,22 @@ def foo
RUBY
end

def test_bug_19316
n = 2 ** 64
# foo's extra param and the splats are relevant
assert_compiles(<<~'RUBY', result: [[n, -n], [n, -n]])
def foo(_, a, b, c)
[a & b, ~c]
end

n = 2 ** 64
args = [0, -n, n, n-1]

GC.stress = true
[foo(*args), foo(*args)]
RUBY
end

private

def code_gc_helpers
Expand Down
4 changes: 4 additions & 0 deletions yjit/src/codegen.rs
Expand Up @@ -5181,6 +5181,10 @@ fn gen_send_iseq(
if builtin_argc + 1 < (C_ARG_OPNDS.len() as i32) {
asm.comment("inlined leaf builtin");

// Save the PC and SP because the callee may allocate
// e.g. Integer#abs on a bignum
jit_prepare_routine_call(jit, ctx, asm);

// Call the builtin func (ec, recv, arg1, arg2, ...)
let mut args = vec![EC];

Expand Down