BUG added: [59c2eb816cf4] Wrong result for jumping from root
[SXSI/xpathcomp.git] / src / runtime.ml
index fa92977..46e1b01 100644 (file)
@@ -135,6 +135,7 @@ module Make (U : ResJIT.S) : S with type result_set = U.NS.t =
              end
            end else (* todo_code *) begin fun empty_slot sl1 sl2 tree node ->
              let sl = choose_slot empty_slot sl1 sl2 in
+             LOG( __ "bottom-up" 3 "Has todo code\n");
               U.exec sl sl1 sl2 node code;
               List.fold_left
                 (fun ares (p, q, code) ->
@@ -151,7 +152,8 @@ module Make (U : ResJIT.S) : S with type result_set = U.NS.t =
           let f = gen_code auto tlist s1 s2 in
           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
+          if not !Options.no_cache then add cache tlist s1 s2 f;
+         f
       end
 
 DEFINE LOOP (t, states, ctx) = (
@@ -217,7 +219,7 @@ DEFINE LOOP_TAG (t, states, tag, ctx) = (
 
       and l2jit_dispatch t tag states ctx opcode =
         match opcode with
-          | L2JIT.RETURN _ -> nil_res
+          | L2JIT.RETURN () -> nil_res
           | L2JIT.LEFT (tr_list, instr) ->
               let res1, slot1 =
                 l2jit_dispatch_instr t (Tree.closing tree t) instr
@@ -238,7 +240,7 @@ DEFINE LOOP_TAG (t, states, tag, ctx) = (
                 l2jit_dispatch_instr t ctx instr2
               in
                 l3jit_dispatch tr_list res1 res2 t slot1 slot2
-          | L2JIT.CACHE _ ->
+          | L2JIT.CACHE () ->
             LOG(__ "top-down-run" 3
                   "Top-down cache miss for configuration %s %a"
                   (Tag.to_string tag) StateSet.print states);
@@ -294,6 +296,7 @@ DEFINE LOOP_TAG (t, states, tag, ctx) = (
 
     let top_down_run auto tree root =
       Ata.init ();
+      L2JIT.init();
       let res, slot = full_top_down_run auto auto.init tree root in
       slot.(StateSet.min_elt auto.topdown_marking_states)
 
@@ -325,6 +328,8 @@ DEFINE BOTTOM_UP_NEXT(node, rest, stop) =
       let nil_res = auto.bottom_states, empty_slot in
       let cache = Cache.Lvl3.create 0 L3JIT.dummy in
       let rec move_up node res is_left rest stop =
+       LOG(__ "bottom-up" 2 "move_up: node %i is_left %b stop %i\n"
+             (Node.to_int node) is_left (Node.to_int stop));
         if node == stop then res, rest
         else
           (*let prev_sibling = Tree.prev_sibling tree node in *)
@@ -366,6 +371,12 @@ DEFINE BOTTOM_UP_NEXT(node, rest, stop) =
                   states
                   Translist.nil
               in
+             LOG( __ "bottom-up" 3 "Transition list for %s, %a, %a is %a\n"
+                    (Tag.to_string tag)
+                    StateSet.print s1
+                    StateSet.print s2
+                    Translist.print trl
+             );
               let code = L3JIT.gen_code auto trl s1 s2 in
               Cache.Lvl3.add cache id2 id1 tag code; code
             else code