From 1cfe55ed692a62e11ded4d7574a660471ac96703 Mon Sep 17 00:00:00 2001 From: weiyu Date: Tue, 1 Oct 2019 19:00:42 -0700 Subject: [PATCH] Move one snapshotted data structure from ModelHistory to ModelExecution --- execution.h | 2 ++ history.cc | 26 +++++++++++++------------- history.h | 3 --- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/execution.h b/execution.h index 622f17aa..b35113fd 100644 --- a/execution.h +++ b/execution.h @@ -89,6 +89,7 @@ public: ModelAction * check_current_action(ModelAction *curr); SnapVector * get_thrd_func_list() { return &thrd_func_list; } + SnapVector * get_thrd_last_entered_func() { return &thrd_last_entered_func; } SnapVector< SnapList *> * 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 thrd_func_list; + SnapVector 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 diff --git a/history.cc b/history.cc index bf40312c..989a2afd 100644 --- a/history.cc +++ b/history.cc @@ -21,7 +21,6 @@ ModelHistory::ModelHistory() : write_history = new HashTable(); loc_func_nodes_map = new HashTable *, uintptr_t, 0>(); loc_wr_func_nodes_map = new HashTable *, uintptr_t, 0>(); - thrd_last_entered_func = new SnapVector(); loc_waiting_writes_map = new HashTable *, uintptr_t, 0>(); thrd_waiting_write = new SnapVector(); func_inst_act_maps = new HashTable *, 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 * thrd_func_list = model->get_execution()->get_thrd_func_list(); + SnapVector * thrd_func_list = execution->get_thrd_func_list(); SnapVector< SnapList *> * - thrd_func_act_lists = model->get_execution()->get_thrd_func_act_lists(); + thrd_func_act_lists = execution->get_thrd_func_act_lists(); + SnapVector * 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(); + 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 * 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 * thrd_func_list = model->get_execution()->get_thrd_func_list(); + SnapVector * thrd_func_list = execution->get_thrd_func_list(); SnapVector< SnapList *> * - thrd_func_act_lists = model->get_execution()->get_thrd_func_act_lists(); + thrd_func_act_lists = execution->get_thrd_func_act_lists(); SnapList * 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 * thrd_func_list = model->get_execution()->get_thrd_func_list(); + SnapVector * thrd_func_list = execution->get_thrd_func_list(); SnapVector< SnapList *> * - 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); } diff --git a/history.h b/history.h index a39850ba..ad72cdfa 100644 --- a/history.h +++ b/history.h @@ -65,9 +65,6 @@ private: /* Map a location to FuncNodes that may write to it */ HashTable *, uintptr_t, 0> * loc_wr_func_nodes_map; - /* Keeps track of the last function entered by each thread */ - SnapVector * thrd_last_entered_func; - HashTable *, uintptr_t, 0> * loc_waiting_writes_map; SnapVector * thrd_waiting_write; -- 2.34.1