-
-
Notifications
You must be signed in to change notification settings - Fork 43
backport to v1: _register_kinds!: improve type stability when creating Vector
#588
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
Closed
Conversation
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
Make the temporary `existing_kinds::Vector` infer concretely. NB: a more thorough solution might do away with the construction of `existing_kinds` altogether, however this seems like an OK quick fix. (cherry picked from commit 2774125)
Member
Author
|
These sysimage invalidations in particular are at least some of those that are eliminated: Click to expand
{
"method_instance": {
"method": "(::Base.JuliaSyntax.var\"#Kind##0#Kind##1\")() @ Base.JuliaSyntax ~/tmp/jl/julia-git/playground/upstream/base/JuliaSyntax/src/kinds.jl:47",
"method_instance": "MethodInstance for (::Base.JuliaSyntax.var\"#Kind##0#Kind##1\"{<:AbstractString})()"
},
"children": [
{
"method_instance": {
"method": "get(default::Union{Function, Type}, h::Dict{K, V}, key) where {K, V} @ Base dict.jl:526",
"method_instance": "MethodInstance for get(::Base.JuliaSyntax.var\"#Kind##0#Kind##1\"{<:AbstractString}, ::Dict{String, UInt16}, ::AbstractString)"
},
"children": [
{
"method_instance": {
"method": "Base.JuliaSyntax.Kind(s::AbstractString) @ Base.JuliaSyntax ~/tmp/jl/julia-git/playground/upstream/base/JuliaSyntax/src/kinds.jl:45",
"method_instance": "MethodInstance for Base.JuliaSyntax.Kind(::AbstractString)"
},
"children": [
{
"method_instance": {
"method": "(::Base.JuliaSyntax.var\"#_register_kinds!##0#_register_kinds!##1\")(n) @ Base.JuliaSyntax none:0",
"method_instance": "MethodInstance for (::Base.JuliaSyntax.var\"#_register_kinds!##0#_register_kinds!##1\"{Dict{String, UInt16}})(::String)"
},
"children": [
{
"method_instance": {
"method": "iterate(g::Base.Generator, s...) @ Base generator.jl:43",
"method_instance": "MethodInstance for iterate(::Base.Generator{Vector{String}, Base.JuliaSyntax.var\"#_register_kinds!##0#_register_kinds!##1\"{Dict{String, UInt16}}})"
},
"children": [
{
"method_instance": {
"method": "_iterator_upper_bound(itr) @ Base array.jl:768",
"method_instance": "MethodInstance for Base._iterator_upper_bound(::Base.Generator{Vector{String}, Base.JuliaSyntax.var\"#_register_kinds!##0#_register_kinds!##1\"{Dict{String, UInt16}}})"
},
"children": [
{
"method_instance": {
"method": "collect(itr::Base.Generator) @ Base array.jl:796",
"method_instance": "MethodInstance for collect(::Base.Generator{Vector{String}, Base.JuliaSyntax.var\"#_register_kinds!##0#_register_kinds!##1\"{Dict{String, UInt16}}})"
},
"children": [
{
"method_instance": {
"method": "_register_kinds!(kind_modules, int_to_kindstr, kind_str_to_int, mod, module_id, names) @ Base.JuliaSyntax ~/tmp/jl/julia-git/playground/upstream/base/JuliaSyntax/src/kinds.jl:78",
"method_instance": "MethodInstance for Base.JuliaSyntax._register_kinds!(::Dict{Int64, Union{Module, Symbol}}, ::Dict{UInt16, String}, ::Dict{String, UInt16}, ::Module, ::Int64, ::Vector{String})"
},
"children": [
{
"method_instance": {
"method": "register_kinds!(mod, module_id, names) @ Base.JuliaSyntax ~/tmp/jl/julia-git/playground/upstream/base/JuliaSyntax/src/kinds.jl:145",
"method_instance": "MethodInstance for Base.JuliaSyntax.register_kinds!(::Module, ::Int64, ::Vector{String})"
},
"children": [
]
}
]
}
]
}
]
},
{
"method_instance": {
"method": "collect(itr::Base.Generator) @ Base array.jl:796",
"method_instance": "MethodInstance for collect(::Base.Generator{Vector{String}, Base.JuliaSyntax.var\"#_register_kinds!##0#_register_kinds!##1\"{Dict{String, UInt16}}})"
},
"children": [
]
}
]
},
{
"method_instance": {
"method": "iterate(g::Base.Generator, s...) @ Base generator.jl:43",
"method_instance": "MethodInstance for iterate(::Base.Generator{Vector{String}, Base.JuliaSyntax.var\"#_register_kinds!##0#_register_kinds!##1\"{Dict{String, UInt16}}}, ::Int64)"
},
"children": [
{
"method_instance": {
"method": "_iterator_upper_bound(itr) @ Base array.jl:768",
"method_instance": "MethodInstance for Base._iterator_upper_bound(::Base.Generator{Vector{String}, Base.JuliaSyntax.var\"#_register_kinds!##0#_register_kinds!##1\"{Dict{String, UInt16}}})"
},
"children": [
]
},
{
"method_instance": {
"method": "collect_to!(dest::AbstractArray{T}, itr, offs, st) where T @ Base array.jl:856",
"method_instance": "MethodInstance for Base.collect_to!(::Vector{Base.JuliaSyntax.Kind}, ::Base.Generator{Vector{String}, Base.JuliaSyntax.var\"#_register_kinds!##0#_register_kinds!##1\"{Dict{String, UInt16}}}, ::Int64, ::Int64)"
},
"children": [
]
},
{
"method_instance": {
"method": "collect_to!(dest::AbstractArray{T}, itr, offs, st) where T @ Base array.jl:856",
"method_instance": "MethodInstance for Base.collect_to!(::Vector{Nothing}, ::Base.Generator{Vector{String}, Base.JuliaSyntax.var\"#_register_kinds!##0#_register_kinds!##1\"{Dict{String, UInt16}}}, ::Int64, ::Int64)"
},
"children": [
]
},
{
"method_instance": {
"method": "collect_to!(dest::AbstractArray{T}, itr, offs, st) where T @ Base array.jl:856",
"method_instance": "MethodInstance for Base.collect_to!(::Vector{Union{Nothing, Base.JuliaSyntax.Kind}}, ::Base.Generator{Vector{String}, Base.JuliaSyntax.var\"#_register_kinds!##0#_register_kinds!##1\"{Dict{String, UInt16}}}, ::Int64, ::Int64)"
},
"children": [
{
"method_instance": {
"method": "collect_to!(dest::AbstractArray{T}, itr, offs, st) where T @ Base array.jl:856",
"method_instance": "MethodInstance for Base.collect_to!(::Vector{Base.JuliaSyntax.Kind}, ::Base.Generator{Vector{String}, Base.JuliaSyntax.var\"#_register_kinds!##0#_register_kinds!##1\"{Dict{String, UInt16}}}, ::Int64, ::Int64)"
},
"children": [
{
"method_instance": {
"method": "collect_to_with_first!(dest::AbstractArray, v1, itr, st) @ Base array.jl:836",
"method_instance": "MethodInstance for Base.collect_to_with_first!(::Vector{Base.JuliaSyntax.Kind}, ::Base.JuliaSyntax.Kind, ::Base.Generator{Vector{String}, Base.JuliaSyntax.var\"#_register_kinds!##0#_register_kinds!##1\"{Dict{String, UInt16}}}, ::Int64)"
},
"children": [
{
"method_instance": {
"method": "collect(itr::Base.Generator) @ Base array.jl:796",
"method_instance": "MethodInstance for collect(::Base.Generator{Vector{String}, Base.JuliaSyntax.var\"#_register_kinds!##0#_register_kinds!##1\"{Dict{String, UInt16}}})"
},
"children": [
]
}
]
}
]
},
{
"method_instance": {
"method": "collect_to!(dest::AbstractArray{T}, itr, offs, st) where T @ Base array.jl:856",
"method_instance": "MethodInstance for Base.collect_to!(::Vector{Nothing}, ::Base.Generator{Vector{String}, Base.JuliaSyntax.var\"#_register_kinds!##0#_register_kinds!##1\"{Dict{String, UInt16}}}, ::Int64, ::Int64)"
},
"children": [
{
"method_instance": {
"method": "collect_to_with_first!(dest::AbstractArray, v1, itr, st) @ Base array.jl:836",
"method_instance": "MethodInstance for Base.collect_to_with_first!(::Vector{Nothing}, ::Nothing, ::Base.Generator{Vector{String}, Base.JuliaSyntax.var\"#_register_kinds!##0#_register_kinds!##1\"{Dict{String, UInt16}}}, ::Int64)"
},
"children": [
{
"method_instance": {
"method": "collect(itr::Base.Generator) @ Base array.jl:796",
"method_instance": "MethodInstance for collect(::Base.Generator{Vector{String}, Base.JuliaSyntax.var\"#_register_kinds!##0#_register_kinds!##1\"{Dict{String, UInt16}}})"
},
"children": [
]
}
]
}
]
}
]
}
]
}
]
}
]
}
]
}
]
}Before this change, on struct S <: AbstractString end
function Base.show(::IO, ::S) end |
Member
Author
|
The PR also eliminates these invalidations: {
"method_instance": {
"method": "print_to_string(xs...) @ Base strings/io.jl:136",
"method_instance": "MethodInstance for Base.print_to_string(::String, ::Integer)"
},
"children": [
{
"method_instance": {
"method": "string(xs...) @ Base strings/io.jl:189",
"method_instance": "MethodInstance for string(::String, ::Integer)"
},
"children": [
{
"method_instance": {
"method": "Base.JuliaSyntax.Kind(x::Integer) @ Base.JuliaSyntax ~/tmp/jl/julia-git/playground/upstream/base/JuliaSyntax/src/kinds.jl:38",
"method_instance": "MethodInstance for Base.JuliaSyntax.Kind(::Integer)"
},
"children": [
{
"method_instance": {
"method": "(::Base.JuliaSyntax.var\"#_register_kinds!##0#_register_kinds!##1\")(n) @ Base.JuliaSyntax none:0",
"method_instance": "MethodInstance for (::Base.JuliaSyntax.var\"#_register_kinds!##0#_register_kinds!##1\"{Dict{String, UInt16}})(::String)"
},
"children": [
]
},
{
"method_instance": {
"method": "(::Base.JuliaSyntax.var\"#_register_kinds!##0#_register_kinds!##1\")(n) @ Base.JuliaSyntax none:0",
"method_instance": "MethodInstance for (::Base.JuliaSyntax.var\"#_register_kinds!##0#_register_kinds!##1\"{Dict{String, UInt16}})(::String)"
},
"children": [
]
}
]
}
]
}
]
}Reproducer: struct I <: Integer end
function Base.promote_rule(::Type{Bool}, ::Type{I}) endSome more: {
"method_instance": {
"method": "promote_type(::Type{T}, ::Type{S}) where {T, S} @ Base promotion.jl:315",
"method_instance": "MethodInstance for promote_type(::Type{Int64}, ::Type{<:Integer})"
},
"children": [
{
"method_instance": {
"method": "promote_typeof(x, y) @ Base promotion.jl:382",
"method_instance": "MethodInstance for Base.promote_typeof(::Int64, ::Integer)"
},
"children": [
{
"method_instance": {
"method": "|(a::Integer, b::Integer) @ Base int.jl:1016",
"method_instance": "MethodInstance for |(::Int64, ::Integer)"
},
"children": [
{
"method_instance": {
"method": "_register_kinds!(kind_modules, int_to_kindstr, kind_str_to_int, mod, module_id, names) @ Base.JuliaSyntax ~/tmp/jl/julia-git/playground/upstream/base/JuliaSyntax/src/kinds.jl:78",
"method_instance": "MethodInstance for Base.JuliaSyntax._register_kinds!(::Dict{Int64, Union{Module, Symbol}}, ::Dict{UInt16, String}, ::Dict{String, UInt16}, ::Module, ::Int64, ::Vector{String})"
},
"children": [
]
},
{
"method_instance": {
"method": "_register_kinds!(kind_modules, int_to_kindstr, kind_str_to_int, mod, module_id, names) @ Base.JuliaSyntax ~/tmp/jl/julia-git/playground/upstream/base/JuliaSyntax/src/kinds.jl:78",
"method_instance": "MethodInstance for Base.JuliaSyntax._register_kinds!(::Dict{Int64, Union{Module, Symbol}}, ::Dict{UInt16, String}, ::Dict{String, UInt16}, ::Module, ::Int64, ::Vector{String})"
},
"children": [
]
}
]
}
]
}
]
}Reproducer: struct I <: Integer end
function Base.promote_rule(::Type{Int}, ::Type{I}) end |
Member
Author
|
I suppose this is not important enough to be backported together with the other PR. |
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.
Make the temporary
existing_kinds::Vectorinfer concretely.NB: a more thorough solution might do away with the construction of
existing_kindsaltogether, however this seems like an OK quick fix.(cherry picked from commit 2774125)
xref:
the PR being backported:
_register_kinds!: improve type stability when creatingVector#587backport release PR Backports release 1 #577