From 0884e7116f8ffbbba7f22735b55d0b93a697077a Mon Sep 17 00:00:00 2001 From: weiyu Date: Mon, 5 Aug 2019 15:39:02 -0700 Subject: [PATCH] move the codes that add actions to thrd_func_act_lists from history.cc to ModelExecution::add_action_to_lists --- execution.cc | 11 ++++++++++- execution.h | 2 -- history.cc | 24 +++++++----------------- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/execution.cc b/execution.cc index 70261b0f..f978cd4c 100644 --- a/execution.cc +++ b/execution.cc @@ -1164,6 +1164,15 @@ void ModelExecution::add_action_to_lists(ModelAction *act) } (*vec)[tid].push_back(act); } + + /* Update thrd_func_act_lists, list of actions in functions entered by each thread + * To be used by FuncNode and only care about actions with a position */ + if (act->get_position() != NULL) { + SnapList * func_act_lists = thrd_func_act_lists[tid]; + action_list_t * curr_act_list = func_act_lists->back(); + ASSERT(curr_act_list != NULL); + curr_act_list->push_back(act); + } } void insertIntoActionList(action_list_t *list, ModelAction *act) { @@ -1661,7 +1670,7 @@ Thread * ModelExecution::take_step(ModelAction *curr) curr = check_current_action(curr); ASSERT(curr); - /* Process this action in ModelHistory for records*/ + /* Process this action in ModelHistory for records */ model->get_history()->process_action( curr, curr->get_tid() ); if (curr_thrd->is_blocked() || curr_thrd->is_complete()) diff --git a/execution.h b/execution.h index 343a5074..a6add070 100644 --- a/execution.h +++ b/execution.h @@ -210,8 +210,6 @@ private: /* Keeps track of atomic actions that thread i has performed in some * function. Index of SnapVector is thread id. SnapList simulates * the call stack. - * - * This data structure is handled by ModelHistory */ SnapVector< SnapList *> thrd_func_act_lists; bool isfinished; diff --git a/history.cc b/history.cc index 283c248f..782da5a3 100644 --- a/history.cc +++ b/history.cc @@ -21,7 +21,7 @@ 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); - uint32_t id = id_to_int(tid); + uint id = id_to_int(tid); SnapVector * thrd_func_list = model->get_execution()->get_thrd_func_list(); SnapVector< SnapList *> * thrd_func_act_lists = model->get_execution()->get_thrd_func_act_lists(); @@ -30,20 +30,18 @@ void ModelHistory::enter_function(const uint32_t func_id, thread_id_t tid) uint oldsize = thrd_func_list->size(); thrd_func_list->resize( id + 1 ); for (uint i = oldsize; i < id + 1; i++) { - new(&(*thrd_func_list)[i]) func_id_list_t(); + new (&(*thrd_func_list)[i]) func_id_list_t(); // push 0 as a dummy function id to a void seg fault (*thrd_func_list)[i].push_back(0); } thrd_func_act_lists->resize( id + 1 ); + for (uint i = oldsize; i < id + 1; i++) { + (*thrd_func_act_lists)[i] = new SnapList(); + } } - SnapList * func_act_lists = thrd_func_act_lists->at(id); - - if (func_act_lists == NULL) { - func_act_lists = new SnapList(); - thrd_func_act_lists->at(id) = func_act_lists; - } + SnapList * func_act_lists = (*thrd_func_act_lists)[id]; (*thrd_func_list)[id].push_back(func_id); func_act_lists->push_back( new action_list_t() ); @@ -60,7 +58,7 @@ void ModelHistory::exit_function(const uint32_t func_id, thread_id_t tid) SnapVector< SnapList *> * thrd_func_act_lists = model->get_execution()->get_thrd_func_act_lists(); - SnapList * func_act_lists = thrd_func_act_lists->at(id); + SnapList * func_act_lists = (*thrd_func_act_lists)[id]; uint32_t last_func_id = (*thrd_func_list)[id].back(); if (last_func_id == func_id) { @@ -101,8 +99,6 @@ void ModelHistory::process_action(ModelAction *act, thread_id_t tid) /* 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< SnapList *> * - thrd_func_act_lists = model->get_execution()->get_thrd_func_act_lists(); uint32_t id = id_to_int(tid); if ( thrd_func_list->size() <= id ) @@ -110,7 +106,6 @@ void ModelHistory::process_action(ModelAction *act, thread_id_t tid) /* get the function id that thread i is currently in */ uint32_t func_id = (*thrd_func_list)[id].back(); - SnapList * func_act_lists = thrd_func_act_lists->at(id); if (func_id == 0) return; @@ -129,11 +124,6 @@ void ModelHistory::process_action(ModelAction *act, thread_id_t tid) if (act->is_write()) add_to_write_history(act->get_location(), act->get_write_value()); - - /* add to curr_inst_list */ - action_list_t * curr_act_list = func_act_lists->back(); - ASSERT(curr_act_list != NULL); - curr_act_list->push_back(act); } /* return the FuncNode given its func_id */ -- 2.34.1