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

improve effects of objectid and getindex(::Dict) #49447

Merged

Conversation

oscardssmith
Copy link
Member

@oscardssmith oscardssmith commented Apr 20, 2023

With these changes (and #49260) we can now tab complete through dictionaries. EDIT: It's not necessary.

The objectid improvement is needed for Dict{Symbol, T} since hash(Symbol) calls objectid.

@oscardssmith oscardssmith added performance Must go faster compiler:effects effect analysis labels Apr 20, 2023
base/dict.jl Outdated Show resolved Hide resolved
base/dict.jl Outdated Show resolved Hide resolved
base/reflection.jl Outdated Show resolved Hide resolved
Copy link
Sponsor Member

@aviatesk aviatesk left a comment

Choose a reason for hiding this comment

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

Add a test case that exercises the improved effects.

@oscardssmith
Copy link
Member Author

tests added.

function objectid(x)
# objectid is foldable iff it isn't a pointer.
# Sring, Symbol, Module, and DataType are safe because jl_objectid for them works by value.
if !ismutable(x) || x isa String || x isa Symbol || x isa Module
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

ismutable doesn't feel right.

Consider

struct F
    v::Vector
end

That's not mutable but I don't think objectid is foldable for it.

Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Module I think also gets different objectid in different sessions?

Copy link
Member Author

Choose a reason for hiding this comment

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

Module is hashed by name and parent name as of #47749. Good catch on F. I think the right test is valid type param

@staticfloat
Copy link
Sponsor Member

Build on aarch64-darwin is failing likely due to a clang version difference that is pickier now.

test/reflection.jl Outdated Show resolved Hide resolved
base/reflection.jl Outdated Show resolved Hide resolved
test/reflection.jl Outdated Show resolved Hide resolved
test/reflection.jl Outdated Show resolved Hide resolved
@aviatesk aviatesk changed the title improve effects of getindex(Dict) and objectid improve effects of objectid and getindex(::Dict) Apr 25, 2023
@aviatesk aviatesk force-pushed the improve-dict-and-objectid-effects branch from d8c0deb to a582220 Compare April 25, 2023 03:17
Copy link
Sponsor Member

@aviatesk aviatesk left a comment

Choose a reason for hiding this comment

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

Added some changes on my own. Should be ready to go if CI goes successfully.

@aviatesk aviatesk merged commit 86b819c into JuliaLang:master Apr 25, 2023
@oscardssmith oscardssmith deleted the improve-dict-and-objectid-effects branch April 25, 2023 11:52
oscardssmith added a commit that referenced this pull request Oct 4, 2023
As pointed out in #51594 (comment), this is necessary for the assertion added in #49447 to be valid.
oscardssmith added a commit that referenced this pull request Oct 5, 2023
As pointed out in
#51594 (comment),
this is necessary for the assertion added in
#49447 to be valid.

Fix #51594
KristofferC pushed a commit that referenced this pull request Oct 9, 2023
As pointed out in
#51594 (comment),
this is necessary for the assertion added in
#49447 to be valid.

Fix #51594

(cherry picked from commit c18e485)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:effects effect analysis performance Must go faster
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants