{
int tid = id_to_int(act->get_tid());
if ((act->is_fence() && act->is_seqcst()) || act->is_unlock()) {
- action_list_t *list = get_safe_ptr_action(&obj_map, act->get_location());
- list->push_back(act);
+ action_list_t *list = get_safe_ptr_action(&obj_map, act->get_location());
+ list->push_back(act);
}
// Update action trace, a total order of all actions
action_list_t action_trace;
/** Per-object list of actions. Maps an object (i.e., memory location)
- * to a trace of all actions performed on the object.
+ * to a trace of all actions performed on the object.
* Used only for SC fences, unlocks, & wait.
*/
HashTable<const void *, action_list_t *, uintptr_t, 2> obj_map;
* @return true if branch found, false otherwise.
*/
bool FuncNode::follow_branch(Predicate ** curr_pred, FuncInst * next_inst,
-ModelAction * next_act, SnapVector<Predicate *> * unset_predicates)
+ ModelAction * next_act, SnapVector<Predicate *> * unset_predicates)
{
/* Check if a branch with func_inst and corresponding predicate exists */
bool branch_found = false;
bool equality;
switch(pred_expression->token) {
- case NOPREDICATE:
- predicate_correct = true;
- break;
- case EQUALITY:
- FuncInst * to_be_compared;
- ModelAction * last_act;
+ case NOPREDICATE:
+ predicate_correct = true;
+ break;
+ case EQUALITY:
+ FuncInst * to_be_compared;
+ ModelAction * last_act;
- to_be_compared = pred_expression->func_inst;
- last_act = to_be_compared->get_associated_act(marker);
+ to_be_compared = pred_expression->func_inst;
+ 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();
- equality = (last_read == next_read);
- if (equality != pred_expression->value)
- predicate_correct = false;
+ last_read = last_act->get_reads_from_value();
+ next_read = next_act->get_reads_from_value();
+ equality = (last_read == next_read);
+ if (equality != pred_expression->value)
+ predicate_correct = false;
- break;
- case NULLITY:
- next_read = next_act->get_reads_from_value();
- // TODO: implement likely to be null
- equality = ( (void*) (next_read & 0xffffffff) == NULL);
- if (equality != pred_expression->value)
- predicate_correct = false;
- break;
- default:
+ break;
+ case NULLITY:
+ next_read = next_act->get_reads_from_value();
+ // TODO: implement likely to be null
+ equality = ( (void*) (next_read & 0xffffffff) == NULL);
+ if (equality != pred_expression->value)
predicate_correct = false;
- model_print("unkown predicate token\n");
- break;
+ break;
+ default:
+ predicate_correct = false;
+ model_print("unkown predicate token\n");
+ break;
}
}
/* Infer predicate expressions, which are generated in FuncNode::generate_predicates */
void FuncNode::infer_predicates(FuncInst * next_inst, ModelAction * next_act,
-HashTable<void *, ModelAction *, uintptr_t, 0> * loc_act_map,
-SnapVector<struct half_pred_expr *> * half_pred_expressions)
+ HashTable<void *, ModelAction *, uintptr_t, 0> * loc_act_map,
+ SnapVector<struct half_pred_expr *> * half_pred_expressions)
{
void * loc = next_act->get_location();
/* Able to generate complex predicates when there are multiple predciate expressions */
void FuncNode::generate_predicates(Predicate ** curr_pred, FuncInst * next_inst,
-SnapVector<struct half_pred_expr *> * half_pred_expressions)
+ SnapVector<struct half_pred_expr *> * half_pred_expressions)
{
if (half_pred_expressions->size() == 0) {
Predicate * new_pred = new Predicate(next_inst);
leaves.push_back(node);
}
- for (uint i = 0; i < children->size(); i++)
+ for (uint i = 0;i < children->size();i++)
queue.push_front( (*children)[i] );
}
double weight_sum = 0;
bool has_unassigned_node = false;
- for (uint i = 0; i < children->size(); i++) {
+ for (uint i = 0;i < children->size();i++) {
Predicate * child = (*children)[i];
// If a child has unassigned weight
}
void ModelHistory::add_waiting_thread(thread_id_t self_id,
-thread_id_t waiting_for_id, FuncNode * target_node, int dist)
+ thread_id_t waiting_for_id, FuncNode * target_node, int dist)
{
WaitObj * self_wait_obj = getWaitObj(self_id);
self_wait_obj->add_waiting_for(waiting_for_id, target_node, dist);
}
void ModelHistory::stop_waiting_for_node(thread_id_t self_id,
-thread_id_t waiting_for_id, FuncNode * target_node)
+ thread_id_t waiting_for_id, FuncNode * target_node)
{
WaitObj * self_wait_obj = getWaitObj(self_id);
bool thread_removed = self_wait_obj->remove_waiting_for_node(waiting_for_id, target_node);
* @return False if no child matches read_inst
*/
bool NewFuzzer::check_store_visibility(Predicate * curr_pred, FuncInst * read_inst,
-inst_act_map_t * inst_act_map, SnapVector<ModelAction *> * rf_set)
+ inst_act_map_t * inst_act_map, SnapVector<ModelAction *> * rf_set)
{
available_branches_tmp_storage.clear();
* @return true if rf_set is pruned
*/
bool NewFuzzer::prune_writes(thread_id_t tid, Predicate * pred,
-SnapVector<ModelAction *> * rf_set, inst_act_map_t * inst_act_map)
+ SnapVector<ModelAction *> * rf_set, inst_act_map_t * inst_act_map)
{
if (pred == NULL)
return false;
}
bool NewFuzzer::check_predicate_expressions(PredExprSet * pred_expressions,
-inst_act_map_t * inst_act_map, uint64_t write_val, bool * no_predicate)
+ inst_act_map_t * inst_act_map, uint64_t write_val, bool * no_predicate)
{
bool satisfy_predicate = true;
bool equality;
switch (expression->token) {
- case NOPREDICATE:
- *no_predicate = true;
- break;
- case EQUALITY:
- FuncInst * to_be_compared;
- ModelAction * last_act;
- uint64_t last_read;
-
- to_be_compared = expression->func_inst;
- last_act = inst_act_map->get(to_be_compared);
- last_read = last_act->get_reads_from_value();
-
- equality = (write_val == last_read);
- if (equality != expression->value)
- satisfy_predicate = false;
- break;
- case NULLITY:
- // TODO: implement likely to be null
- equality = ((void*) (write_val & 0xffffffff) == NULL);
- if (equality != expression->value)
- satisfy_predicate = false;
- break;
- default:
- model_print("unknown predicate token\n");
- break;
+ case NOPREDICATE:
+ *no_predicate = true;
+ break;
+ case EQUALITY:
+ FuncInst * to_be_compared;
+ ModelAction * last_act;
+ uint64_t last_read;
+
+ to_be_compared = expression->func_inst;
+ last_act = inst_act_map->get(to_be_compared);
+ last_read = last_act->get_reads_from_value();
+
+ equality = (write_val == last_read);
+ if (equality != expression->value)
+ satisfy_predicate = false;
+ break;
+ case NULLITY:
+ // TODO: implement likely to be null
+ equality = ((void*) (write_val & 0xffffffff) == NULL);
+ if (equality != expression->value)
+ satisfy_predicate = false;
+ break;
+ default:
+ model_print("unknown predicate token\n");
+ break;
}
if (!satisfy_predicate)
_size++;
}
+ sllnode<_Tp>add_front(_Tp val) {
+ sllnode<_Tp> * tmp = new sllnode<_Tp>();
+ tmp->prev = NULL;
+ tmp->next = head;
+ tmp->val = val;
+ if (head == NULL)
+ tail = tmp;
+ else
+ head->prev = tmp;
+ head = tmp;
+ _size++;
+ return tmp;
+ }
+
+ sllnode<_Tp> * add_back(_Tp val) {
+ sllnode<_Tp> * tmp = new sllnode<_Tp>();
+ tmp->prev = tail;
+ tmp->next = NULL;
+ tmp->val = val;
+ if (tail == NULL)
+ head = tmp;
+ else tail->next = tmp;
+ tail = tmp;
+ _size++;
+ return tmp;
+ }
+
void pop_front() {
sllnode<_Tp> *tmp = head;
head = head->next;