ZJIT: Refine singleton class invariant to only invalidate on method shadowing#950
Draft
tekknolagi wants to merge 1 commit intoShopify:ruby-upstreamfrom
Draft
Conversation
…hadowing Previously, the NoSingletonClass invariant invalidated JIT code whenever a singleton class was created for an instance of a given class. This was overly conservative—many uses of singleton classes (freeze, introspection, non-shadowing methods) don't affect method dispatch for the original class. Refine the invariant to NoSingletonClassWithShadowingMethod: only invalidate when a method is defined on a singleton class that shadows a method on the original class. The hook moves from make_singleton_class() in class.c to rb_method_entry_make() in vm_method.c, where it checks whether the newly defined method exists on the superclass chain. Correctness is always maintained by GuardType, which checks the exact class of the receiver—singleton class objects fail this check and side-exit regardless of the patchpoint.
01b413c to
8acac8b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
NoSingletonClassinvariant toNoSingletonClassWithShadowingMethod: only invalidate when a method defined on a singleton class shadows a method on the original classmake_singleton_class()in class.c torb_method_entry_make()in vm_method.c, checkingrb_method_entry(super, mid)for shadowingTest plan