Skip to content

Commit

Permalink
Add a cache for stagedfunctions
Browse files Browse the repository at this point in the history
  • Loading branch information
Jutho committed Jan 25, 2015
1 parent 1eca232 commit eb5882b
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 @@ -618,11 +618,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 eb5882b

Please sign in to comment.