FuncInst(ModelAction *act, FuncNode *func_node);
~FuncInst();
- //ModelAction * get_action() const { return action; }
const char * get_position() const { return position; }
void * get_location() const { return location; }
action_type get_type() const { return type; }
bool add_pred(FuncInst * other);
bool add_succ(FuncInst * other);
- FuncInst * search_in_collision(ModelAction *act);
+ //FuncInst * search_in_collision(ModelAction *act);
+ //func_inst_list_mt * get_collisions() { return &collisions; }
- func_inst_list_mt * get_collisions() { return &collisions; }
func_inst_list_mt * get_preds() { return &predecessors; }
func_inst_list_mt * get_succs() { return &successors; }
bool is_read() const;
bool is_write() const;
+ bool is_single_location() { return single_location; }
+ void not_single_location() { single_location = false; }
void print();
MEMALLOC
private:
- //ModelAction * const action;
const char * position;
+
+ /* Atomic operations with the same source line number may act at different
+ * memory locations, such as the next field of the head pointer in ms-queue.
+ * location only stores the memory location when this FuncInst was constructed.
+ */
void * location;
action_type type;
memory_order order;
FuncNode * func_node;
- /* collisions store a list of FuncInsts with the same position
+ bool single_location;
+
+ /* Currently not in use. May remove this field later
+ *
+ * collisions store a list of FuncInsts with the same position
* but different action types. For example, CAS is broken down
* as three different atomic operations in cmodelint.cc */
- func_inst_list_mt collisions;
+ // func_inst_list_mt collisions;
func_inst_list_mt predecessors;
func_inst_list_mt successors;
if ( func_inst_map.contains(position) ) {
FuncInst * inst = func_inst_map.get(position);
- if (inst->get_type() != act->get_type() ) {
- // model_print("action with a different type occurs at line number %s\n", position);
- FuncInst * func_inst = inst->search_in_collision(act);
-
- if (func_inst != NULL)
- return;
-
- func_inst = new FuncInst(act, this);
- inst->get_collisions()->push_back(func_inst);
- inst_list.push_back(func_inst); // delete?
- }
+ ASSERT(inst->get_type() == act->get_type());
+ if (inst->get_location() != act->get_location())
+ inst->not_single_location();
return;
}
if (inst == NULL)
return NULL;
-// ASSERT(inst->get_location() == act->get_location());
-
action_type inst_type = inst->get_type();
action_type act_type = act->get_type();
read_act_list.push_back(act);
}
+ model_print("function %s\n", func_name);
update_inst_tree(&inst_list);
update_predicate_tree(&read_act_list);
+ deep_update(predicate_tree_entry);
+
+ print_predicate_tree();
}
/**
curr_pred->add_child(new_pred1);
curr_pred->add_child(new_pred2);
- //new_pred1->add_parent(curr_pred);
- //new_pred2->add_parent(curr_pred);
+ new_pred1->set_parent(curr_pred);
+ new_pred2->set_parent(curr_pred);
ModelAction * last_act = loc_act_map.get(next_act->get_location());
uint64_t last_read = last_act->get_reads_from_value();
} else {
Predicate * new_pred = new Predicate(next_inst);
curr_pred->add_child(new_pred);
- //new_pred->add_parent(curr_pred);
+ new_pred->set_parent(curr_pred);
curr_pred = new_pred;
}
loc_act_map.put(next_act->get_location(), next_act);
it = it->getNext();
}
+}
+
+void FuncNode::deep_update(Predicate * curr_pred)
+{
+ FuncInst * func_inst = curr_pred->get_func_inst();
+ if (func_inst != NULL && !func_inst->is_single_location()) {
+ bool has_null_pred = false;
+ PredExprSet * pred_expressions = curr_pred->get_pred_expressions();
+ PredExprSetIter * pred_expr_it = pred_expressions->iterator();
+ while (pred_expr_it->hasNext()) {
+ pred_expr * pred_expression = pred_expr_it->next();
+ if (pred_expression->token == NULLITY) {
+ has_null_pred = true;
+ break;
+ }
+ }
+
+ if (!has_null_pred) {
+// func_inst->print();
+ Predicate * parent = curr_pred->get_parent();
+ curr_pred->add_predicate(NULLITY, NULL, 0);
+
+ Predicate * another_branch = new Predicate(func_inst);
+ another_branch->add_predicate(NULLITY, NULL, 1);
+ parent->add_child(another_branch);
+// another_branch.add_children(i);
+ }
+ }
-// model_print("function %s\n", func_name);
-// print_predicate_tree();
+ ModelVector<Predicate *> * branches = curr_pred->get_children();
+ for (uint i = 0; i < branches->size(); i++) {
+ Predicate * branch = (*branches)[i];
+ deep_update(branch);
+ }
}
/* Given curr_pred and next_inst, find the branch following curr_pred that contains next_inst and the correct predicate
/* no predicate, follow the only branch */
if (pred_expressions->getSize() == 0) {
-// model_print("no predicate exists: "); next_inst->print();
*curr_pred = branch;
branch_found = true;
break;
next_read = next_act->get_reads_from_value();
equality = (last_read == next_read);
-
if (equality == pred_expression->value) {
*curr_pred = branch;
// model_print("predicate: token: %d, location: %p, value: %d - ", pred_expression->token, pred_expression->location, pred_expression->value); next_inst->print();
}
break;
case NULLITY:
+ next_read = next_act->get_reads_from_value();
+ equality = ((void*)next_read == NULL);
+ //model_print("%s ", next_act->get_position()); next_act->print();
+ if (equality == pred_expression->value) {
+ *curr_pred = branch;
+ branch_found = true;
+ }
break;
default:
model_print("unkown predicate token\n");
PredExprSet * get_pred_expressions() { return &pred_expressions; }
void add_predicate(token_t token, void * location, bool value);
void add_child(Predicate * child);
- void add_parent(Predicate * parent);
+ void set_parent(Predicate * parent_pred) { parent = parent_pred; }
void set_backedge(Predicate * back_pred) { backedge = back_pred; }
ModelVector<Predicate *> * get_children() { return &children; }
- ModelVector<Predicate *> * get_parents() { return &parents; }
+ Predicate * get_parent() { return parent; }
Predicate * get_backedge() { return backedge; }
bool is_entry_predicate() { return entry_predicate; }
/* may have multiple predicates */
PredExprSet pred_expressions;
ModelVector<Predicate *> children;
- ModelVector<Predicate *> parents;
+
+ /* only a single parent may exist */
+ Predicate * parent;
/* assume almost one back edge exists */
Predicate * backedge;