INCLUDE "debug.ml"
-INCLUDE "trace.ml"
+INCLUDE "log.ml"
INCLUDE "utils.ml"
open Format
let eval_trans auto s1 s2 trans =
- TRACE("top-down-run", 2, __ "Evaluating transition list:\n%!");
- TRACE("top-down-run", 2, __ "%a\n%!" Translist.print trans);
+ LOG(__ "top-down-run" 3 "Evaluating transition list:@\n%a" Translist.print trans);
Translist.fold
(fun t ((a_st, a_op, a_todo) as acc)->
let q, _, m, f = Transition.node t in
let show_stats a =
let count = ref 0 in
Cache.Lvl3.iteri (fun _ _ _ _ b -> if not b then incr count) a;
- eprintf "%!L3JIT: %i used entries\n%!" !count
+ Logger.print err_formatter "@?L3JIT: %i used entries@\n@?" !count
let create () =
let v = Cache.Lvl3.create 1024 dummy in
if !Options.verbose then at_exit (fun () -> show_stats v);
else sl1
else sl2
in
- eprintf "Here 1\n%!";
U.exec sl sl1 sl2 node code;
res, sl
end
else sl1
else sl2
in
- eprintf "Here 2\n%!";
U.exec sl sl1 sl2 node code;
res, sl
end
let cache_apply cache auto tlist s1 s2 =
let f = gen_code auto tlist s1 s2 in
- TRACE("grammar", 2, __ "Inserting: %i, %a, %a\n%!"
+ LOG(__ "grammar" 2 "Inserting: %i, %a, %a\n%!"
(Uid.to_int tlist.Translist.Node.id) StateSet.print s1 StateSet.print s2);
add cache tlist s1 s2 f; f
end
DEFINE LOOP (t, states, ctx) = (
let _t = t in
- TRACE("top-down-run", 3,
- __ "Entering node %i with loop (tag %s, context %i) with states %a\n%!"
- (Node.to_int _t)
- (Tag.to_string (Tree.tag tree _t))
- (Node.to_int (ctx))
- (StateSet.print) (states));
+ LOG(__ "top-down-run" 3
+ "Entering node %i with loop (tag %s, context %i) with states %a"
+ (Node.to_int _t)
+ (Tag.to_string (Tree.tag tree _t))
+ (Node.to_int (ctx))
+ (StateSet.print) (states));
if _t == Tree.nil then nil_res
else
let tag = Tree.tag tree _t in
DEFINE LOOP_TAG (t, states, tag, ctx) = (
let _t = (t) in (* to avoid duplicating expression t *)
- TRACE("top-down-run", 3,
- __ "Entering node %i with loop_tag (tag %s, context %i) with states %a\n%!"
+ LOG(__ "top-down-run" 3
+ "Entering node %i with loop_tag (tag %s, context %i) with states %a"
(Node.to_int _t)
(Tag.to_string (tag))
(Node.to_int (ctx))
match opcode with
| L2JIT.RETURN -> nil_res
| L2JIT.CACHE ->
- eprintf "New configuration\n%!";
+ LOG(__ "top-down-run" 3
+ "Top-down cache miss for configuration %s %a"
+ (Tag.to_string tag) StateSet.print states);
let opcode = L2JIT.compile cache2 auto tree tag states in
l2jit_dispatch t tag states ctx opcode
l3jit_dispatch tr_list res1 res2 t slot1 slot2
and l2jit_dispatch_instr t ctx instr =
- match instr with
+ match instr with
+ | L2JIT.NOP () -> nil_res
| L2JIT.FIRST_CHILD s -> LOOP ((Tree.first_child tree t), s, ctx)
| L2JIT.NEXT_SIBLING s -> LOOP ((Tree.next_sibling tree t), s, ctx)
(*** Bottom-up evaluation function **)
- let ns_print fmt t =
- Format.fprintf fmt "{ ";
- U.NS.iter begin fun node ->
- Format.fprintf fmt "%a " Node.print node;
- end t;
- Format.fprintf fmt "}"
-
- let slot_print fmt t =
- Array.iteri begin fun state ns ->
- Format.eprintf "%a -> %a\n" State.print state ns_print ns;
- end t
-
-
let eval_trans auto tree parent res1 res2 = assert false
let rec uniq = function
in
let lambda = ref 0 in
let rec start_loop idx states =
- TRACE("grammar", 2, __ "Node %i\n%!" (Node.to_int idx));
+ LOG(__ "grammar" 2 "Node %i\n%!" (Node.to_int idx));
if states == dummy_set then nil_res else
if idx < Node.null then nil_res
else begin
let set a i v =
- TRACE("twopass", 2, __ "Setting node %i to state %a\n%!"
+ LOG(__ "twopass" 2 "Setting node %i to state %a\n%!"
i StateSet.print v);
a.(i) <- v
auto.bottom_states
else
let tag = Tree.tag tree t in
- TRACE("twopass", 2, __ "Traversing node %i (tag %s) in states %a\n%!" (Node.to_int t) (Tag.to_string tag)
+ LOG(__ "twopass" 2 "Traversing node %i (tag %s) in states %a\n%!" (Node.to_int t) (Tag.to_string tag)
StateSet.print states
);
let trans, lstates, rstates =
c
else c
in
- TRACE("twopass", 2, __ "\nTransitions are:\n%!");
- TRACE("twopass", 2, __ "\nTransitions are:\n%a\n%!"
+ LOG(__ "twopass" 2 "\nTransitions are:\n%!");
+ LOG(__ "twopass" 2"\nTransitions are:\n%a\n%!"
Translist.print trans
);
let s1 = loop (Tree.first_child tree t) lstates ctx
(Uid.to_int trans.Translist.Node.id) c;c
else c
in
- TRACE("twopass", 2, __ "Evaluating node %i (tag %s).\n%!States=%a\n%!"
+ LOG(__ "twopass" 2 "Evaluating node %i (tag %s).\n%!States=%a\n%!"
(Node.to_int t)
(Tag.to_string tag)
StateSet.print states
);
- TRACE("twopass", 2, __ "Translist=%a\nLeft=%a\nRight=%a\nMark=%s\n\n%!"
+ LOG(__ "twopass" 2 "Translist=%a\nLeft=%a\nRight=%a\nMark=%s\n\n%!"
Translist.print trans
StateSet.print s1
StateSet.print s2
let twopass_top_down_run auto tree root =
let len = Node.to_int (Tree.closing tree root) + 1 in
- TRACE("twopass", 2, __ "Creating array of size: %i\n%!" len);
+ LOG(__ "twopass" 2 "Creating array of size: %i\n%!" len);
let states_array = Array.make len StateSet.empty in
let _, cache =
twopass_top_down states_array auto tree root auto.init Tree.nil