Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: Add a cache for stagedfunctions #9921

Merged
merged 1 commit into from
Feb 3, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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