Skip to content

Commit

Permalink
try immutable JETInterpreter
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk committed Jan 9, 2021
1 parent 643f1f5 commit 988dd8a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
10 changes: 5 additions & 5 deletions src/abstractinterpreterinterface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ end

const LocalCache = Dict{Vector{Any},Vector{InferenceErrorReportCache}}

struct JETInterpreter <: AbstractInterpreter
mutable struct JETInterpreter <: AbstractInterpreter
#= native =#

native::NativeInterpreter
Expand Down Expand Up @@ -44,10 +44,10 @@ struct JETInterpreter <: AbstractInterpreter
analysis_params::AnalysisParams

# keeps track of the current inference frame (needed for report cache reconstruction)
current_frame::Ref{Union{Nothing,InferenceState}}
current_frame::Union{Nothing,InferenceState}

# debugging
depth::Ref{Int}
depth::Int

function JETInterpreter(world = get_world_counter();
inf_params = gen_inf_params(),
Expand Down Expand Up @@ -77,8 +77,8 @@ struct JETInterpreter <: AbstractInterpreter
native_remarks,
concretized,
analysis_params,
Ref{Union{Nothing,InferenceState}}(nothing),
Ref(0),
nothing,
0,
)
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/jetcache.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function CC.get(wvc::WorldView{JETCache}, mi::MethodInstance, default)
global_cache = get(JET_GLOBAL_CACHE, mi, nothing)
if isa(global_cache, Vector{InferenceErrorReportCache})
interp = wvc.cache.interp
caller = interp.current_frame[]::InferenceState
caller = interp.current_frame::InferenceState
for cached in global_cache
restore_cached_report!(cached, interp, caller)
end
Expand Down
14 changes: 6 additions & 8 deletions src/typeinfer.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# in this overload we will work on some meta/debug information management
function CC.typeinf(interp::JETInterpreter, frame::InferenceState)
# # print debug info before typeinf
# depth = interp.depth[]
# depth = interp.depth
# io = stdout::IO
# color = RAIL_COLORS[(depth+1)%N_RAILS+1]
# print_rails(io, depth)
Expand All @@ -14,18 +14,16 @@ function CC.typeinf(interp::JETInterpreter, frame::InferenceState)
# print(io, ' ', file, ':', line)
# println(io)

current_frame_ref = interp.current_frame

prev_frame = current_frame_ref[]
current_frame_ref[] = frame
interp.depth[] += 1 # for debug
prev_frame = interp.current_frame
interp.current_frame = frame
interp.depth += 1 # for debug

ret = @invoke typeinf(interp::AbstractInterpreter, frame::InferenceState)

push!(ANALYZED_LINFOS, frame.linfo) # analyzed !

current_frame_ref[] = prev_frame
interp.depth[] -= 1 # for debug
interp.current_frame = prev_frame
interp.depth -= 1 # for debug

# # print debug info after typeinf
# print_rails(io, depth)
Expand Down

0 comments on commit 988dd8a

Please sign in to comment.