Skip to content

Commit 0bf560a

Browse files
authored
NFC changes on base/compiler/inferenceresult.jl (#50589)
- specialize `va_hanlder!` - tidy up the implementation of `cache_lookup` @nanosoldier `runbenchmarks("inference", vs=":master")`
1 parent 7288095 commit 0bf560a

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

base/compiler/inferenceresult.jl

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ end
8080

8181
va_process_argtypes(𝕃::AbstractLattice, given_argtypes::Vector{Any}, mi::MethodInstance) =
8282
va_process_argtypes(Returns(nothing), 𝕃, given_argtypes, mi)
83-
function va_process_argtypes(@nospecialize(va_handler!), 𝕃::AbstractLattice, given_argtypes::Vector{Any}, mi::MethodInstance)
83+
function va_process_argtypes(@specialize(va_handler!), 𝕃::AbstractLattice, given_argtypes::Vector{Any}, mi::MethodInstance)
8484
def = mi.def
8585
isva = isa(def, Method) ? def.isva : false
8686
nargs = isa(def, Method) ? Int(def.nargs) : length(mi.specTypes.parameters)
@@ -203,31 +203,29 @@ function elim_free_typevars(@nospecialize t)
203203
end
204204
end
205205

206-
function cache_lookup(lattice::AbstractLattice, linfo::MethodInstance, given_argtypes::Vector{Any}, cache::Vector{InferenceResult})
206+
function cache_lookup(𝕃::AbstractLattice, linfo::MethodInstance, given_argtypes::Vector{Any}, cache::Vector{InferenceResult})
207207
method = linfo.def::Method
208-
nargs::Int = method.nargs
208+
nargs = Int(method.nargs)
209209
method.isva && (nargs -= 1)
210-
length(given_argtypes) >= nargs || return nothing
210+
length(given_argtypes) nargs || return nothing
211211
for cached_result in cache
212212
cached_result.linfo === linfo || continue
213-
cache_match = true
214213
cache_argtypes = cached_result.argtypes
215214
cache_overridden_by_const = cached_result.overridden_by_const
216215
for i in 1:nargs
217-
if !is_argtype_match(lattice, widenmustalias(given_argtypes[i]),
218-
cache_argtypes[i],
219-
cache_overridden_by_const[i])
220-
cache_match = false
221-
break
216+
if !is_argtype_match(𝕃, widenmustalias(given_argtypes[i]),
217+
cache_argtypes[i], cache_overridden_by_const[i])
218+
@goto next_cache
222219
end
223220
end
224-
if method.isva && cache_match
225-
cache_match = is_argtype_match(lattice, tuple_tfunc(lattice, given_argtypes[(nargs + 1):end]),
226-
cache_argtypes[end],
227-
cache_overridden_by_const[end])
221+
if method.isva
222+
if !is_argtype_match(𝕃, tuple_tfunc(𝕃, given_argtypes[(nargs + 1):end]),
223+
cache_argtypes[end], cache_overridden_by_const[end])
224+
@goto next_cache
225+
end
228226
end
229-
cache_match || continue
230227
return cached_result
228+
@label next_cache
231229
end
232230
return nothing
233231
end

0 commit comments

Comments
 (0)