@@ -14,12 +14,13 @@ module FwdBuSolver (System: FwdGlobConstrSys) = struct
1414 module GM = Hashtbl. Make (System. GVar )
1515 module LM = Hashtbl. Make (System. LVar )
1616
17+ (*
1718 module OM = LM
1819 let source x = x
19- (*
20+ *)
21+
2022 module OM = Hashtbl. Make (Node )
2123 let source = System.LVar. node
22- *)
2324 let gas_default = ref (10 ,3 )
2425
2526 let lwarrow (a ,delay ,gas ,narrow ) b =
@@ -66,7 +67,8 @@ module FwdBuSolver (System: FwdGlobConstrSys) = struct
6667 let _ = work := (xs,s) in
6768 Some x
6869
69- type glob = {value : G .t ; init : G .t ; infl : LS .t ; from : (G .t * int * int * bool ) OM .t }
70+ type glob = {value : G .t ; init : G .t ; infl : LS .t ; last : G .t LM .t ;
71+ from : (G .t * int * int * bool * LS .t ) OM .t }
7072
7173 let glob: glob GM. t = GM. create 100
7274
@@ -77,7 +79,7 @@ module FwdBuSolver (System: FwdGlobConstrSys) = struct
7779 with _ ->
7880 (
7981 if tracing then trace " unknownsize" " Number of globals so far: %d" (GM. length glob);
80- let rglob = {value = G. bot () ; init = G. bot () ; infl = LS. empty; from = OM. create 10 } in
82+ let rglob = {value = G. bot () ; init = G. bot () ; infl = LS. empty; last = LM. create 10 ; from = OM. create 10 } in
8183 GM. add glob g rglob;
8284 rglob
8385 )
@@ -87,17 +89,23 @@ module FwdBuSolver (System: FwdGlobConstrSys) = struct
8789 value = d;
8890 init = d;
8991 infl = LS. empty;
92+ last = LM. create 10 ;
9093 from = OM. create 10
9194 }
9295
93- let get_global_value init from = OM. fold (fun _ (b ,_ ,_ ,_ ) a -> G. join a b) from init
96+ let get_global_value init from = OM. fold (fun _ (b ,_ ,_ ,_ , _ ) a -> G. join a b) from init
9497
95- let get_old_global_value x from =
96- try OM. find from x
98+ let get_old_global_value orig from =
99+ try OM. find from orig
97100 with _ ->
98101 let (delay,gas) = ! gas_default in
99- OM. add from x (G. bot () ,delay,gas,false );
100- (G. bot () ,delay,gas,false )
102+ OM. add from orig (G. bot () ,delay,gas,false ,LS. empty);
103+ (G. bot () ,delay,gas,false ,LS. empty)
104+
105+ let get_last_contrib orig set last =
106+ LS. fold (fun x d -> G. join d (LM. find last x)) set (G. bot() )
107+
108+ (* determine the join of all last contribs of unknowns with same orig *)
101109
102110 (* now the getters for globals *)
103111
@@ -161,22 +169,26 @@ module FwdBuSolver (System: FwdGlobConstrSys) = struct
161169*)
162170 in
163171 (* if tracing then trace "set_global" "set_global: \n From: %a \nOn:%a \n Value: %a" System.LVar.pretty_trace x System.GVar.pretty_trace g G.pretty d; *)
164- let {value;init;infl;from} = get_global_ref g in
165- let (old_xg,delay,gas,narrow) = get_old_global_value sx from in
166- let (new_xg,delay,gas,narrow) = gwarrow (old_xg,delay,gas,narrow) d in
172+ let {value;init;infl;last;from} = get_global_ref g in
173+ let (old_xg,delay,gas,narrow,set) = get_old_global_value sx from in
174+ let () = LM. add last x d in
175+ let set = LS. add x set in
176+ let d_new = get_last_contrib sx set last in
177+ let (new_xg,delay,gas,narrow) = gwarrow (old_xg,delay,gas,narrow) d_new in
178+ let () = OM. replace from sx (new_xg,delay,gas,narrow,set) in
167179 if G. equal new_xg old_xg then (
168- if tracing then trace " set_globalc" " no change!"
180+ if tracing then trace " set_globalc" " no change!" ;
169181 )
170182 else
171183 begin
172184 if tracing then trace " set_globalc" " new contribution registered!" ;
173- let _ = OM. replace from sx (new_xg,delay,gas,narrow) in
174185 let new_g = get_global_value init from in
175186 if G. equal value new_g then
176187 ()
177188 else
189+ let () = GM. replace glob g {value = new_g; init = init; infl = LS. empty;last;from} in
178190 let work = infl in
179- let _ = GM. replace glob g {value = new_g; init = init; infl = LS. empty; from} in
191+ let _ = GM. replace glob g {value = new_g; init = init; infl = LS. empty; last; from} in
180192 let doit x =
181193 let r = get_local_ref x in
182194 if ! (r.called) then r.aborted := true
0 commit comments