You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/symbolic/solver.ml
+35-19Lines changed: 35 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -27,27 +27,35 @@ let check (S (solver_module, s)) pc =
27
27
letmoduleSolver = (val solver_module) in
28
28
Solver.check_set s pc
29
29
30
-
letmodel_of_partition (S (solver_module, s)) ~partition : Smtml.Model.t=
30
+
letmodel_of_path_condition (S (solver_module, s)) ~path_condition :
31
+
Smtml.Model.tOption.t=
32
+
letexception Unknown in
31
33
letmodule Solver = (val solver_module) in
32
-
let partition =
33
-
List.map
34
-
(funpc ->
35
-
matchSolver.get_sat_model s pc with
36
-
|`Modelmodel -> model
37
-
|`Unknown -> assertfalse
38
-
|`Unsat -> assertfalse )
39
-
partition
40
-
in
41
-
let model =Hashtbl.create 64in
42
-
List.iter
43
-
(funtbl -> Hashtbl.iter (funsymv -> Hashtbl.add model sym v) tbl)
44
-
partition;
45
-
model
34
+
try
35
+
let sub_conditions =Symbolic_path_condition.slice path_condition in
36
+
let models =
37
+
List.map
38
+
(funpc ->
39
+
matchSolver.get_sat_model s pc with
40
+
|`Modelmodel -> model
41
+
|`Unknown ->
42
+
(* it can happen if the solver is interrupted, otherwise it is an error, we raise, so the function can return an option that will be handled by the called *)
43
+
raise Unknown
44
+
|`Unsat ->
45
+
(* it can not happen otherwise it means we reached an unreachable branch (or added garbage to the PC and did something wrong, who knows... :-) *)
46
+
assertfalse )
47
+
sub_conditions
48
+
in
49
+
(* We build the new complete model by merging all "sub models" *)
letget_sat_model (S (solver_module, s)) ~symbol_scopes~pc=
55
+
letmodel_of_set (S (solver_module, s)) ~symbol_scopes~set=
48
56
letmoduleSolver = (val solver_module) in
49
57
let symbols =Symbol_scope.only_symbols symbol_scopes in
50
-
Solver.get_sat_model ~symbols s pc
58
+
Solver.get_sat_model ~symbols s set
51
59
52
60
let empty_stats =Smtml.Statistics.Map.empty
53
61
@@ -61,9 +69,17 @@ let interrupt_all () =
61
69
Solver.interrupt s )
62
70
solvers
63
71
64
-
letget_all_stats()=
72
+
letget_all_stats~wait_for_all_domains=
65
73
ifnot (Log.is_bench_enabled ()) then empty_stats
66
74
elsebegin
75
+
(* interrupt_all is unreliable but is a best effort to try to make sure we don't wait too long on really long requests.
76
+
The reliable alternative would be to backup the statistics before each SMT request when in benchmark mode, but this would be too costly and lead to less accurate requests than random failures... *)
77
+
interrupt_all ();
78
+
(* we wait for all domains to terminate because:
79
+
- some solvers can not be interrupted and usually don't like being asked for statistics while running
80
+
- we already got all the previous metrics, so we don't care about waiting more... *)
81
+
wait_for_all_domains ();
82
+
67
83
let solvers =Atomic.get instances in
68
84
List.fold_left
69
85
(funstats_acc (S (solver_module, s)) ->
@@ -74,7 +90,7 @@ let get_all_stats () =
74
90
Logs.warn (funm ->
75
91
m
76
92
"could not fetch the statistics of one solver because it was \
0 commit comments