append_c_digits: typeassert Int to improve inference#57950
Merged
KristofferC merged 1 commit intoJuliaLang:masterfrom Apr 1, 2025
Merged
Conversation
Should make the sysimage more resistant to method invalidation.
Member
Author
|
Eliminates all (47 on current struct I <: Integer end
function Base.:(>>)(::I, ::UInt8) end
function Base.:(>>)(::I, ::Int) endReproduce with: ./julia -E 'using SnoopCompileCore; i = (@snoop_invalidations (struct I <: Integer end; function Base.:(>>)(::I, ::UInt8) end; function Base.:(>>)(::I, ::Int) end)); using SnoopCompile; length(uinvalidated(i))'The eliminated invalidations: {
"method": ">>(::Main.RawInvalidations.I, ::Int64) @ Main.RawInvalidations ~/invalidations/script/reproducer.jl:34",
"reason": "inserting",
"mt_backedges": [
],
"backedges": [
{
"method_instance": {
"method": ">>(x::Integer, c::Int64) @ Base operators.jl:761",
"method_instance": "MethodInstance for >>(::Integer, ::Int64)"
},
"children": [
{
"method_instance": {
"method": ">>(x::Integer, c::Integer) @ Base operators.jl:752",
"method_instance": "MethodInstance for >>(::Integer, ::UInt8)"
},
"children": [
]
},
{
"method_instance": {
"method": ">>(x::Integer, c::Integer) @ Base operators.jl:752",
"method_instance": "MethodInstance for >>(::Integer, ::UInt8)"
},
"children": [
]
}
]
}
],
"mt_cache": [
],
"mt_disable": [
]
}{
"method": ">>(::Main.RawInvalidations.I, ::UInt8) @ Main.RawInvalidations ~/invalidations/script/reproducer.jl:34",
"reason": "inserting",
"mt_backedges": [
{
"type": "Tuple{typeof(>>), Any, UInt8}",
"tree": {
"method_instance": {
"method": "append_c_digits(olength::Int64, digits::Unsigned, buf, pos::Int64) @ Base intfuncs.jl:843",
"method_instance": "MethodInstance for Base.append_c_digits(::Int64, ::Unsigned, ::Memory{UInt8}, ::Int64)"
},
"children": [
{
"method_instance": {
"method": "append_c_digits_fast(olength::Int64, digits::Unsigned, buf, pos::Int64) @ Base intfuncs.jl:871",
"method_instance": "MethodInstance for Base.append_c_digits_fast(::Int64, ::Unsigned, ::Memory{UInt8}, ::Int64)"
},
"children": [
]
},
{
"method_instance": {
"method": "append_nine_digits(digits::Unsigned, buf, pos::Int64) @ Base intfuncs.jl:860",
"method_instance": "MethodInstance for Base.append_nine_digits(::Unsigned, ::Memory{UInt8}, ::Int64)"
},
"children": [
{
"method_instance": {
"method": "append_c_digits_fast(olength::Int64, digits::Unsigned, buf, pos::Int64) @ Base intfuncs.jl:871",
"method_instance": "MethodInstance for Base.append_c_digits_fast(::Int64, ::Unsigned, ::Memory{UInt8}, ::Int64)"
},
"children": [
{
"method_instance": {
"method": "dec(x::Unsigned, pad::Int64, neg::Bool) @ Base intfuncs.jl:889",
"method_instance": "MethodInstance for Base.dec(::Unsigned, ::Int64, ::Bool)"
},
"children": [
]
}
]
}
]
}
]
}
}
],
"backedges": [
{
"method_instance": {
"method": ">>(x::Integer, c::Integer) @ Base operators.jl:752",
"method_instance": "MethodInstance for >>(::Integer, ::UInt8)"
},
"children": [
{
"method_instance": {
"method": "append_c_digits(olength::Int64, digits::Unsigned, buf, pos::Int64) @ Base intfuncs.jl:843",
"method_instance": "MethodInstance for Base.append_c_digits(::Int64, ::Unsigned, ::Memory{UInt8}, ::Int64)"
},
"children": [
]
}
]
}
],
"mt_cache": [
],
"mt_disable": [
]
} |
Member
|
Why can't this be inferred? |
This was referenced Mar 31, 2025
topolarity
approved these changes
Apr 1, 2025
Member
julia> code_typed(Base.divrem, (Unsigned, typeof(0x64)))
1-element Vector{Any}:
CodeInfo(
1 ─ %1 = Base.divrem(x, y, Base.RoundToZero)::Tuple{Any, Any}
└── return %1
) => Tuple{Any, Any} |
Member
|
|
Member
Yes, a lot of inference runs with abstract types. |
KristofferC
pushed a commit
that referenced
this pull request
Apr 4, 2025
Makes the sysimage more resistant to method invalidation, when defining a new `Integer` subtype with a right bitshift method. (cherry picked from commit 69a22cf)
51 tasks
KristofferC
pushed a commit
that referenced
this pull request
Apr 4, 2025
Makes the sysimage more resistant to method invalidation, when defining a new `Integer` subtype with a right bitshift method. (cherry picked from commit 69a22cf)
KristofferC
pushed a commit
that referenced
this pull request
Jun 4, 2025
Makes the sysimage more resistant to method invalidation, when defining a new `Integer` subtype with a right bitshift method. (cherry picked from commit 69a22cf)
KristofferC
pushed a commit
that referenced
this pull request
Jun 5, 2025
Makes the sysimage more resistant to method invalidation, when defining a new `Integer` subtype with a right bitshift method. (cherry picked from commit 69a22cf)
KristofferC
pushed a commit
that referenced
this pull request
Jul 3, 2025
Makes the sysimage more resistant to method invalidation, when defining a new `Integer` subtype with a right bitshift method. (cherry picked from commit 69a22cf)
71 tasks
Merged
Merged
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.
Makes the sysimage more resistant to method invalidation, when defining a new
Integersubtype with a right bitshift method.