Skip to content

ZJIT: Support invalidating on method redefinition #13875

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

Merged

Conversation

st0012
Copy link
Member

@st0012 st0012 commented Jul 14, 2025

This commit adds support for the MethodRedefined invariant to be invalidated when a method is redefined.

Changes:

  • Added CME pointer to the MethodRedefined invariant in HIR
  • Updated all places where MethodRedefined invariants are created to include the CME pointer
  • Added handling for MethodRedefined invariants in gen_patch_point to call track_cme_assumption, which registers the patch point for invalidation when rb_zjit_cme_invalidate is called

This ensures that when a method is redefined, all JIT code that depends on that method will be properly invalidated.

@matzbot matzbot requested a review from a team July 14, 2025 11:21
@st0012 st0012 marked this pull request as draft July 14, 2025 13:05
@st0012
Copy link
Member Author

st0012 commented Jul 14, 2025

I'm investigating the segfault on ubuntu atm.

@tekknolagi tekknolagi linked an issue Jul 14, 2025 that may be closed by this pull request

This comment has been minimized.

@st0012 st0012 force-pushed the zjit-support-invalidating-method-redefinition branch from 723380b to 2b9fdc5 Compare July 16, 2025 15:30
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.

Very nice

@st0012 st0012 force-pushed the zjit-support-invalidating-method-redefinition branch 7 times, most recently from e2658e6 to e84548d Compare July 17, 2025 19:28
@tekknolagi
Copy link
Contributor

Try another rebase?

@st0012 st0012 force-pushed the zjit-support-invalidating-method-redefinition branch from e84548d to 0afb145 Compare July 18, 2025 14:36
This commit adds support for the MethodRedefined invariant to be invalidated
when a method is redefined.

Changes:
- Added CME pointer to the MethodRedefined invariant in HIR
- Updated all places where MethodRedefined invariants are created to
    include the CME pointer
- Added handling for MethodRedefined invariants in gen_patch_point to
    call track_cme_assumption, which registers the patch point for
    invalidation when rb_zjit_cme_invalidate is called

This ensures that when a method is redefined, all JIT code that
depends on that method will be properly invalidated.
@st0012 st0012 force-pushed the zjit-support-invalidating-method-redefinition branch from 0afb145 to ad85148 Compare July 18, 2025 14:57
@st0012 st0012 marked this pull request as ready for review July 18, 2025 15:15
@st0012 st0012 requested a review from tekknolagi July 18, 2025 15:15
@matzbot matzbot requested a review from a team July 18, 2025 15:15
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.

Nice, lgtm

@tekknolagi tekknolagi changed the title ZJIT: Support invalidating method redefinition ZJIT: Support invalidating on method redefinition Jul 18, 2025
@tekknolagi tekknolagi enabled auto-merge (squash) July 18, 2025 15:26
@tekknolagi tekknolagi merged commit 8df61bf into ruby:master Jul 18, 2025
85 checks passed
@tekknolagi tekknolagi deleted the zjit-support-invalidating-method-redefinition branch July 18, 2025 15:36
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 method is redefined
2 participants