Skip to content

Commit

Permalink
Merge pull request #9921 from JuliaLang/jh/stagedfunctioncaching
Browse files Browse the repository at this point in the history
RFC: Add a cache for stagedfunctions
  • Loading branch information
timholy committed Feb 3, 2015
2 parents 7f9d6f7 + eb5882b commit 1e47b82
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions base/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -653,11 +653,19 @@ const limit_tuple_type_n = function (t::Tuple, lim::Int)
return t
end

function func_for_method(m::Method, tt, env)
if !m.isstaged
return m.func.code
let stagedcache=Dict{Any,Any}()
global func_for_method
function func_for_method(m::Method, tt, env)
if !m.isstaged
return m.func.code
elseif haskey(stagedcache,(m,tt,env))
return stagedcache[(m,tt,env)].code
else
f=ccall(:jl_instantiate_staged,Any,(Any,Any,Any),m,tt,env)
stagedcache[(m,tt,env)]=f
return f.code
end
end
(ccall(:jl_instantiate_staged,Any,(Any,Any,Any),m,tt,env)).code
end

function abstract_call_gf(f, fargs, argtypes, e)
Expand Down

0 comments on commit 1e47b82

Please sign in to comment.