Move one snapshotted data structure from ModelHistory to ModelExecution
authorweiyu <weiyuluo1232@gmail.com>
Wed, 2 Oct 2019 02:00:42 +0000 (19:00 -0700)
committerweiyu <weiyuluo1232@gmail.com>
Wed, 2 Oct 2019 02:00:42 +0000 (19:00 -0700)
execution.h
history.cc
history.h

index 622f17aafedaefe74d675f7eb42ca8be37eace61..b35113fd60aff8c8e8f3a49f838f3760104986b5 100644 (file)
@@ -89,6 +89,7 @@ public:
        ModelAction * check_current_action(ModelAction *curr);
 
        SnapVector<func_id_list_t> * get_thrd_func_list() { return &thrd_func_list; }
+       SnapVector<uint32_t> * get_thrd_last_entered_func() { return &thrd_last_entered_func; }
        SnapVector< SnapList<action_list_t *> *> * get_thrd_func_act_lists() { return &thrd_func_act_lists; }
        bool isFinished() {return isfinished;}
        void setFinished() {isfinished = true;}
@@ -209,6 +210,7 @@ private:
         * This data structure is handled by ModelHistory
         */
        SnapVector<func_id_list_t> thrd_func_list;
+       SnapVector<uint32_t> thrd_last_entered_func;
 
        /* Keeps track of atomic actions that thread i has performed in some
         * function. Index of SnapVector is thread id. SnapList simulates
index bf40312c770df768ac3562f5b7fc8c668691b973..989a2afde4463239064ad9e21b27e3f4becb7701 100644 (file)
@@ -21,7 +21,6 @@ ModelHistory::ModelHistory() :
        write_history = new HashTable<void *, value_set_t *, uintptr_t, 4>();
        loc_func_nodes_map = new HashTable<void *, SnapList<FuncNode *> *, uintptr_t, 0>();
        loc_wr_func_nodes_map = new HashTable<void *, SnapList<FuncNode *> *, uintptr_t, 0>();
-       thrd_last_entered_func = new SnapVector<uint32_t>();
        loc_waiting_writes_map = new HashTable<void *, SnapVector<ConcretePredicate *> *, uintptr_t, 0>();
        thrd_waiting_write = new SnapVector<ConcretePredicate *>();
        func_inst_act_maps = new HashTable<uint32_t, SnapVector<inst_act_map_t *> *, int, 0>();
@@ -30,10 +29,12 @@ ModelHistory::ModelHistory() :
 void ModelHistory::enter_function(const uint32_t func_id, thread_id_t tid)
 {
        //model_print("thread %d entering func %d\n", tid, func_id);
+       ModelExecution * execution = model->get_execution();
        uint id = id_to_int(tid);
-       SnapVector<func_id_list_t> * thrd_func_list = model->get_execution()->get_thrd_func_list();
+       SnapVector<func_id_list_t> * thrd_func_list = execution->get_thrd_func_list();
        SnapVector< SnapList<action_list_t *> *> *
-               thrd_func_act_lists = model->get_execution()->get_thrd_func_act_lists();
+               thrd_func_act_lists = execution->get_thrd_func_act_lists();
+       SnapVector<uint32_t> * thrd_last_entered_func = execution->get_thrd_last_entered_func();
 
        if ( thrd_func_list->size() <= id ) {
                uint oldsize = thrd_func_list->size();
@@ -41,18 +42,15 @@ void ModelHistory::enter_function(const uint32_t func_id, thread_id_t tid)
                thrd_func_act_lists->resize( id + 1 );
 
                for (uint i = oldsize; i < id + 1; i++) {
-                       new (&(*thrd_func_list)[i]) func_id_list_t();
                        // push 0 as a dummy function id to a void seg fault
+                       new (&(*thrd_func_list)[i]) func_id_list_t();
                        (*thrd_func_list)[i].push_back(0);
 
                        (*thrd_func_act_lists)[i] = new SnapList<action_list_t *>();
+                       thrd_last_entered_func->push_back(0);
                }
        }
 
-       while ( thrd_last_entered_func->size() <= id ) {
-               thrd_last_entered_func->push_back(0);   // 0 is a dummy function id
-       }
-
        SnapList<action_list_t *> * func_act_lists = (*thrd_func_act_lists)[id];
        func_act_lists->push_back( new action_list_t() );
 
@@ -77,10 +75,11 @@ void ModelHistory::enter_function(const uint32_t func_id, thread_id_t tid)
 /* @param func_id a non-zero value */
 void ModelHistory::exit_function(const uint32_t func_id, thread_id_t tid)
 {
+       ModelExecution * execution = model->get_execution();
        uint32_t id = id_to_int(tid);
-       SnapVector<func_id_list_t> * thrd_func_list = model->get_execution()->get_thrd_func_list();
+       SnapVector<func_id_list_t> * thrd_func_list = execution->get_thrd_func_list();
        SnapVector< SnapList<action_list_t *> *> *
-               thrd_func_act_lists = model->get_execution()->get_thrd_func_act_lists();
+               thrd_func_act_lists = execution->get_thrd_func_act_lists();
 
        SnapList<action_list_t *> * func_act_lists = (*thrd_func_act_lists)[id];
        uint32_t last_func_id = (*thrd_func_list)[id].back();
@@ -135,11 +134,12 @@ void ModelHistory::resize_func_nodes(uint32_t new_size)
 
 void ModelHistory::process_action(ModelAction *act, thread_id_t tid)
 {
+       ModelExecution * execution = model->get_execution();
        /* return if thread i has not entered any function or has exited
           from all functions */
-       SnapVector<func_id_list_t> * thrd_func_list = model->get_execution()->get_thrd_func_list();
+       SnapVector<func_id_list_t> * thrd_func_list = execution->get_thrd_func_list();
        SnapVector< SnapList<action_list_t *> *> *
-               thrd_func_act_lists = model->get_execution()->get_thrd_func_act_lists();
+               thrd_func_act_lists = execution->get_thrd_func_act_lists();
 
        uint32_t id = id_to_int(tid);
        if ( thrd_func_list->size() <= id )
@@ -198,7 +198,7 @@ void ModelHistory::process_action(ModelAction *act, thread_id_t tid)
                func_node->update_inst_act_map(tid, act);
 
                // Update predicate tree position
-               Fuzzer * fuzzer = model->get_execution()->getFuzzer();
+               Fuzzer * fuzzer = execution->getFuzzer();
                Predicate * selected_branch = fuzzer->get_selected_child_branch(tid);
                func_node->set_predicate_tree_position(tid, selected_branch);
        }
index a39850ba5f6afdc144eaefd8f931325dd15bb56a..ad72cdfa85e34aaab1ffee3b905b136b87925ada 100644 (file)
--- a/history.h
+++ b/history.h
@@ -65,9 +65,6 @@ private:
        /* Map a location to FuncNodes that may write to it */
        HashTable<void *, SnapList<FuncNode *> *, uintptr_t, 0> * loc_wr_func_nodes_map;
 
-       /* Keeps track of the last function entered by each thread */
-       SnapVector<uint32_t> * thrd_last_entered_func;
-
        HashTable<void *, SnapVector<ConcretePredicate *> *, uintptr_t, 0> * loc_waiting_writes_map;
        SnapVector<ConcretePredicate *> * thrd_waiting_write;