From d65ed556d29077d2b630d5336ab1d113d66b698c Mon Sep 17 00:00:00 2001 From: Gabor Greif Date: Wed, 15 Jan 2025 11:54:00 +0100 Subject: [PATCH] WIP: use the right hook for timer-related send failure --- src/ir_passes/await.ml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/ir_passes/await.ml b/src/ir_passes/await.ml index 84a2170a8d2..c3d1f2b9e04 100644 --- a/src/ir_passes/await.ml +++ b/src/ir_passes/await.ml @@ -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 @@ -671,7 +671,7 @@ 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, @@ -679,6 +679,14 @@ and t_ignore_throw context exp = 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 })