Skip to content

Commit 85aba52

Browse files
committed
Make new LIFO path exploration the default
This commits adds the "lifo" strategy, which explores program paths using depth-first search. This is now the default strategy due to its favourable memory consumption compared to other strategies; tests on a few benchmarks show that its memory usage is basically constant and comparable to regular model-checking, since this strategy finishes paths as quickly as possible rather than saving them for later.
1 parent feef069 commit 85aba52

File tree

2 files changed

+64
-3
lines changed

2 files changed

+64
-3
lines changed

src/goto-symex/path_storage.cpp

+47-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,39 @@ Author: Kareem Khazem <[email protected]>
1313
#include <util/exit_codes.h>
1414
#include <util/make_unique.h>
1515

16+
// _____________________________________________________________________________
17+
// path_lifot
18+
19+
path_storaget::patht &path_lifot::private_peek()
20+
{
21+
last_peeked = paths.end();
22+
--last_peeked;
23+
return paths.back();
24+
}
25+
26+
void path_lifot::push(
27+
const path_storaget::patht &next_instruction,
28+
const path_storaget::patht &jump_target)
29+
{
30+
paths.push_back(next_instruction);
31+
paths.push_back(jump_target);
32+
}
33+
34+
void path_lifot::private_pop()
35+
{
36+
PRECONDITION(last_peeked != paths.end());
37+
paths.erase(last_peeked);
38+
last_peeked = paths.end();
39+
}
40+
41+
std::size_t path_lifot::size() const
42+
{
43+
return paths.size();
44+
}
45+
46+
// _____________________________________________________________________________
47+
// path_fifot
48+
1649
path_storaget::patht &path_fifot::private_peek()
1750
{
1851
return paths.front();
@@ -36,6 +69,9 @@ std::size_t path_fifot::size() const
3669
return paths.size();
3770
}
3871

72+
// _____________________________________________________________________________
73+
// path_strategy_choosert
74+
3975
std::string path_strategy_choosert::show_strategies() const
4076
{
4177
std::stringstream ss;
@@ -69,10 +105,19 @@ void path_strategy_choosert::set_path_strategy_options(
69105

70106
path_strategy_choosert::path_strategy_choosert()
71107
: strategies(
72-
{{"fifo",
108+
{{"lifo",
109+
{" lifo next instruction is pushed before\n"
110+
" goto target; paths are popped in\n"
111+
" last-in, first-out order. Explores\n"
112+
" the program tree depth-first.\n",
113+
[]() { // NOLINT(whitespace/braces)
114+
return util_make_unique<path_lifot>();
115+
}}},
116+
{"fifo",
73117
{" fifo next instruction is pushed before\n"
74118
" goto target; paths are popped in\n"
75-
" first-in, first-out order\n",
119+
" first-in, first-out order. Explores\n"
120+
" the program tree breadth-first.\n",
76121
[]() { // NOLINT(whitespace/braces)
77122
return util_make_unique<path_fifot>();
78123
}}}})

src/goto-symex/path_storage.h

+17-1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,22 @@ class path_storaget
8484
virtual void private_pop() = 0;
8585
};
8686

87+
/// \brief LIFO save queue: depth-first search, try to finish paths
88+
class path_lifot : public path_storaget
89+
{
90+
public:
91+
void push(const patht &, const patht &) override;
92+
std::size_t size() const override;
93+
94+
protected:
95+
std::list<path_storaget::patht>::iterator last_peeked;
96+
std::list<patht> paths;
97+
98+
private:
99+
patht &private_peek() override;
100+
void private_pop() override;
101+
};
102+
87103
/// \brief FIFO save queue: paths are resumed in the order that they were saved
88104
class path_fifot : public path_storaget
89105
{
@@ -134,7 +150,7 @@ class path_strategy_choosert
134150
protected:
135151
std::string default_strategy() const
136152
{
137-
return "fifo";
153+
return "lifo";
138154
}
139155

140156
/// Map from the name of a strategy (to be supplied on the command line), to

0 commit comments

Comments
 (0)