Skip to content

Fix for import_methods does not allow calling another refined method#9237

Merged
headius merged 2 commits intojruby:masterfrom
evaniainbrooks:8876-import-methods-2
Feb 17, 2026
Merged

Fix for import_methods does not allow calling another refined method#9237
headius merged 2 commits intojruby:masterfrom
evaniainbrooks:8876-import-methods-2

Conversation

@evaniainbrooks
Copy link
Contributor

issue #8876

@evaniainbrooks evaniainbrooks marked this pull request as ready for review February 14, 2026 21:33
Copy link
Member

@enebo enebo left a comment

Choose a reason for hiding this comment

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

I think this is right but I am going to let @headius also review this since refinements are complicated. Two reviewers is better than one here.

@headius
Copy link
Member

headius commented Feb 16, 2026

I'm trying to untangle this a bit so I understand the change. I'd like to better understand and document the conditions where a CallBase is potentiallyRefined but does not have a RefinedCachingCallSite.

@headius
Copy link
Member

headius commented Feb 17, 2026

This fix works but only repairs the interpreter. JIT mode needs additional help to clear out already-compiled code when the scope's refinements are changed.

[] jruby $ jruby blah.rb
NoMethodError: undefined method 'indent' for an instance of String
  indent_normal at blah.rb:9
         <main> at blah.rb:19
    module_exec at org/jruby/RubyModule.java:4247
     initialize at org/jruby/RubyModule.java:3432
            new at org/jruby/RubyClass.java:1050
         <main> at blah.rb:13
[] jruby $ jruby -X-C blah.rb
"   foo"

I'm working on some additional patches on top of this PR.

@headius
Copy link
Member

headius commented Feb 17, 2026

Interpreter and JIT can be fixed by having the import clear out old compile code, as @evaniainbrooks did for fullInterpreterContext and as we can do by resetting the callCount and actualMethod in AbstractIRMethod and MixedModeIRMethod, but methods compiled eagerly at boot (CompiledIRMethod) don't have any way to recompile. In order to make them work with this we need to finally make all dynamic call sites in the JIT refinable.

I also observed that the changes in CallBase don't appear to trigger for the startup interpreter, likely because the sites passing in unrefined CallSite instances are only produced by the full interpreter. I'm going to see if I can clean up those paths so this logic can just be removed (if a call should be refined, we should not be passing in unrefined call sites and having to fix them up in the constructor).

@headius
Copy link
Member

headius commented Feb 17, 2026

I've pushed some additional changes as #9248, which fixes the JIT issue and eliminates the call site fix-up logic. The CompiledIRMethod issue will take a larger project to fix.

@headius
Copy link
Member

headius commented Feb 17, 2026

I will merge this PR and then my additional fixes. I'll open a separate issue for the CompiledIRMethod issues with changing refinement status.

Copy link
Member

@headius headius left a comment

Choose a reason for hiding this comment

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

Accepted with the caveat that additional fixes from #9248 are to be merged after.

@headius headius added this to the JRuby 10.0.4.0 milestone Feb 17, 2026
@headius headius merged commit 833904b into jruby:master Feb 17, 2026
158 checks passed
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.

3 participants

Comments