Edits
[c11tester.git] / history.cc
index b11614bdf58a7f55a4e8e75e4ee12f480650ad93..7fab503bc48e5056f4ec68ae260bfb35e73b9ebd 100644 (file)
@@ -16,19 +16,18 @@ ModelHistory::ModelHistory() :
        func_counter(1),        /* function id starts with 1 */
        func_map(),
        func_map_rev(),
-       func_nodes()
+       func_nodes(),
+       last_action(NULL)
 {
        /* The following are snapshot data structures */
        write_history = new HashTable<void *, value_set_t *, uintptr_t, 0>();
        loc_rd_func_nodes_map = new HashTable<void *, SnapVector<FuncNode *> *, uintptr_t, 0>();
        loc_wr_func_nodes_map = new HashTable<void *, SnapVector<FuncNode *> *, uintptr_t, 0>();
        loc_waiting_writes_map = new HashTable<void *, SnapVector<ConcretePredicate *> *, uintptr_t, 0>();
-       thrd_func_act_lists = new SnapVector< SnapList<action_list_t *> *>();
        thrd_func_list = new SnapVector<func_id_list_t>();
        thrd_last_entered_func = new SnapVector<uint32_t>();
        thrd_waiting_write = new SnapVector<ConcretePredicate *>();
        thrd_wait_obj = new SnapVector<WaitObj *>();
-       func_inst_act_maps = new HashTable<uint32_t, SnapVector<inst_act_map_t *> *, int, 0>(128);
 }
 
 ModelHistory::~ModelHistory()
@@ -46,21 +45,15 @@ void ModelHistory::enter_function(const uint32_t func_id, thread_id_t tid)
        if ( thrd_func_list->size() <= id ) {
                uint oldsize = thrd_func_list->size();
                thrd_func_list->resize( id + 1 );
-               thrd_func_act_lists->resize( id + 1 );
 
                for (uint i = oldsize;i < id + 1;i++) {
                        // 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);
                }
        }
 
-       SnapList<action_list_t *> * func_act_lists = (*thrd_func_act_lists)[id];
-       func_act_lists->push_back( new action_list_t() );
-
        uint32_t last_entered_func_id = (*thrd_last_entered_func)[id];
        (*thrd_last_entered_func)[id] = func_id;
        (*thrd_func_list)[id].push_back(func_id);
@@ -85,8 +78,6 @@ void ModelHistory::enter_function(const uint32_t func_id, thread_id_t tid)
 void ModelHistory::exit_function(const uint32_t func_id, thread_id_t tid)
 {
        uint32_t id = id_to_int(tid);
-
-       SnapList<action_list_t *> * func_act_lists = (*thrd_func_act_lists)[id];
        uint32_t last_func_id = (*thrd_func_list)[id].back();
 
        if (last_func_id == func_id) {
@@ -94,10 +85,8 @@ void ModelHistory::exit_function(const uint32_t func_id, thread_id_t tid)
                func_node->function_exit_handler(tid);
 
                (*thrd_func_list)[id].pop_back();
-               func_act_lists->pop_back();
        } else {
-               model_print("trying to exit with a wrong function id\n");
-               model_print("--- last_func: %d, func_id: %d\n", last_func_id, func_id);
+               ASSERT(false);
        }
        //model_print("thread %d exiting func %d\n", tid, func_id);
 }
@@ -152,29 +141,16 @@ void ModelHistory::process_action(ModelAction *act, thread_id_t tid)
        if (func_id == 0 || act->get_position() == NULL)
                return;
 
-       SnapList<action_list_t *> * func_act_lists = (*thrd_func_act_lists)[thread_id];
-
-       /* The list of actions that thread tid has taken in its current function */
-       action_list_t * curr_act_list = func_act_lists->back();
-
-       if (skip_action(act, curr_act_list))
+       if (skip_action(act))
                return;
 
-       /* Add to curr_inst_list */
-       curr_act_list->push_back(act);
-
        FuncNode * func_node = func_nodes[func_id];
        func_node->add_inst(act);
 
        if (act->is_read()) {
-               func_node->update_inst_act_map(tid, act);
-
-//             Fuzzer * fuzzer = model->get_execution()->getFuzzer();
-//             Predicate * selected_branch = ((NewFuzzer *)fuzzer)->get_selected_child_branch(tid);
-//             func_node->set_predicate_tree_position(tid, selected_branch);
-       }
-/*
-       if (act->is_write()) {
+               // Do nothing
+       } else if (act->is_write()) {
+               /*
                Predicate * curr_pred = func_node->get_predicate_tree_position(tid);
                FuncInst * curr_inst = func_node->get_inst(act);
 
@@ -183,10 +159,11 @@ void ModelHistory::process_action(ModelAction *act, thread_id_t tid)
                        curr_pred = curr_pred->follow_write_child(curr_inst);
                }
                func_node->set_predicate_tree_position(tid, curr_pred);
+               */
        }
-*/
 
        func_node->update_tree(act);
+       last_action = act;
 }
 
 /* Return the FuncNode given its func_id  */
@@ -419,23 +396,8 @@ void ModelHistory::stop_waiting_for_node(thread_id_t self_id,
        }
 }
 
-SnapVector<inst_act_map_t *> * ModelHistory::getThrdInstActMap(uint32_t func_id)
+bool ModelHistory::skip_action(ModelAction * act)
 {
-       ASSERT(func_id != 0);
-
-       SnapVector<inst_act_map_t *> * maps = func_inst_act_maps->get(func_id);
-       if (maps == NULL) {
-               maps = new SnapVector<inst_act_map_t *>();
-               func_inst_act_maps->put(func_id, maps);
-       }
-
-       return maps;
-}
-
-bool ModelHistory::skip_action(ModelAction * act, SnapList<ModelAction *> * curr_act_list)
-{
-       ASSERT(curr_act_list != NULL);
-
        bool second_part_of_rmw = act->is_rmwc() || act->is_rmw();
        modelclock_t curr_seq_number = act->get_seq_number();
 
@@ -444,9 +406,8 @@ bool ModelHistory::skip_action(ModelAction * act, SnapList<ModelAction *> * curr
                return true;
 
        /* Skip actions with the same sequence number */
-       if (curr_act_list->size() != 0) {
-               ModelAction * last_act = curr_act_list->back();
-               if (last_act->get_seq_number() == curr_seq_number)
+       if (last_action != NULL) {
+               if (last_action->get_seq_number() == curr_seq_number)
                        return true;
        }