11open Goblint_constraint.ConstrSys
22
3-
4- let gas_default = (10 ,3 )
53(* TODO make these config options *)
64let do_local_gc = false
75let do_global_gc = false
86
7+ module type WarrowConfig = sig
8+ val delay_default : int
9+ val gas_default : int
10+ end
11+
912(* * Manage warrowing
1013
1114 Widening will be delayed 'delay' times in each phase
1215 There will be at most 'gas' narrowing phases.
1316*)
14- module Warrow (L : Lattice.S ) = struct
17+ module Warrow (L : Lattice.S ) ( Conf : WarrowConfig ) = struct
1518 (* * (value, delay, gas, narrowing_flag)
1619 Narrowing flag denotes if the last update lead
1720 to a narrowing. This is required to maintain delay/gas values.
@@ -23,11 +26,9 @@ module Warrow (L : Lattice.S) = struct
2326 last_was_narrow : bool ;
2427 }
2528
26- let default () =
27- let (delay,gas) = gas_default in { value = L. bot () ; delay; gas; last_was_narrow= false }
29+ let default () = { value = L. bot () ; delay = Conf. delay_default; gas = Conf. gas_default; last_was_narrow= false }
2830
29- let warrowc contribution new_value =
30- let (delay0, _) = gas_default in
31+ let warrow contribution new_value =
3132
3233 let narrow () =
3334 if contribution.last_was_narrow then
@@ -48,7 +49,7 @@ module Warrow (L : Lattice.S) = struct
4849 { contribution with
4950 value = L. join contribution.value new_value;
5051 last_was_narrow = false ;
51- delay = delay0
52+ delay = Conf. delay_default
5253 }
5354 else if contribution.delay < = 0 then
5455 { contribution with value = L. widen contribution.value (L. join contribution.value new_value) }
@@ -64,34 +65,22 @@ module Warrow (L : Lattice.S) = struct
6465 else if L. leq new_value current_value then narrow ()
6566 else widen ()
6667
67-
68- (* Legacy warrow with tuples instead of contribution types *)
69- (* remove once all solvers are migrated *)
70- let warrow (current , delay , gas , narrow_flag ) newval =
71- let (delay0, _) = gas_default in
72- if L. equal current newval then (current, delay, gas, narrow_flag)
73-
74- else if L. leq newval current then (
75- if narrow_flag then (L. narrow current newval, delay, gas, true )
76- else if gas < = 0 then (current, delay, gas, false )
77- else (L. narrow current newval, delay, gas - 1 , true )
78- )
79-
80- else (
81- if narrow_flag then (L. join current newval, delay0, gas, false )
82- else if delay < = 0 then (L. widen current (L. join current newval), 0 , gas, false )
83- else (L. join current newval, delay - 1 , gas, false )
84- )
8568end
8669
8770module SolverLocals (Sys : FwdGlobConstrSys )
8871 (LM : Hashtbl.S with type key=Sys.LVar.t )
8972 (GS : Set.S with type elt=Sys.GVar.t )
9073= struct
9174
75+ module WarrowConf = struct
76+ (* TODO this for locals? *)
77+ let gas_default = GobConfig. get_int " solvers.td3.narrow-globs.narrow-gas"
78+ let delay_default = GobConfig. get_int " solvers.td3.widen_gas"
79+ end
80+
9281 module System = Sys
9382 module D = Sys. D
94- module LWarrow = Warrow (D )
83+ module LWarrow = Warrow (D )( WarrowConf )
9584 module LM = LM
9685 module GS = GS
9786
@@ -141,7 +130,7 @@ module SolverLocals (Sys: FwdGlobConstrSys)
141130 ) in
142131 BatOption. default_delayed add_default (LM. find_opt data.loc_from contributor)
143132
144- let warrow = LWarrow. warrowc
133+ let warrow = LWarrow. warrow
145134
146135 type updated_contribution = Updated of t | NotUpdated of t
147136
@@ -174,10 +163,15 @@ end
174163
175164module SolverGlobals (Sys : FwdGlobConstrSys ) (LS : Set.S with type elt = Sys.LVar.t ) (LM : Hashtbl.S with type key = Sys.LVar.t ) (GM : Hashtbl.S with type key = Sys.GVar.t ) = struct
176165
166+ module WarrowConf = struct
167+ let gas_default = GobConfig. get_int " solvers.td3.narrow-globs.narrow-gas"
168+ let delay_default = GobConfig. get_int " solvers.td3.side_widen_gas"
169+ end
170+
177171 module Sys = Sys
178172
179173 module G = Sys. G
180- module GWarrow = Warrow (G )
174+ module GWarrow = Warrow (G )( WarrowConf )
181175 module LS = LS
182176 module LM = LM
183177 module GM = GM
@@ -208,7 +202,7 @@ module SolverGlobals (Sys: FwdGlobConstrSys) (LS: Set.S with type elt = Sys.LVar
208202 gas = old_contribution.gas;
209203 last_was_narrow = old_contribution.last_was_narrow
210204 } in
211- let c = GWarrow. warrowc warrow_contribution d in
205+ let c = GWarrow. warrow warrow_contribution d in
212206 {
213207 value = c.value;
214208 delay = c.delay;
@@ -218,8 +212,7 @@ module SolverGlobals (Sys: FwdGlobConstrSys) (LS: Set.S with type elt = Sys.LVar
218212 }
219213
220214 let default_contribution () =
221- let (delay,gas) = gas_default in
222- { value = G. bot () ; delay; gas; last_was_narrow= false ; set= LS. empty}
215+ { value = G. bot () ; delay = WarrowConf. delay_default; gas= WarrowConf. gas_default; last_was_narrow= false ; set= LS. empty}
223216
224217 (* * Values for globals
225218
0 commit comments