thrd_last_action(new std::vector<ModelAction *>(1)),
node_stack(new NodeStack()),
next_backtrack(NULL),
- cyclegraph(new CycleGraph()),
+ mo_graph(new CycleGraph()),
failed_promise(false)
{
}
delete obj_thrd_map;
delete obj_map;
delete action_trace;
+
+ for (unsigned int i = 0; i < promises->size(); i++)
+ delete (*promises)[i];
+ delete promises;
+
delete thrd_last_action;
delete node_stack;
delete scheduler;
- delete cyclegraph;
+ delete mo_graph;
}
/**
return NULL;
}
/* linear search: from most recent to oldest */
- action_list_t *list = obj_map->ensureptr(act->get_location());
+ action_list_t *list = obj_map->get_safe_ptr(act->get_location());
action_list_t::reverse_iterator rit;
for (rit = list->rbegin(); rit != list->rend(); rit++) {
ModelAction *prev = *rit;
/** @returns whether the current partial trace is feasible. */
bool ModelChecker::isfeasible() {
- return !cyclegraph->checkForCycles() && !failed_promise;
+ return !mo_graph->checkForCycles() && !failed_promise;
}
/** Returns whether the current completed trace is feasible. */
ModelAction *lastread = get_last_action(tid);
lastread->process_rmw(act);
if (act->is_rmw())
- cyclegraph->addRMWEdge(lastread, lastread->get_reads_from());
+ mo_graph->addRMWEdge(lastread->get_reads_from(), lastread);
return lastread;
}
/**
- * Updates the cyclegraph with the constraints imposed from the current read.
+ * Updates the mo_graph with the constraints imposed from the current read.
* @param curr The current action. Must be a read.
* @param rf The action that curr reads from. Must be a write.
*/
void ModelChecker::r_modification_order(ModelAction * curr, const ModelAction *rf) {
- std::vector<action_list_t> *thrd_lists = obj_thrd_map->ensureptr(curr->get_location());
+ std::vector<action_list_t> *thrd_lists = obj_thrd_map->get_safe_ptr(curr->get_location());
unsigned int i;
ASSERT(curr->is_read());
if (act->is_read()) {
const ModelAction * prevreadfrom = act->get_reads_from();
if (prevreadfrom != NULL && rf != prevreadfrom)
- cyclegraph->addEdge(rf, prevreadfrom);
+ mo_graph->addEdge(prevreadfrom, rf);
} else if (rf != act) {
- cyclegraph->addEdge(rf, act);
+ mo_graph->addEdge(act, rf);
}
break;
}
}
}
-/** Updates the cyclegraph with the constraints imposed from the
- * current read. */
+/** Updates the mo_graph with the constraints imposed from the current read. */
void ModelChecker::post_r_modification_order(ModelAction * curr, const ModelAction *rf) {
- std::vector<action_list_t> *thrd_lists = obj_thrd_map->ensureptr(curr->get_location());
+ std::vector<action_list_t> *thrd_lists = obj_thrd_map->get_safe_ptr(curr->get_location());
unsigned int i;
ASSERT(curr->is_read());
if (lastact->is_read()) {
const ModelAction * postreadfrom = lastact->get_reads_from();
if (postreadfrom != NULL&&rf != postreadfrom)
- cyclegraph->addEdge(postreadfrom, rf);
+ mo_graph->addEdge(rf, postreadfrom);
} else if (rf != lastact) {
- cyclegraph->addEdge(lastact, rf);
+ mo_graph->addEdge(rf, lastact);
}
break;
}
}
/**
- * Updates the cyclegraph with the constraints imposed from the current write.
+ * Updates the mo_graph with the constraints imposed from the current write.
* @param curr The current action. Must be a write.
*/
void ModelChecker::w_modification_order(ModelAction * curr) {
- std::vector<action_list_t> *thrd_lists = obj_thrd_map->ensureptr(curr->get_location());
+ std::vector<action_list_t> *thrd_lists = obj_thrd_map->get_safe_ptr(curr->get_location());
unsigned int i;
ASSERT(curr->is_write());
so we are initialized. */
ModelAction * last_seq_cst = get_last_seq_cst(curr->get_location());
if (last_seq_cst != NULL)
- cyclegraph->addEdge(curr, last_seq_cst);
+ mo_graph->addEdge(last_seq_cst, curr);
}
/* Iterate over all threads */
/* Include at most one act per-thread that "happens before" curr */
if (act->happens_before(curr)) {
if (act->is_read())
- cyclegraph->addEdge(curr, act->get_reads_from());
+ mo_graph->addEdge(act->get_reads_from(), curr);
else
- cyclegraph->addEdge(curr, act);
+ mo_graph->addEdge(act, curr);
break;
} else if (act->is_read() && !act->is_synchronizing(curr) &&
!act->same_thread(curr)) {
int tid = id_to_int(act->get_tid());
action_trace->push_back(act);
- obj_map->ensureptr(act->get_location())->push_back(act);
+ obj_map->get_safe_ptr(act->get_location())->push_back(act);
- std::vector<action_list_t> *vec = obj_thrd_map->ensureptr(act->get_location());
+ std::vector<action_list_t> *vec = obj_thrd_map->get_safe_ptr(act->get_location());
if (tid >= (int)vec->size())
vec->resize(next_thread_id);
(*vec)[tid].push_back(act);
*/
ModelAction * ModelChecker::get_last_seq_cst(const void *location)
{
- action_list_t *list = obj_map->ensureptr(location);
+ action_list_t *list = obj_map->get_safe_ptr(location);
/* Find: max({i in dom(S) | seq_cst(t_i) && isWrite(t_i) && samevar(t_i, t)}) */
action_list_t::reverse_iterator rit;
for (rit = list->rbegin(); rit != list->rend(); rit++)
*/
void ModelChecker::build_reads_from_past(ModelAction *curr)
{
- std::vector<action_list_t> *thrd_lists = obj_thrd_map->ensureptr(curr->get_location());
+ std::vector<action_list_t> *thrd_lists = obj_thrd_map->get_safe_ptr(curr->get_location());
unsigned int i;
ASSERT(curr->is_read());