Skip to content

ZJIT: Support invalidating constant patch points #13998

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

st0012
Copy link
Member

@st0012 st0012 commented Jul 23, 2025

No description provided.

@matzbot matzbot requested a review from a team July 23, 2025 23:21
@st0012 st0012 linked an issue Jul 24, 2025 that may be closed by this pull request
Copy link
Contributor

@tekknolagi tekknolagi left a comment

Choose a reason for hiding this comment

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

Looks great -- let's wait for Alan or Kokubun

@@ -148,6 +148,7 @@ rb_clear_constant_cache_for_id(ID id)
}

rb_yjit_constant_state_changed(id);
rb_zjit_constant_state_changed(id);
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is only keyed on one ID, does that mean we will invalidate A::B::C if D::E::C changes (because they both share C)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes when C is redefined the current implementation invalidates all jumps associated with it (confirmed with debugger and print messages). But since the callback only receives one ID, I'm not sure if there's a way to reconstruct the full constant path based on it.

It looks like YJIT behaves the same way?

https://github.com/Shopify/ruby/blob/8f634e19599c97f9ecae31afd651a65ca06693a1/yjit/src/invariants.rs#L337-L343

@k0kubun is this correct?

@k0kubun
Copy link
Member

k0kubun commented Jul 24, 2025

YJIT also invalidates constants on rb_yjit_constant_ic_update. Does ZJIT need the same thing?

@tekknolagi
Copy link
Contributor

lgtm after addressing ^

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.

ZJIT: Invalidate code when constant is set
3 participants