Don't inline generated functions if we can't invoke their generator#59018
Merged
JeffBezanson merged 8 commits intoJuliaLang:masterfrom Aug 28, 2025
Merged
Conversation
Member
That is basically correct, but they might be used for execution with --compile=all. Otherwise we can't guarantee it's possible to run all julia code without a JIT compiler available. |
JeffBezanson
approved these changes
Jul 29, 2025
Member
|
This PR looks totally reasonable but is somehow very broken! |
adienes
reviewed
Jul 30, 2025
…generator-if-cant-invoke
Member
|
Thanks @serenity4 , great to have this fixed properly |
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.
This PR disables inlining (via an outer
src_inlining_policymethod) for method instances obtained from@generatedmethods if we cannot invoke their generator during compilation, deferring their execution to runtime via dynamic dispatch.Generated functions may be called with arguments that are not fully inferrable, yet we might inline them. The lack of concretely inferred argument types can cause the generator function to not be invoked
may_invoke_generator(mi) === false, which causes its fallback definition to be executed when one is available to expand its body (theelsebranch of aif @generatedconstruct, if present). However, fallback definitions were intended to enable more accurate type inference, but not to be actually used for execution; they will typically be slower, and in this case, it is best to defer the generation of the method body to runtime, where the generator can be invoked with concrete argument types.Implements #59013 (comment), fixing #58915.