Skip to content

Commit c39a1ce

Browse files
committed
wip
1 parent cefe938 commit c39a1ce

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

src/stage2/interpreter.jl

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -95,24 +95,22 @@ lower_level(interp::ADInterpreter) = change_level(interp, interp.current_level -
9595
disable_forward(interp::ADInterpreter) = ADInterpreter(interp; forward=false)
9696

9797
function CC.InferenceState(result::InferenceResult, cache::Symbol, interp::ADInterpreter)
98+
ret = @invoke CC.InferenceState(result::InferenceResult, cache::Symbol, interp::AbstractInterpreter)
99+
ret === nothing && return ret
98100
if interp.current_level === missing
99-
error()
101+
# override initial bestguess
102+
ret.bestguess = CC.typeinf_type(interp.native_interpreter, result.linfo, #=allow_extended=#true)
100103
end
101-
return @invoke CC.InferenceState(result::InferenceResult, cache::Symbol, interp::AbstractInterpreter)
102-
# prepare an InferenceState object for inferring lambda
103-
world = get_world_counter(interp)
104-
src = retrieve_code_info(result.linfo, world)
105-
src === nothing && return nothing
106-
validate_code_in_debug_mode(result.linfo, src, "lowered")
107-
return InferenceState(result, src, cache, interp, Bottom)
104+
return ret
108105
end
109106

110-
111-
function CC.initial_bestguess(interp::ADInterpreter, result::InferenceResult)
107+
function CC.update_bestguess!(interp::ADInterpreter, frame::InferenceState,
108+
currstate::CC.VarTable, @nospecialize(rt))
112109
if interp.current_level === missing
113-
return CC.typeinf_lattice(interp.native_interpreter, result.linfo)
110+
# TODO
114111
end
115-
return Bottom
112+
return @invoke CC.update_bestguess!(interp::AbstractInterpreter, frame::InferenceState,
113+
currstate::CC.VarTable, rt::Any)
116114
end
117115

118116
function Cthulhu.get_optimized_codeinst(interp::ADInterpreter, curs::ADCursor)
@@ -121,7 +119,6 @@ function Cthulhu.get_optimized_codeinst(interp::ADInterpreter, curs::ADCursor)
121119
end
122120
Cthulhu.AbstractCursor(interp::ADInterpreter, mi::MethodInstance) = ADCursor(0, mi, false)
123121

124-
125122
# This is a lie, but let's clean this up later
126123
Cthulhu.can_descend(interp::ADInterpreter, @nospecialize(key), optimize::Bool) = true
127124

0 commit comments

Comments
 (0)