Skip to content

Commit e8e2d97

Browse files
authored
Merge pull request #3446 from romainbrenguier/refactor/switch-to-thread
Make switch_to_thread static
2 parents d7645fd + 9cff682 commit e8e2d97

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed

src/goto-symex/goto_symex_state.cpp

-16
Original file line numberDiff line numberDiff line change
@@ -777,19 +777,3 @@ void goto_symex_statet::get_l1_name(exprt &expr) const
777777
Forall_operands(it, expr)
778778
get_l1_name(*it);
779779
}
780-
781-
void goto_symex_statet::switch_to_thread(unsigned t)
782-
{
783-
PRECONDITION(source.thread_nr < threads.size());
784-
PRECONDITION(t < threads.size());
785-
786-
// save PC
787-
threads[source.thread_nr].pc=source.pc;
788-
threads[source.thread_nr].atomic_section_id=atomic_section_id;
789-
790-
// get new PC
791-
source.thread_nr=t;
792-
source.pc=threads[t].pc;
793-
794-
guard=threads[t].guard;
795-
}

src/goto-symex/goto_symex_state.h

-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,6 @@ class goto_symex_statet final
283283
void populate_dirty_for_function(
284284
const irep_idt &id, const goto_functiont &);
285285

286-
void switch_to_thread(unsigned t);
287286
bool record_events;
288287
incremental_dirtyt dirty;
289288

src/goto-symex/symex_main.cpp

+19-1
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,24 @@ void goto_symext::initialize_entry_point(
154154
symex_transition(state, state.source.pc, false);
155155
}
156156

157+
static void
158+
switch_to_thread(goto_symex_statet &state, const unsigned int thread_nb)
159+
{
160+
PRECONDITION(state.source.thread_nr < state.threads.size());
161+
PRECONDITION(thread_nb < state.threads.size());
162+
163+
// save PC
164+
state.threads[state.source.thread_nr].pc = state.source.pc;
165+
state.threads[state.source.thread_nr].atomic_section_id =
166+
state.atomic_section_id;
167+
168+
// get new PC
169+
state.source.thread_nr = thread_nb;
170+
state.source.pc = state.threads[thread_nb].pc;
171+
172+
state.guard = state.threads[thread_nb].guard;
173+
}
174+
157175
void goto_symext::symex_threaded_step(
158176
statet &state, const get_goto_functiont &get_goto_function)
159177
{
@@ -173,7 +191,7 @@ void goto_symext::symex_threaded_step(
173191
#if 0
174192
std::cout << "********* Now executing thread " << t << '\n';
175193
#endif
176-
state.switch_to_thread(t);
194+
switch_to_thread(state, t);
177195
symex_transition(state, state.source.pc, false);
178196
}
179197
}

0 commit comments

Comments
 (0)