Skip to content
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

fix #44153, limit input types of reflection utilities #44155

Merged
merged 1 commit into from
Feb 13, 2022
Merged

Conversation

aviatesk
Copy link
Member

After #43113 Julia compiler can inline @nospecialize ::AbstractType
signature, so we can reintroduce the input type annotations.
Still I want to keep the current ::Any signature for those utility
functions heavily in Core.Compiler (e.g. isbitstype) because isa(t, Type)
check inserted by the inliner otherwise might involve some cost.
But I agree that the other non-performance sensitive functions like which
is better to have input type restrictions.

After #43113 Julia compiler can inline `@nospecialize ::AbstractType`
signature, so we can reintroduce the input type annotations.
Still I want to keep the current `::Any` signature for those utility
functions heavily in `Core.Compiler` (e.g. `isbitstype`) because `isa(t, Type)`
check inserted by the inliner otherwise might involve some cost.
But I agree that the other non-performance sensitive functions like `which`
is better to have input type restrictions.
Copy link
Member

@simeonschaub simeonschaub left a comment

Choose a reason for hiding this comment

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

Still I want to keep the current ::Any signature for those utility
functions heavily in Core.Compiler (e.g. isbitstype) because isa(t, Type)
check inserted by the inliner otherwise might involve some cost.

Yes, I think those should be fine, they shouldn't lead to segfaults at least.

@simeonschaub simeonschaub added bugfix This change fixes an existing bug merge me PR is reviewed. Merge when all tests are passing labels Feb 13, 2022
@simeonschaub simeonschaub added this to the 1.8 milestone Feb 13, 2022
Copy link
Member

@vtjnash vtjnash left a comment

Choose a reason for hiding this comment

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

LGTM. At some point we should try to handle the Union case too though, since that is also a type it can encounter:

julia> which(Union{Tuple{typeof(+),Int64,Int64}, Tuple{typeof(+),Int32,Int32}})
julia: /data/vtjnash/julia/src/gf.c:2775: ml_matches: Assertion `jl_is_datatype(unw)' failed.

julia> Base._methods_by_ftype(Union{Tuple{typeof(+),Int64,Int64}, Tuple{typeof(+),Int32,Int32}}, -1, Base.get_world_counter())
julia: /data/vtjnash/julia/src/gf.c:2775: ml_matches: Assertion `jl_is_datatype(unw)' failed.

@aviatesk
Copy link
Member Author

aha, so which has been such a very dangerous function after all.

@DilumAluthge DilumAluthge merged commit d7dccc5 into master Feb 13, 2022
@DilumAluthge DilumAluthge deleted the avi/43087 branch February 13, 2022 06:34
@DilumAluthge DilumAluthge removed the merge me PR is reviewed. Merge when all tests are passing label Feb 13, 2022
antoine-levitt pushed a commit to antoine-levitt/julia that referenced this pull request Feb 17, 2022
…Lang#44155)

After JuliaLang#43113 Julia compiler can inline `@nospecialize ::AbstractType`
signature, so we can reintroduce the input type annotations.
Still I want to keep the current `::Any` signature for those utility
functions heavily in `Core.Compiler` (e.g. `isbitstype`) because `isa(t, Type)`
check inserted by the inliner otherwise might involve some cost.
But I agree that the other non-performance sensitive functions like `which`
is better to have input type restrictions.
LilithHafner pushed a commit to LilithHafner/julia that referenced this pull request Feb 22, 2022
…Lang#44155)

After JuliaLang#43113 Julia compiler can inline `@nospecialize ::AbstractType`
signature, so we can reintroduce the input type annotations.
Still I want to keep the current `::Any` signature for those utility
functions heavily in `Core.Compiler` (e.g. `isbitstype`) because `isa(t, Type)`
check inserted by the inliner otherwise might involve some cost.
But I agree that the other non-performance sensitive functions like `which`
is better to have input type restrictions.
LilithHafner pushed a commit to LilithHafner/julia that referenced this pull request Mar 8, 2022
…Lang#44155)

After JuliaLang#43113 Julia compiler can inline `@nospecialize ::AbstractType`
signature, so we can reintroduce the input type annotations.
Still I want to keep the current `::Any` signature for those utility
functions heavily in `Core.Compiler` (e.g. `isbitstype`) because `isa(t, Type)`
check inserted by the inliner otherwise might involve some cost.
But I agree that the other non-performance sensitive functions like `which`
is better to have input type restrictions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This change fixes an existing bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants