Move the L3JIT to the ResJIT module.
[SXSI/xpathcomp.git] / src / runtime.ml
index 215195d..5ca556b 100644 (file)
@@ -1,6 +1,7 @@
 INCLUDE "debug.ml"
 INCLUDE "trace.ml"
 INCLUDE "utils.ml"
+let l3jit_dummy _ _ _ _ _ = failwith "Uninitialized L3JIT"
 
 open Format
 open Ata
@@ -194,42 +195,33 @@ DEFINE LOOP_TAG (t, states, tag, ctx) = (
     l2jit_dispatch
       _t (tag) (states) (ctx) (L2JIT.find cache2 (tag) (states)))
 
-DEFINE LOOP(t, states, ctx) = loop (t) (states) (ctx)
-DEFINE LOOP_TAG(t, states, tag, ctx) = loop_tag (t) (states) (ctx) (tag)
-
     let top_down_run auto tree root states ctx =
       let res_len = StateSet.max_elt auto.states + 1 in
       let empty_slot = Array.create res_len U.NS.empty in
       let nil_res = auto.bottom_states, empty_slot in
-      let cache3 = L3JIT.create () in
-      let mark_subtree  =
-       fun s subtree -> if subtree != U.NS.empty then
+      let cache3 = ResJIT.create () in
+      let mark_subtree s subtree =
+       if subtree != U.NS.empty then
          let r = Array.copy empty_slot in
          r.(auto.last) <- subtree;
          s,r
        else
          s,empty_slot
       in
-      let l3jit_dispatch trl s1 s2 t sl1 sl2 =
+(*      let l3jit_dispatch trl s1 s2 t sl1 sl2 =
        let f = L3JIT.find cache3 trl s1 s2 in
-       if f == L3JIT.dummy then (L3JIT.cache_apply cache3 auto trl s1 s2) empty_slot sl1 sl2 tree t
+       if f == l3jit_dummy then
+
+         (L3JIT.cache_apply cache3 auto trl s1 s2) empty_slot sl1 sl2 tree t
        else f empty_slot sl1 sl2 tree t
 
+      in *)
+      let l3jit_dispatch trl s1 s2 t sl1 sl2 =
+       U.update cache3 auto trl s1 s2 empty_slot sl1 sl2 tree t
       in
       let cache2 = L2JIT.create () in
 
-      let rec loop t states ctx =
-       if t == Tree.nil then nil_res
-       else
-         let tag = Tree.tag tree t in
-         l2jit_dispatch
-            t tag (states) (ctx) (L2JIT.find cache2 tag (states))
-      and loop_tag t states ctx tag =
-       if t == Tree.nil then nil_res
-       else
-         l2jit_dispatch
-           t (tag) (states) (ctx) (L2JIT.find cache2 (tag) (states))
-      and l2jit_dispatch t tag states ctx opcode =
+      let rec l2jit_dispatch t tag states ctx opcode =
        match opcode with
          | L2JIT.RETURN -> nil_res
          | L2JIT.CACHE ->