Skip to content

Commit

Permalink
fix InferenceResult cache lookup verification
Browse files Browse the repository at this point in the history
  • Loading branch information
jrevels committed Apr 18, 2018
1 parent 6b883fa commit 043fe97
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions base/compiler/inferenceresult.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,17 @@ end

function cache_lookup(code::MethodInstance, argtypes::Vector{Any}, cache::Vector{InferenceResult})
method = code.def::Method
nargs::Int = method.nargs
method.isva && (nargs -= 1)
for cache_code in cache
# try to search cache first
cache_args = cache_code.args
if cache_code.linfo === code && length(cache_args) == length(argtypes)
cache_vargs = cache_code.vargs
if cache_code.linfo === code && length(argtypes) === (length(cache_vargs) + nargs)
cache_match = true
for i in 1:length(argtypes)
a = argtypes[i]
ca = cache_args[i]
ca = i <= nargs ? cache_args[i] : cache_vargs[i - nargs]
# verify that all Const argument types match between the call and cache
if (isa(a, Const) || isa(ca, Const)) && !(a === ca)
cache_match = false
Expand Down

0 comments on commit 043fe97

Please sign in to comment.