predicate_leaves(),
leaves_tmp_storage(),
weight_debug_vec(),
+ failed_predicates(),
edge_table(32),
out_edges()
{
return -1;
}
+void FuncNode::add_failed_predicate(Predicate * pred)
+{
+ failed_predicates.add(pred);
+}
+
/* Implement quick sort to sort leaves before assigning base scores */
template<typename _Tp>
static int partition(ModelVector<_Tp *> * arr, int low, int high)
while (it->hasNext()) {
Predicate * pred = it->next();
- double weight = 100.0 / sqrt(pred->get_expl_count() + 1);
+ double weight = 100.0 / sqrt(pred->get_expl_count() + pred->get_fail_count() + 1);
pred->set_weight(weight);
leaves_tmp_storage.push_back(pred);
}
weight_debug_vec.clear();
+ PredSetIter * it = failed_predicates.iterator();
+ while (it->hasNext()) {
+ Predicate * pred = it->next();
+ leaves_tmp_storage.push_back(pred);
+ }
+ delete it;
+ failed_predicates.reset();
+
quickSort(&leaves_tmp_storage, 0, leaves_tmp_storage.size() - 1);
for (uint i = 0; i < leaves_tmp_storage.size(); i++) {
Predicate * pred = leaves_tmp_storage[i];
- double weight = 100.0 / sqrt(pred->get_expl_count() + 1);
+ double weight = 100.0 / sqrt(pred->get_expl_count() + pred->get_fail_count() + 1);
pred->set_weight(weight);
}
ModelList<FuncNode *> * get_out_edges() { return &out_edges; }
int compute_distance(FuncNode * target, int max_step = MAX_DIST);
+ void add_failed_predicate(Predicate * pred);
+
void print_predicate_tree();
MEMALLOC
PredSet predicate_leaves;
ModelVector<Predicate *> leaves_tmp_storage;
ModelVector<Predicate *> weight_debug_vec;
+ PredSet failed_predicates;
/* Store the relation between this FuncNode and other FuncNodes */
HashTable<FuncNode *, edge_type_t, uintptr_t, 0, model_malloc, model_calloc, model_free> edge_table;
if (curr_pred != NULL) {
Predicate * selected_branch = NULL;
- if (check_store_visibility(curr_pred, read_inst, inst_act_map, rf_set))
+ if (check_branch_inst(curr_pred, read_inst, inst_act_map, rf_set))
selected_branch = selectBranch(tid, curr_pred, read_inst);
else {
// no child of curr_pred matches read_inst, check back edges
while (it->hasNext()) {
curr_pred = it->next();
- if (check_store_visibility(curr_pred, read_inst, inst_act_map, rf_set)) {
+ if (check_branch_inst(curr_pred, read_inst, inst_act_map, rf_set)) {
selected_branch = selectBranch(tid, curr_pred, read_inst);
break;
}
// The chosen branch fails, reselect new branches
while ( rf_set->size() == 0 ) {
Predicate * selected_branch = get_selected_child_branch(tid);
+ FuncNode * func_node = history->get_curr_func_node(tid);
+
+ // Add failed predicate to NewFuzzer and FuncNode
failed_predicates.put(selected_branch, true);
+ func_node->add_failed_predicate(selected_branch);
+ selected_branch->incr_fail_count();
//model_print("the %d read action of thread %d at %p is unsuccessful\n", read->get_seq_number(), read_thread->get_id(), read->get_location());
FuncInst * read_inst = thrd_last_func_inst[thread_id];
selected_branch = selectBranch(tid, curr_pred, read_inst);
- FuncNode * func_node = history->get_curr_func_node(tid);
inst_act_map_t * inst_act_map = func_node->get_inst_act_map(tid);
prune_writes(tid, selected_branch, rf_set, inst_act_map);
return random_index;
}
-/* For children of curr_pred that matches read_inst.
- * If any store in rf_set satisfies the a child's predicate,
- * increment the store visibility count for it.
- *
+/* Check if children of curr_pred match read_inst.
* @return False if no child matches read_inst
*/
-bool NewFuzzer::check_store_visibility(Predicate * curr_pred, FuncInst * read_inst,
+bool NewFuzzer::check_branch_inst(Predicate * curr_pred, FuncInst * read_inst,
inst_act_map_t * inst_act_map, SnapVector<ModelAction *> * rf_set)
{
available_branches_tmp_storage.clear();
/* The children predicates may have different FuncInsts */
if (branch->get_func_inst() == read_inst) {
any_child_match = true;
+ branch->incr_total_checking_count();
available_branches_tmp_storage.push_back(branch);
}
}
SnapVector<Predicate *> thrd_selected_child_branch;
SnapVector< SnapVector<ModelAction *> *> thrd_pruned_writes;
- bool check_store_visibility(Predicate * curr_pred, FuncInst * read_inst, inst_act_map_t * inst_act_map, SnapVector<ModelAction *> * rf_set);
+ bool check_branch_inst(Predicate * curr_pred, FuncInst * read_inst, inst_act_map_t * inst_act_map, SnapVector<ModelAction *> * rf_set);
Predicate * selectBranch(thread_id_t tid, Predicate * curr_pred, FuncInst * read_inst);
bool prune_writes(thread_id_t tid, Predicate * pred, SnapVector<ModelAction *> * rf_set, inst_act_map_t * inst_act_map);
int choose_branch_index(SnapVector<Predicate *> * branches);
double prob = (double) store_visible_count / total_checking_count;
model_print("Total checks: %d, visible count: %d; prob: %f\n", total_checking_count, store_visible_count, prob);
- model_print("Exploration count: %d", exploration_count);
+ model_print("Exploration count: %d, failure count: %d", exploration_count, failure_count);
model_print("\"];\n");
delete it;
ConcretePredicate * evaluate(inst_act_map_t * inst_act_map, thread_id_t tid);
uint32_t get_expl_count() { return exploration_count; }
+ uint32_t get_fail_count() { return failure_count; }
uint32_t get_store_visible_count() { return store_visible_count; }
uint32_t get_total_checking_count() { return total_checking_count; }
void incr_expl_count() { exploration_count++; }
+ void incr_fail_count() { failure_count++; }
void incr_store_visible_count() { store_visible_count++; }
void incr_total_checking_count() { total_checking_count++; }
double weight;
uint32_t exploration_count;
+ uint32_t failure_count;
uint32_t store_visible_count;
uint32_t total_checking_count; /* The number of times the store visibility is checked */