Merge branch 'handle-stdout'
[SXSI/xpathcomp.git] / src / runtime.ml
index 0ba08a2..669fb4a 100644 (file)
@@ -73,10 +73,17 @@ module Make (U : ResJIT.S) : S with type result_set = U.NS.t =
         let show_stats a =
           let count = ref 0 in
           Cache.Lvl3.iteri (fun _ _ _ _ b -> if not b then incr count) a;
-          Logger.print err_formatter "@?L3JIT: %i used entries@\n@?" !count
+          Logger.start_msg err_formatter "[Debug] L3JIT used: ";
+          Logger.msg err_formatter "%i enttries" !count;
+          Logger.end_msg err_formatter "\n\n"
+
+        let _has_exit = ref false
         let create () =
           let v = Cache.Lvl3.create 1024 dummy in
-          if !Options.verbose then at_exit (fun () -> show_stats v);
+          if !Config.verbose && not !_has_exit then begin
+            _has_exit := true;
+            at_exit (fun () -> show_stats v);
+          end;
           v
 
         let find t tlist s1 s2 =
@@ -151,7 +158,7 @@ module Make (U : ResJIT.S) : S with type result_set = U.NS.t =
           let f = gen_code auto tlist s1 s2 in
           LOG(__ "top-down-run" 2 "Inserting: %i, %a, %a\n%!"
             (Uid.to_int tlist.Translist.Node.id) StateSet.print s1 StateSet.print s2);
-          if not !Options.no_cache then add cache tlist s1 s2 f;
+          if not !Config.no_cache then add cache tlist s1 s2 f;
          f
       end