From 7c7aa0f18e3cbeef89019a152b635cc4f3f4a46f Mon Sep 17 00:00:00 2001 From: weiyu Date: Thu, 27 Jun 2019 11:45:24 -0700 Subject: [PATCH] factor codes in history.* and move it to funcnode.* --- funcnode.cc | 13 +++++++++++++ funcnode.h | 30 ++++++++++++++++++++++++++++++ history.cc | 6 ------ history.h | 22 +++++----------------- 4 files changed, 48 insertions(+), 23 deletions(-) create mode 100644 funcnode.cc create mode 100644 funcnode.h diff --git a/funcnode.cc b/funcnode.cc new file mode 100644 index 00000000..3a545112 --- /dev/null +++ b/funcnode.cc @@ -0,0 +1,13 @@ +#include "funcnode.h" + +FuncInst::FuncInst(ModelAction *act) : + action(act) +{ + ASSERT(act); + this->position = act->get_position(); +} + +FuncNode::FuncNode() : + func_insts() +{} + diff --git a/funcnode.h b/funcnode.h new file mode 100644 index 00000000..03c92ef0 --- /dev/null +++ b/funcnode.h @@ -0,0 +1,30 @@ +#include "action.h" +#include "hashtable.h" + +class ModelAction; + +typedef ModelList action_mlist_t; +typedef SnapList func_id_list_t; + +class FuncInst { +public: + FuncInst(ModelAction *act); + ~FuncInst(); + + ModelAction * get_action() const { return action; } + const char * get_position() const { return position; } +private: + ModelAction * const action; + const char * position; +}; + +class FuncNode { +public: + FuncNode(); + ~FuncNode(); + + HashTable * getFuncInsts() { return &func_insts; } +private: + HashTable func_insts; +}; + diff --git a/history.cc b/history.cc index f757a5d7..4af57289 100644 --- a/history.cc +++ b/history.cc @@ -2,12 +2,6 @@ #include "history.h" #include "action.h" -HistoryNode::HistoryNode(ModelAction *act) : - action(act) -{ - ASSERT(act); - this->position = act->get_position(); -} /** @brief Constructor */ ModelHistory::ModelHistory() : diff --git a/history.h b/history.h index 03a89852..c8d2265f 100644 --- a/history.h +++ b/history.h @@ -9,18 +9,6 @@ class ModelAction; typedef ModelList action_mlist_t; typedef SnapList func_id_list_t; -class HistoryNode { -public: - HistoryNode(ModelAction *act); - ~HistoryNode(); - - ModelAction * get_action() const { return action; } - const char * get_position() const { return position; } -private: - ModelAction * const action; - const char * position; -}; - class ModelHistory { public: ModelHistory(); @@ -29,20 +17,20 @@ public: void enter_function(const uint32_t func_id, thread_id_t tid); void exit_function(const uint32_t func_id, thread_id_t tid); - uint32_t get_func_counter() { return func_counter; } - void incr_func_counter() { func_counter++; } + uint32_t get_func_counter() { return func_counter; } + void incr_func_counter() { func_counter++; } void add_func_atomic(ModelAction *act, thread_id_t tid); - HashTable * getFuncMap() { return &func_map; } + HashTable * getFuncMap() { return &func_map; } ModelVector< action_mlist_t * > * getFuncAtomics() { return &func_atomics; } void print(); private: uint32_t func_counter; - /* map function names to integer ids */ - HashTable func_map; + /* map function names to integer ids */ + HashTable func_map; ModelVector< action_mlist_t * > func_atomics; -- 2.34.1