FuncInst::FuncInst(ModelAction *act, FuncNode *func_node) :
single_location(true),
- execution_number(model->get_execution_number())
+ execution_number(model->get_execution_number()),
+ marker(0) /* The marker for FuncNode starts from 1 */
{
ASSERT(act);
ASSERT(func_node);
return true;
}
+void FuncInst::set_associated_act(ModelAction * act, uint32_t marker)
+{
+ associated_act = act;
+ this->marker = marker;
+}
+
+ModelAction * FuncInst::get_associated_act(uint32_t marker)
+{
+ if (marker == this->marker)
+ return associated_act;
+ else
+ return NULL;
+}
+
/*
FuncInst * FuncInst::search_in_collision(ModelAction *act)
{
FuncNode::FuncNode(ModelHistory * history) :
history(history),
exit_count(0),
+ marker(1),
func_inst_map(),
inst_list(),
entry_insts(),
write_locations->add(loc);
history->update_loc_wr_func_nodes_map(loc, this);
}
-
}
if (act->is_read()) {
if (act_list == NULL || act_list->size() == 0)
return;
+ incr_marker();
+
/* Map a FuncInst to the its predicate */
HashTable<FuncInst *, Predicate *, uintptr_t, 0> inst_pred_map(128);
/* Only need to store the locations of read actions */
HashTable<void *, ModelAction *, uintptr_t, 0> loc_act_map(128);
- HashTable<FuncInst *, ModelAction *, uintptr_t, 0> inst_act_map(128);
sllnode<ModelAction *> *it = act_list->begin();
Predicate * curr_pred = predicate_tree_entry;
while (it != NULL) {
ModelAction * next_act = it->getVal();
FuncInst * next_inst = get_inst(next_act);
+ next_inst->set_associated_act(next_act, marker);
SnapVector<Predicate *> unset_predicates = SnapVector<Predicate *>();
- bool branch_found = follow_branch(&curr_pred, next_inst, next_act, &inst_act_map, &unset_predicates);
+ bool branch_found = follow_branch(&curr_pred, next_inst, next_act, &unset_predicates);
// A branch with unset predicate expression is detected
if (!branch_found && unset_predicates.size() != 0) {
loc_act_map.put(next_act->get_location(), next_act);
}
- inst_act_map.put(next_inst, next_act);
inst_pred_map.put(next_inst, curr_pred);
if (!inst_id_map.contains(next_inst))
inst_id_map.put(next_inst, inst_counter++);
* contains next_inst and the correct predicate.
* @return true if branch found, false otherwise.
*/
-bool FuncNode::follow_branch(Predicate ** curr_pred, FuncInst * next_inst, ModelAction * next_act,
- HashTable<FuncInst *, ModelAction *, uintptr_t, 0> * inst_act_map,
- SnapVector<Predicate *> * unset_predicates)
+bool FuncNode::follow_branch(Predicate ** curr_pred, FuncInst * next_inst,
+ ModelAction * next_act, SnapVector<Predicate *> * unset_predicates)
{
/* Check if a branch with func_inst and corresponding predicate exists */
bool branch_found = false;
ModelAction * last_act;
to_be_compared = pred_expression->func_inst;
- last_act = inst_act_map->get(to_be_compared);
+ last_act = to_be_compared->get_associated_act(marker);
last_read = last_act->get_reads_from_value();
next_read = next_act->get_reads_from_value();
void update_tree(action_list_t * act_list);
void update_inst_tree(func_inst_list_t * inst_list);
void update_predicate_tree(action_list_t * act_list);
- bool follow_branch(Predicate ** curr_pred, FuncInst * next_inst, ModelAction * next_act, HashTable<FuncInst *, ModelAction *, uintptr_t, 0> * inst_act_map, SnapVector<Predicate *> * unset_predicates);
+ bool follow_branch(Predicate ** curr_pred, FuncInst * next_inst, ModelAction * next_act, SnapVector<Predicate *> * unset_predicates);
void incr_exit_count() { exit_count++; }
uint32_t get_exit_count() { return exit_count; }
Predicate * predicate_tree_entry; // a dummy node whose children are the real entries
uint32_t exit_count;
+ uint32_t marker;
+
+ void incr_marker() { marker++; }
/* Use source line number as the key of hashtable, to check if
* atomic operation with this line number has been added or not