Skip to content

Commit

Permalink
WIP: use the right hook for timer-related send failure
Browse files Browse the repository at this point in the history
  • Loading branch information
ggreif committed Jan 15, 2025
1 parent 9793747 commit d65ed55
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/ir_passes/await.ml
Original file line number Diff line number Diff line change
Expand Up @@ -653,14 +653,14 @@ and t_comp_unit context = function
preupgrade = t_exp LabelEnv.empty preupgrade;
postupgrade = t_exp LabelEnv.empty postupgrade;
heartbeat = t_ignore_throw LabelEnv.empty heartbeat;
timer = t_ignore_throw LabelEnv.empty timer;
timer = t_timer_throw LabelEnv.empty timer;
inspect = t_exp LabelEnv.empty inspect;
stable_record = t_exp LabelEnv.empty stable_record;
stable_type;
},
t)

and t_ignore_throw context exp =
and t_on_throw context exp t_exp =
match exp.it with
| Ir.PrimE (Ir.TupPrim, []) ->
exp
Expand All @@ -671,14 +671,22 @@ and t_ignore_throw context exp =
(LabelEnv.add Throw (Cont throw) context) in
let e = fresh_var "e" T.catch in
{ (blockE [
funcD throw e (tupE[]);
funcD throw e t_exp;
]
(c_exp context' exp (meta (T.unit) (fun v1 -> tupE []))))
(* timer logic requires us to preserve any source location,
or timer won't be initialized in compile.ml *)
with at = exp.at
}

and t_ignore_throw context exp = t_on_throw context exp (tupE[])

and t_timer_throw context exp =
let check_timer_send_type = T.(Func (Local, Returns, [], [], [])) in
t_on_throw context exp
(callE
(varE (var "@check_timer_send" check_timer_send_type)) []
(unitE()))

and t_prog (prog, flavor) =
(t_comp_unit LabelEnv.empty prog, { flavor with has_await = false })
Expand Down

0 comments on commit d65ed55

Please sign in to comment.