-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
inference: make Core.Compiler.return_type
respect max_methods
setting
#46810
base: master
Are you sure you want to change the base?
Conversation
9232929
to
059345f
Compare
base/compiler/tfuncs.jl
Outdated
sv.restrict_abstract_call_sites = old_restrict | ||
else | ||
call = abstract_call(interp, ArgInfo(nothing, argtypes_vec), sv, -1) | ||
call = abstract_call(interp, ArgInfo(nothing, argtypes_vec), sv) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to match the implementation of return_type
julia/base/compiler/typeinfer.jl
Line 1142 in 997e336
for match in _methods_by_ftype(t, -1, get_world_counter(interp))::Vector |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I synced the implementations of Core.Compiler.return_type
and return_type_tfunc
.
One thing I'm not satisfied with is that the current Core.Compiler.return_type
interface doesn't allow it to see caller module context, so it can't respect module-wise max_methods
setting.
059345f
to
ddcd2f0
Compare
max_methods
setting for return_type_tfunc
Core.Compiler.return_type
respect max_methods
setting
190026c
to
a48650d
Compare
a48650d
to
496192d
Compare
Since this part of refactoring is generally useful and I would like to utilize it for other PRs that may be merged before #46810.
Since this part of refactoring is generally useful and I would like to utilize it for other PRs that may be merged before #46810.
b349f09
to
9419d6c
Compare
This would help inference on `Core.Compiler.return_type(isequal, tt)` when `tt` is not well inferred (e.g. `tt` is inferred to `Tuple{Any,Any}`). (although #46810 may disable this `Core.Compiler.return_type` improvement for good reasons). Anyway, it is explicitly stated in the documentation that the `isequal` method should always return a value of `Bool`. So, not only does this annotation assist inference, it also serves to ensure the correctness of our code base, and therefore should be beneficial. We may need to take similar measures for `isless` and `isgreater` (in separate PRs).
This would help inference on `Core.Compiler.return_type(isequal, tt)` when `tt` is not well inferred (e.g. `tt` is inferred to `Tuple{Any,Any}`). (although #46810 may disable this `Core.Compiler.return_type` improvement for good reasons). Anyway, it is explicitly stated in the documentation that the `isequal` method should always return a value of `Bool`. So, not only does this annotation assist inference, it also serves to ensure the correctness of our code base, and therefore should be beneficial. We may need to take similar measures for `isless` and `isgreater` (in separate PRs).
This would help inference on `Core.Compiler.return_type(isequal, tt)` when `tt` is not well inferred (e.g. `tt` is inferred to `Tuple{Any,Any}`). (although #46810 may disable this `Core.Compiler.return_type` improvement for good reasons). Anyway, it is explicitly stated in the documentation that the `isequal` method should always return a value of `Bool`. So, not only does this annotation assist inference, it also serves to ensure the correctness of our code base, and therefore should be beneficial. We may need to take similar measures for `isless` and `isgreater` (in separate PRs).
This would help inference on `Core.Compiler.return_type(isequal, tt)` when `tt` is not well inferred (e.g. `tt` is inferred to `Tuple{Any,Any}`). (although #46810 may disable this `Core.Compiler.return_type` improvement for good reasons). Anyway, it is explicitly stated in the documentation that the `isequal` method should always return a value of `Bool`. So, not only does this annotation assist inference, it also serves to ensure the correctness of our code base, and therefore should be beneficial. We may need to take similar measures for `isless` and `isgreater` (in separate PRs).
9419d6c
to
0b975c0
Compare
…ting Previously we didn't limit the number of matching methods for `Core.Compiler.return_type`, which could lead to a potential latency problem. This commit makes `Core.Compiler.return_type` and the corresponding tfunc `return_type_tfunc` respect `max_methods` setting as like the ordinary inference. One caveat here is that the current `Core.Compiler.return_type` interface unfortunately doesn't allow it to see the caller module context, so it can't respect module-wide `max_methods` setting (I guess the change to the interface should be made as of version 2.0), that I think can lead to a potential confusion.
0b975c0
to
48955b4
Compare
I am not sure why SparseArrays tests failed so badly (looks like undef arrays being returned?), so I restarted it |
Previously we didn't limit the number of matching methods for
Core.Compiler.return_type
, which could lead to a potential latencyproblem.
This commit makes
Core.Compiler.return_type
and the correspondingtfunc
return_type_tfunc
respectmax_methods
setting as like theordinary inference.
One caveat here is that the current
Core.Compiler.return_type
interfaceunfortunately doesn't allow it to see the caller module context, so it
can't respect module-wide
max_methods
setting (I guess the change tothe interface should be made as of version 2.0), that I think can lead
to a potential confusion.