projects
/
SXSI
/
xpathcomp.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
ae485b9
)
Factorize code in ResJIT.ml
author
Kim Nguyễn
<kn@lri.fr>
Wed, 14 Mar 2012 18:07:01 +0000
(19:07 +0100)
committer
Kim Nguyễn
<kn@lri.fr>
Wed, 14 Mar 2012 18:07:01 +0000
(19:07 +0100)
src/runtime.ml
patch
|
blob
|
history
diff --git
a/src/runtime.ml
b/src/runtime.ml
index
a02f7a8
..
215195d
100644
(file)
--- a/
src/runtime.ml
+++ b/
src/runtime.ml
@@
-57,34
+57,32
@@
module Make (U : ResJIT.S) : S with type result_set = U.NS.t =
| _ -> assert false
) trans (StateSet.empty, [], [])
| _ -> assert false
) trans (StateSet.empty, [], [])
-
-
module L3JIT =
struct
module L3JIT =
struct
- type opcode = (
t -> t -> t -> Tree.t -> Tree.node -> StateSet.t *
t)
+ type opcode = (
U.t -> U.t -> U.t -> Tree.t -> Tree.node -> StateSet.t * U.
t)
type t = opcode Cache.Lvl3.t
type t = opcode Cache.Lvl3.t
-
let dummy _ _ _ _ _ = failwith "Uninitialized L3JIT"
let dummy _ _ _ _ _ = failwith "Uninitialized L3JIT"
- let show_stats
a
=
+ let show_stats
(a : t)
=
let count = ref 0 in
Cache.Lvl3.iteri (fun _ _ _ _ b -> if not b then incr count) a;
eprintf "%!L3JIT: %i used entries\n%!" !count
let count = ref 0 in
Cache.Lvl3.iteri (fun _ _ _ _ b -> if not b then incr count) a;
eprintf "%!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);
v
let create () =
let v = Cache.Lvl3.create 1024 dummy in
if !Options.verbose then at_exit (fun () -> show_stats v);
v
- let find
t
tlist s1 s2 =
+ let find
(t : t)
tlist s1 s2 =
Cache.Lvl3.find t
(Uid.to_int s2.StateSet.Node.id)
(Uid.to_int s1.StateSet.Node.id)
(Uid.to_int tlist.Translist.Node.id)
Cache.Lvl3.find t
(Uid.to_int s2.StateSet.Node.id)
(Uid.to_int s1.StateSet.Node.id)
(Uid.to_int tlist.Translist.Node.id)
- let add
t
tlist s1 s2 v =
+ let add
(t : t)
tlist s1 s2 v =
Cache.Lvl3.add t
(Uid.to_int s2.StateSet.Node.id)
(Uid.to_int s1.StateSet.Node.id)
Cache.Lvl3.add t
(Uid.to_int s2.StateSet.Node.id)
(Uid.to_int s1.StateSet.Node.id)
@@
-95,7
+93,7
@@
module Make (U : ResJIT.S) : S with type result_set = U.NS.t =
let orig_s1, orig_s2 =
Translist.fold (fun t (a1, a2) ->
let _, _, _, f = Transition.node t in
let orig_s1, orig_s2 =
Translist.fold (fun t (a1, a2) ->
let _, _, _, f = Transition.node t in
- let
(_, _, fs1), (_, _, fs2)
= Formula.st f in
+ let
fs1, fs2
= Formula.st f in
(StateSet.union a1 fs1, StateSet.union a2 fs2)
) trl (StateSet.empty, StateSet.empty)
in
(StateSet.union a1 fs1, StateSet.union a2 fs2)
) trl (StateSet.empty, StateSet.empty)
in
@@
-165,8
+163,6
@@
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
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%!"
- (Uid.to_int tlist.Translist.Node.id) StateSet.print s1 StateSet.print s2);
add cache tlist s1 s2 f; f
end
add cache tlist s1 s2 f; f
end
@@
-328,9
+324,6
@@
DEFINE LOOP_TAG(t, states, tag, ctx) = loop_tag (t) (states) (ctx) (tag)
Format.eprintf "%a -> %a\n" State.print state ns_print ns;
end t
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
| ([] | [ _ ]) as l -> l
| e1 :: ((e2 :: ll) as l) -> if e1 == e2 then uniq l
let rec uniq = function
| ([] | [ _ ]) as l -> l
| e1 :: ((e2 :: ll) as l) -> if e1 == e2 then uniq l
@@
-422,7
+415,7
@@
let get_trans g auto tag states =
then acc
else
let _, _, _, phi = Transition.node trs in
then acc
else
let _, _, _, phi = Transition.node trs in
- let
(_,_,l), (_,_,r)
= Formula.st phi in
+ let
l, r
= Formula.st phi in
(StateSet.union l lstates,
StateSet.union r rstates,
Translist.cons trs tacc)
(StateSet.union l lstates,
StateSet.union r rstates,
Translist.cons trs tacc)