Temporary commit.
[SXSI/xpathcomp.git] / src / l2JIT.ml
index 6eccae3..7a73d12 100644 (file)
@@ -1,5 +1,6 @@
 INCLUDE "debug.ml"
 INCLUDE "utils.ml"
+INCLUDE "trace.ml"
 
 open Format
 open Ata
@@ -168,8 +169,8 @@ let rec translate_jump tree tag (jkind:Ata.jump_kind) dir s =
          let labels = Ptset.Int.inter l_one t in
          let c = Ptset.Int.cardinal labels in
            if c == 0 then _nop
-           else if Ptset.Int.for_all (fun lab -> not (Ptset.Int.mem lab l_many)) labels
-           then translate_jump tree tag (JUMP_MANY(labels)) dir s
+           else if Ptset.Int.for_all (fun lab -> not (Ptset.Int.mem lab l_many)) labels then
+             translate_jump tree tag (JUMP_MANY(labels)) dir s
            else if c == 1 then tagged_one s (Ptset.Int.choose labels)
            else if c > 5 then if has_text labels then any s else any_notext s
            else select_one s labels
@@ -195,22 +196,22 @@ let rec translate_jump tree tag (jkind:Ata.jump_kind) dir s =
       | _ -> assert false
 
 let compute_jump auto tree tag states dir =
-  (*PROF_CFUN("L2JIT.compute_jump"); *)
   if !Options.no_jump then
     if dir == DIR_LEFT then FIRST_CHILD states
     else NEXT_SIBLING states
   else
     let jkind = Ata.top_down_approx auto states tree in
     let jump = translate_jump tree tag jkind dir states in
-      D_TRACE_(eprintf "Computed jumps for %s %a %s: %a\n%!"
-                (Tag.to_string tag)
-                StateSet.print states
-                (if dir == DIR_LEFT then "left" else "right")
-                print_jump jump);
-      jump
+      TRACE("level2-jit", 2,
+           __ "Computed jumps for %s %a %s: %a\n%!"
+             (Tag.to_string tag)
+             StateSet.print states
+             (if dir == DIR_LEFT then "left" else "right")
+             print_jump jump
+      );
+    jump
 
 let compile cache2 auto tree tag states =
-  (*PROF_CFUN("L2JIT.compile"); *)
   let tr_list, states1, states2 =
     StateSet.fold
       (fun q acc ->
@@ -231,9 +232,9 @@ let compile cache2 auto tree tag states =
        LEFT (tr_list,
              compute_jump auto tree tag states1 DIR_LEFT)
       else
-       BOTH (tr_list,
-             compute_jump auto tree tag states1 DIR_LEFT,
-             compute_jump auto tree tag states2 DIR_RIGHT)
+       let j1 = compute_jump auto tree tag states1 DIR_LEFT in
+       let j2 = compute_jump auto tree tag states2 DIR_RIGHT in
+       BOTH (tr_list, j1, j2);
   in
   let op = match op with
       (*BOTH(_, NOP _, NOP _) |  LEFT(_, NOP _) | RIGHT(_, NOP _) -> RETURN() *)