diff --git a/hosts/ocaml/lib/sx_ref.ml b/hosts/ocaml/lib/sx_ref.ml index 9c9a2f22..f42dc9c7 100644 --- a/hosts/ocaml/lib/sx_ref.ml +++ b/hosts/ocaml/lib/sx_ref.ml @@ -382,15 +382,16 @@ and expand_macro mac raw_args env = and cek_run state = let s = ref state in (try + let n = ref 0 in while not (match cek_terminal_p !s with Bool true -> true | _ -> false) do s := cek_step !s; - let n = Atomic.fetch_and_add _step_count 1 in - if n land 4095 = 0 then begin + incr n; + if !n land 4095 = 0 then begin let lim = Atomic.get _step_limit in - if lim > 0 && n >= lim then - raise (Eval_error (Printf.sprintf "Render step limit exceeded (%d steps)" n)); - if n land 1048575 = 0 && n > 0 then - Printf.eprintf "[cek] %d steps, phase=%s control=%s\n%!" n + if lim > 0 && !n >= lim then + raise (Eval_error (Printf.sprintf "Render step limit exceeded (%d steps)" !n)); + if !n land 1048575 = 0 then + Printf.eprintf "[cek] %d steps, phase=%s control=%s\n%!" !n (match cek_phase !s with String p -> p | _ -> "?") (String.sub (Sx_runtime.value_to_str (cek_control !s)) 0 (min 80 (String.length (Sx_runtime.value_to_str (cek_control !s)))))