X-Git-Url: http://plrg.eecs.uci.edu/git/?p=c11tester.git;a=blobdiff_plain;f=predicate.cc;h=9b8060aa777b51554e1d841d9841672cb6b2593d;hp=9ef029882f5cf87ca32a72456a0251463356f67e;hb=193c917736aedbc4b34e6cae3e6eb35eb5e98502;hpb=be2b5266d974c5a043955f0fe29cd3d89aab7072 diff --git a/predicate.cc b/predicate.cc index 9ef02988..9b8060aa 100644 --- a/predicate.cc +++ b/predicate.cc @@ -8,7 +8,7 @@ Predicate::Predicate(FuncInst * func_inst, bool is_entry, bool is_exit) : exit_predicate(is_exit), does_write(false), depth(0), - weight(0), + weight(100), exploration_count(0), store_visible_count(0), total_checking_count(0), @@ -76,57 +76,46 @@ void Predicate::copy_predicate_expr(Predicate * other) struct pred_expr * copy = new pred_expr(ptr->token, ptr->func_inst, ptr->value); pred_expressions.add(copy); } -} - -/* Follow the child if any child whose FuncInst matches with inst - * - * @param inst must be an ATOMIC_WRITE FuncInst - * @return NULL if no such child is found. - */ -Predicate * Predicate::follow_write_child(FuncInst * inst) -{ - ASSERT(inst->get_type() == ATOMIC_WRITE); - for (uint i = 0; i < children.size(); i++) { - Predicate * child = children[i]; - if (child->get_func_inst() == inst) - return child; - } - - return NULL; + delete it; } /* Evaluate predicate expressions against the given inst_act_map */ -ConcretePredicate * Predicate::evaluate(inst_act_map_t * inst_act_map, thread_id_t tid) +ConcretePredicate * Predicate::evaluate(thread_id_t tid) { - ConcretePredicate * concrete = new ConcretePredicate(tid); - PredExprSetIter * it = pred_expressions.iterator(); - - while (it->hasNext()) { - struct pred_expr * ptr = it->next(); - uint64_t value = 0; + /* + ConcretePredicate * concrete = new ConcretePredicate(tid); + PredExprSetIter * it = pred_expressions.iterator(); + + while (it->hasNext()) { + struct pred_expr * ptr = it->next(); + uint64_t value = 0; + + switch(ptr->token) { + case NOPREDICATE: + break; + case EQUALITY: + FuncInst * to_be_compared; + ModelAction * last_act; + + to_be_compared = ptr->func_inst; + last_act = inst_act_map->get(to_be_compared); + value = last_act->get_reads_from_value(); + break; + case NULLITY: + break; + default: + break; + } + + concrete->add_expression(ptr->token, value, ptr->value); + } + + delete it; + return concrete; + */ - switch(ptr->token) { - case NOPREDICATE: - break; - case EQUALITY: - FuncInst * to_be_compared; - ModelAction * last_act; - - to_be_compared = ptr->func_inst; - last_act = inst_act_map->get(to_be_compared); - value = last_act->get_reads_from_value(); - break; - case NULLITY: - break; - default: - break; - } - - concrete->add_expression(ptr->token, value, ptr->value); - } - - return concrete; + return NULL; } void Predicate::print_predicate() @@ -174,8 +163,10 @@ void Predicate::print_predicate() 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; } void Predicate::print_pred_subtree() @@ -196,4 +187,6 @@ void Predicate::print_pred_subtree() if (exit) { model_print("\"%p\" -> \"%p\"[style=dashed, color=red]\n", this, exit); } + + delete it; }