Skip to content

Commit

Permalink
Merge pull request #11005 from yuyichao/invoke-tfunc-lookup
Browse files Browse the repository at this point in the history
use `jl_gf_invoke_lookup` in `invoke_tfunc` to lookup the method to be called (`invoke` improvement No. 2)
  • Loading branch information
JeffBezanson committed May 28, 2015
2 parents b4f884d + a32628a commit 6d9b50f
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions base/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -743,26 +743,18 @@ function invoke_tfunc(f, types, argtype)
if is(argtype,Bottom)
return Bottom
end
applicable = _methods(f, types, -1)
if isempty(applicable)
return Any
end
for (m::SimpleVector) in applicable
local linfo
try
linfo = func_for_method(m[3],types,m[2])
catch
try
meth = ccall(:jl_gf_invoke_lookup, Any, (Any, Any), f, types)
if is(meth, nothing)
return Any
end
if typeseq(m[1],types)
tvars = m[2][1:2:end]
(ti, env) = ccall(:jl_match_method, Any, (Any,Any,Any),
argtype, m[1], tvars)::SimpleVector
(_tree,rt) = typeinf(linfo, ti, env, linfo)
return rt
end
(ti, env) = ccall(:jl_match_method, Any, (Any, Any, Any),
argtype, meth.sig, meth.tvars)::SimpleVector
linfo = func_for_method(meth, types, env)
return typeinf(linfo, ti, env, linfo)[2]
catch
return Any
end
return Any
end

# `types` is an array of inferred types for expressions in `args`.
Expand Down

0 comments on commit 6d9b50f

Please sign in to comment.