8000 ZJIT: SideExit on optional args by composerinteralia · Pull Request #13633 · ruby/ruby · GitHub
[go: up one dir, main page]

Skip to content

ZJIT: SideExit on optional args #13633

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

Closed

Conversation

composerinteralia
Copy link
Contributor

We haven't implemented optional args yet, so SideExit for now. Prior to this commit def test(a=true) a would compile to:

fn test:
bb0(v0:BasicObject, v1:BasicObject):
  v3:TrueClassExact = Const Value(true)
  Return v3

But that is only correct for the case where the caller does not pass in the optional arg. We probably need a guard on the PC similar to what YJIT has.

We haven't implemented optional args yet, so `SideExit` for now.
Prior to this commit `def test(a=true) a` would compile to:

```
fn test:
bb0(v0:BasicObject, v1:BasicObject):
  v3:TrueClassExact = Const Value(true)
  Return v3
```

But that is only correct for the case where the caller does not pass in
the optional arg. We probably need a guard on the PC similar to what
YJIT has.
@matzbot matzbot requested a review from a team June 17, 2025 02:24
Copy link
Member
@XrXr XrXr left a comment

Choose a reason for hiding this comment

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

Can you amend the test to cal the method with opt param in the eval() program? I wonder what happened before your change.

@composerinteralia
Copy link
Contributor Author

Sure, I can do that. Do you mean something like:

        eval("
            def test(a=nil) = a
            test
            test(true)
        ");

I wonder what happened before your change.

It compiled, but it'd always return the default value regardless of what was passed in.

@XrXr
Copy link
Member
XrXr commented Jun 17, 2025

It compiled, but it'd always return the default value regardless of what was passed in.

Thanks. In that case, never mind about changing what's inside eval(). I think we should instead add an execution test to test_zjit.rb.

@composerinteralia
Copy link
Contributor Author
composerinteralia commented Jun 17, 2025

Writing that test made me realize that what I have here doesn't actually work correctly (I think it's saving the wrong PC while exiting). It's probably easier here to bail out entirely with a ParseError (which might might make it difficult to write a test in test_zjit). Or maybe I can try to figure out how to actually implement this instead. I'll close this PR for now since it's not right and open something else later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0