Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove superflous method lookup in inlining
This code used to only do one method lookup, but in 8ca6e8d got changed to one method lookup per union split, to better match what inference does, only doing the big method lookup in the case where we want to inline a non-dispatchtuple signature. I'd like to go one step further and have inference forward all method lookup results to the optimizer. However, as a result the fallback to the big method lookup is problematic, because that same method lookup is not performed during inference. Luckily, we don't actually need it, we already know which method will get inlined, so all we need to do is to recompute the signature and type parameters, which is a simple call to type intersection. This code path isn't hit very often, but regardless of any future refactors it is also a performance improvement, since it was already doing this intersection internally, but this way gets to skip all the additional work of the method lookup. As a side node, there's an additional question of whether inference should be doing this one big method lookup or multiple. However, Jameson points out that this would currently pessimize some important cases, because of the following: ``` julia> Core.Compiler.switchtupleunion(Tuple{Union{Int,Float64},Union{Int,Float64}}) 4-element Array{Any,1}: Tuple{Float64,Float64} Tuple{Int64,Float64} Tuple{Float64,Int64} Tuple{Int64,Int64} julia> Core.Compiler.switchtupleunion(typeintersect(Tuple{Union{Int,Float64},Union{Int,Float64}}, Tuple{T,T} where T)) 1-element Array{Any,1}: Tuple{T,T} where T<:Union{Float64, Int64} ``` and potentially some other cases. Regardless, either way is fine for my planned refactor as long as the method lookups during inference match those during inlining.
- Loading branch information