@@ -7,7 +7,7 @@ using .CC: AbstractInterpreter, NativeInterpreter, InferenceParams, Optimization
77 StmtInfo, MethodCallResult, ConstCallResults, ConstPropResult, MethodTableView,
88 CachedMethodTable, InternalMethodTable, OverlayMethodTable, CallMeta, CallInfo,
99 IRCode, LazyDomtree, IRInterpretationState, set_inlineable!, block_for_inst,
10- BitSetBoundedMinPrioritySet, AbsIntState
10+ BitSetBoundedMinPrioritySet, AbsIntState, Future
1111using Base: IdSet
1212using StateSelection: DiffGraph
1313
@@ -282,13 +282,13 @@ widenincidence(@nospecialize(x)) = x
282282 if length (argtypes) == 2
283283 xarg = argtypes[2 ]
284284 if isa (xarg, Union{Incidence, Const})
285- return structural_inc_ddt (interp. var_to_diff, interp. var_kind, xarg)
285+ return Future {CallMeta} ( structural_inc_ddt (interp. var_to_diff, interp. var_kind, xarg) )
286286 end
287287 end
288288 end
289289 if interp. in_analysis && ! isa (f, Core. Builtin) && ! isa (f, Core. IntrinsicFunction)
290290 # We don't want to do new inference here
291- return CallMeta ( Any, Any, CC. Effects (), CC. NoCallInfo ())
291+ return Future { CallMeta} ( CallMeta ( Any, Any, CC. Effects (), CC. NoCallInfo () ))
292292 end
293293 ret = @invoke CC. abstract_call_known (interp:: AbstractInterpreter , f:: Any ,
294294 arginfo:: ArgInfo , si:: StmtInfo , sv:: AbsIntState , max_methods:: Int )
@@ -306,26 +306,30 @@ widenincidence(@nospecialize(x)) = x
306306 end
307307 arginfo = ArgInfo (arginfo. fargs, map (widenincidence, arginfo. argtypes))
308308 r = Diffractor. fwd_abstract_call_gf_by_type (interp, f, arginfo, si, sv, ret)
309- r != = nothing && return r
310- return ret
309+ return Future {CallMeta} (CC. isready (r) ? ret : r, interp, sv) do _, interp, sv
310+ r[] != = nothing && return r[]
311+ return ret[]
312+ end
311313end
312314
313315@override function CC. abstract_call_method (interp:: DAEInterpreter ,
314316 method:: Method , @nospecialize (sig), sparams:: SimpleVector , hardlimit:: Bool , si:: StmtInfo , sv:: InferenceState )
315- ret = @invoke CC. abstract_call_method (interp:: AbstractInterpreter ,
317+ mret = @invoke CC. abstract_call_method (interp:: AbstractInterpreter ,
316318 method:: Method , sig:: Any , sparams:: SimpleVector , hardlimit:: Bool , si:: StmtInfo , sv:: InferenceState )
317- edge = ret. edge
318- if edge != = nothing
319- cache = CC. get (CC. code_cache (interp), edge, nothing )
320- if cache != = nothing
321- src = @atomic :monotonic cache. inferred
322- if isa (src, DAECache)
323- info = src. info
324- merge_daeinfo! (interp, sv. result, info)
319+ return Future {MethodCallResult} (mret, interp, sv) do ret, interp, sv
320+ edge = ret. edge
321+ if edge != = nothing
322+ cache = CC. get (CC. code_cache (interp), edge, nothing )
323+ if cache != = nothing
324+ src = @atomic :monotonic cache. inferred
325+ if isa (src, DAECache)
326+ info = src. info
327+ merge_daeinfo! (interp, sv. result, info)
328+ end
325329 end
326330 end
331+ return ret
327332 end
328- return ret
329333end
330334
331335@override function CC. const_prop_call (interp:: DAEInterpreter ,
@@ -974,34 +978,36 @@ function _abstract_eval_invoke_inst(interp::DAEInterpreter, inst::Union{CC.Instr
974978end
975979
976980@override function CC. abstract_eval_statement_expr (interp:: DAEInterpreter , inst:: Expr , vtypes:: Nothing , irsv:: IRInterpretationState )
977- (; rt, exct, effects) = @invoke CC. abstract_eval_statement_expr (interp:: AbstractInterpreter , inst:: Expr , vtypes:: Nothing , irsv:: IRInterpretationState )
978-
979- if (! interp. ipo_analysis_mode || interp. in_analysis) && ! isa (rt, Const) && ! isa (rt, Incidence) && ! CC. isType (rt) && ! is_all_inc_or_const (Any[rt])
980- argtypes = CC. collect_argtypes (interp, inst. args, nothing , irsv)
981- if argtypes === nothing
982- return CC. RTEffects (rt, exct, effects)
983- end
984- if is_all_inc_or_const (argtypes)
985- if inst. head in (:call , :invoke ) && CC. hasintersect (widenconst (argtypes[inst. head === :call ? 1 : 2 ]), Union{typeof (variable), typeof (sim_time), typeof (state_ddt)})
986- # The `variable` and `state_ddt` intrinsics can source Incidence. For all other
987- # calls, if there's no incidence in the arguments, there cannot be any incidence
988- # in the result.
981+ ret = @invoke CC. abstract_eval_statement_expr (interp:: AbstractInterpreter , inst:: Expr , vtypes:: Nothing , irsv:: IRInterpretationState )
982+ return Future {CC.RTEffects} (ret, interp, irsv) do ret, interp, irsv
983+ (; rt, exct, effects) = ret
984+ if (! interp. ipo_analysis_mode || interp. in_analysis) && ! isa (rt, Const) && ! isa (rt, Incidence) && ! CC. isType (rt) && ! is_all_inc_or_const (Any[rt])
985+ argtypes = CC. collect_argtypes (interp, inst. args, nothing , irsv)
986+ if argtypes === nothing
989987 return CC. RTEffects (rt, exct, effects)
990988 end
991- fb_inci = _fallback_incidence (argtypes)
992- if fb_inci != = nothing
993- update_type (t:: Type ) = Incidence (t, fb_inci. row, fb_inci. eps)
994- update_type (t:: Incidence ) = t
995- update_type (t:: Const ) = t
996- update_type (t:: CC.PartialTypeVar ) = t
997- update_type (t:: PartialStruct ) = PartialStruct (t. typ, Any[Base. isvarargtype (f) ? f : update_type (f) for f in t. fields])
998- update_type (t:: CC.Conditional ) = CC. Conditional (t. slot, update_type (t. thentype), update_type (t. elsetype))
999- newrt = update_type (rt)
1000- return CC. RTEffects (newrt, exct, effects)
989+ if is_all_inc_or_const (argtypes)
990+ if inst. head in (:call , :invoke ) && CC. hasintersect (widenconst (argtypes[inst. head === :call ? 1 : 2 ]), Union{typeof (variable), typeof (sim_time), typeof (state_ddt)})
991+ # The `variable` and `state_ddt` intrinsics can source Incidence. For all other
992+ # calls, if there's no incidence in the arguments, there cannot be any incidence
993+ # in the result.
994+ return CC. RTEffects (rt, exct, effects)
995+ end
996+ fb_inci = _fallback_incidence (argtypes)
997+ if fb_inci != = nothing
998+ update_type (t:: Type ) = Incidence (t, fb_inci. row, fb_inci. eps)
999+ update_type (t:: Incidence ) = t
1000+ update_type (t:: Const ) = t
1001+ update_type (t:: CC.PartialTypeVar ) = t
1002+ update_type (t:: PartialStruct ) = PartialStruct (t. typ, Any[Base. isvarargtype (f) ? f : update_type (f) for f in t. fields])
1003+ update_type (t:: CC.Conditional ) = CC. Conditional (t. slot, update_type (t. thentype), update_type (t. elsetype))
1004+ newrt = update_type (rt)
1005+ return CC. RTEffects (newrt, exct, effects)
1006+ end
10011007 end
10021008 end
1009+ return CC. RTEffects (rt, exct, effects)
10031010 end
1004- return CC. RTEffects (rt, exct, effects)
10051011end
10061012
10071013@override function CC. compute_forwarded_argtypes (interp:: DAEInterpreter , arginfo:: ArgInfo , sv:: AbsIntState )
@@ -1222,7 +1228,7 @@ function infer_ir!(ir, interp::AbstractInterpreter, mi::MethodInstance)
12221228 min_world = world = get_inference_world (interp)
12231229 max_world = get_world_counter ()
12241230 irsv = IRInterpretationState (interp, method_info, ir, mi, ir. argtypes, world, min_world, max_world)
1225- (rt, nothrow) = CC. _ir_abstract_constant_propagation (interp, irsv)
1231+ (rt, nothrow) = CC. ir_abstract_constant_propagation (interp, irsv)
12261232 return rt
12271233end
12281234
0 commit comments