X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=src%2Fruntime.ml;h=d489a64335e93c3b4f2facb5e726315be2190bc3;hb=718a2eff89f4798ee47e055556f500dc950a82b7;hp=b4de9cf2e5ed61918f69b136064d8a82a7a68c36;hpb=ecec752325cb3d207894a4f8d772936bd7ad9f4a;p=SXSI%2Fxpathcomp.git diff --git a/src/runtime.ml b/src/runtime.ml index b4de9cf..d489a64 100644 --- a/src/runtime.ml +++ b/src/runtime.ml @@ -1,5 +1,5 @@ INCLUDE "debug.ml" -INCLUDE "trace.ml" +INCLUDE "log.ml" INCLUDE "utils.ml" open Format @@ -43,8 +43,7 @@ module Make (U : ResJIT.S) : S with type result_set = U.NS.t = 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 @@ -130,7 +129,6 @@ module Make (U : ResJIT.S) : S with type result_set = U.NS.t = else sl1 else sl2 in - eprintf "Here 1\n%!"; U.exec sl sl1 sl2 node code; res, sl end @@ -142,7 +140,6 @@ module Make (U : ResJIT.S) : S with type result_set = U.NS.t = else sl1 else sl2 in - eprintf "Here 2\n%!"; U.exec sl sl1 sl2 node code; res, sl end @@ -170,19 +167,19 @@ module Make (U : ResJIT.S) : S with type result_set = U.NS.t = 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 @@ -192,8 +189,8 @@ DEFINE LOOP (t, states, ctx) = ( 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)) @@ -228,7 +225,9 @@ DEFINE LOOP_TAG (t, states, tag, 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 @@ -254,7 +253,8 @@ DEFINE LOOP_TAG (t, states, tag, ctx) = ( 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) @@ -518,7 +518,7 @@ let dispatch_param1 conf id2 y0 y1 = 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 @@ -724,7 +724,7 @@ let dispatch_param1 conf id2 y0 y1 = 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 @@ -741,7 +741,7 @@ let dispatch_param1 conf id2 y0 y1 = 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 = @@ -752,8 +752,8 @@ let dispatch_param1 conf id2 y0 y1 = 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 @@ -815,12 +815,12 @@ let dispatch_param1 conf id2 y0 y1 = (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 @@ -837,7 +837,7 @@ let dispatch_param1 conf id2 y0 y1 = 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