Some edits
authorweiyu <weiyuluo1232@gmail.com>
Wed, 23 Oct 2019 00:29:49 +0000 (17:29 -0700)
committerweiyu <weiyuluo1232@gmail.com>
Wed, 23 Oct 2019 00:29:49 +0000 (17:29 -0700)
funcnode.cc
hashfunction.cc
predicate.cc
predicate.h

index c739a28..2972b86 100644 (file)
@@ -64,6 +64,7 @@ void FuncNode::add_inst(ModelAction *act)
        if ( func_inst_map.contains(position) ) {
                FuncInst * inst = func_inst_map.get(position);
 
+               /* TODO: The assertion fails when encountering volatile variables that use ++ or -- syntax, i.e. read and write have the same position */
                ASSERT(inst->get_type() == act->get_type());
                int curr_execution_number = model->get_execution_number();
 
@@ -306,7 +307,7 @@ void FuncNode::update_predicate_tree(action_list_t * act_list)
                        inst_id_map.put(next_inst, inst_counter++);
 
                it = it->getNext();
-               /*-- curr_pred->incr_expl_count(); */
+               curr_pred->incr_expl_count();
        }
 
        curr_pred->set_exit(predicate_tree_exit);
index eca9caf..b41dc03 100644 (file)
@@ -1,6 +1,9 @@
 #include "hashfunction.h"
 
-/* Hash function for 64-bit integers */
+/** 
+ * Hash function for 64-bit integers
+ * https://gist.github.com/badboy/6267743#64-bit-to-32-bit-hash-functions
+ */
 unsigned int int64_hash(uint64_t key) {
        key = (~key) + (key << 18); // key = (key << 18) - key - 1;
        key = key ^ (key >> 31);
index ab64a34..51b216d 100644 (file)
@@ -8,8 +8,8 @@ Predicate::Predicate(FuncInst * func_inst, bool is_entry, bool is_exit) :
        exit_predicate(is_exit),
        does_write(false),
        exploration_count(0),
-       failure_count(0),
-       sleep_score(100),
+       store_visible_count(0),
+       total_checking_count(0),
        pred_expressions(16),
        children(),
        parent(NULL),
@@ -98,32 +98,6 @@ ConcretePredicate * Predicate::evaluate(inst_act_map_t * inst_act_map, thread_id
        return concrete;
 }
 
-void Predicate::incr_expl_count()
-{
-       exploration_count++;
-}
-
-void Predicate::incr_fail_count()
-{
-       failure_count++;
-}
-
-void Predicate::incr_sleep_score(uint32_t amount)
-{
-       if (sleep_score + amount > 100)
-               sleep_score = 100;
-       else
-               sleep_score += amount;
-}
-
-void Predicate::decr_sleep_score(uint32_t amount)
-{
-       if (sleep_score > amount)
-               sleep_score -= amount;
-       else
-               sleep_score = 0;
-}
-
 void Predicate::print_predicate()
 {
        model_print("\"%p\" [shape=box, label=\"\n", this);
@@ -164,7 +138,10 @@ void Predicate::print_predicate()
        if (does_write) {
                model_print("Does write\n");
        }
-       model_print("Count: %d, failed count: %d\n", exploration_count, failure_count);
+
+       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("\"];\n");
 }
 
index 5c634fb..3e1867f 100644 (file)
@@ -40,12 +40,12 @@ public:
        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_sleep_score() { return sleep_score; }
-       void incr_expl_count();
-       void incr_fail_count();
-       void incr_sleep_score(uint32_t amount);
-       void decr_sleep_score(uint32_t amount);
+       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_store_visible_count() { store_visible_count++; }
+       void incr_total_checking_count() { total_checking_count++; }
 
        void print_predicate();
        void print_pred_subtree();
@@ -58,8 +58,8 @@ private:
        bool does_write;
 
        uint32_t exploration_count;
-       uint32_t failure_count;
-       uint32_t sleep_score;   /* 0 <= sleep_score <= 100 */
+       uint32_t store_visible_count;
+       uint32_t total_checking_count;  /* The number of times the store visibility is checked */
 
        /* May have multiple predicate expressions */
        PredExprSet pred_expressions;