- pass = 0;
- fetch_trans_cache = Cache.N2.create dummy_form;
- td_cache = Cache.N6.create dummy_set;
- bu_cache = Cache.N6.create dummy_set;
- node_summaries = let ba = Array1.create int16_unsigned c_layout len in
- Array1.fill ba 0; ba
- }
-
- let get_form fetch_trans_cache auto tag q =
- let phi =
- incr fetch_trans_cache_access;
- Cache.N2.find fetch_trans_cache (tag.QName.id :> int) (q :> int)
- in
- if phi == dummy_form then
- let phi = Ata.get_form auto tag q in
- let () =
- Cache.N2.add
- fetch_trans_cache
- (tag.QName.id :> int)
- (q :> int) phi
- in phi
- else begin
- incr fetch_trans_cache_hit;
- phi
- end
-
-
- let eval_form phi fcs nss ps ss summary =
- let open Ata in
- let rec loop phi =
- begin match Formula.expr phi with
- | Boolean.False -> false
- | Boolean.True -> true
- | Boolean.Atom (a, b) ->
- begin
- let open NodeSummary in
- match a.Atom.node with
- | Move (m, q) ->
- b && StateSet.mem q (
- match m with
- `First_child -> fcs
- | `Next_sibling -> nss
- | `Parent | `Previous_sibling -> ps
- | `Stay -> ss
- )
- | Is_first_child -> b == is_left summary
- | Is_next_sibling -> b == is_right summary
- | Is k -> b == (k == kind summary)
- | Has_first_child -> b == has_left summary
- | Has_next_sibling -> b == has_right summary
- end
- | Boolean.And(phi1, phi2) -> loop phi1 && loop phi2
- | Boolean.Or (phi1, phi2) -> loop phi1 || loop phi2
- end
- in
- loop phi
-
-
- let eval_trans_aux auto fetch_trans_cache tag fcs nss ps sat todo summary =
- StateSet.fold (fun q (a_sat) ->
- let phi =
- get_form fetch_trans_cache auto tag q
- in
- if eval_form phi fcs nss ps a_sat summary then
- StateSet.add q a_sat
- else a_sat
- ) todo sat
-
-
- let rec eval_trans_fix auto fetch_trans_cache tag fcs nss ps sat todo summary =
- let new_sat =
- eval_trans_aux auto fetch_trans_cache tag fcs nss ps sat todo summary
- in
- if new_sat == sat then sat else
- eval_trans_fix auto fetch_trans_cache tag fcs nss ps new_sat todo summary
-
-
- let eval_trans auto fetch_trans_cache eval_cache tag fcs nss ps ss todo summary =
- let fcsid = (fcs.StateSet.id :> int) in
- let nssid = (nss.StateSet.id :> int) in
- let psid = (ps.StateSet.id :> int) in
- let ssid = (ss.StateSet.id :> int) in
- let tagid = (tag.QName.id :> int) in
- let res = Cache.N6.find eval_cache tagid summary ssid fcsid nssid psid in
- incr eval_trans_cache_access;
- if res != dummy_set then begin incr eval_trans_cache_hit; res end
- else let new_sat =
- eval_trans_fix auto fetch_trans_cache tag fcs nss ps ss todo summary
- in
- Cache.N6.add eval_cache tagid summary ssid fcsid nssid psid new_sat;
- new_sat
-
-
-
- let top_down run =
+ pass = 0;
+ fetch_trans_cache = Cache.N2.create dummy_form;
+ td_cache = Cache.N6.create dummy_set;
+ bu_cache = Cache.N6.create dummy_set;
+ node_summaries = ba;
+ stats = {
+ pass = 0;
+ tree_size = len;
+ fetch_trans_cache_access = 0;
+ fetch_trans_cache_miss = 0;
+ eval_trans_cache_access = 0;
+ eval_trans_cache_miss = 0;
+ nodes_per_run = [];
+ }
+ }
+
+
+ let top_down2 run update_res =
+ let num_visited = ref 0 in