Find a faster way to get currently executing thread's id
[c11tester.git] / action.cc
index 89a61b74ad02284768359ec8cc07a9f51f4898bd..4cdca0d7a7272b2f4c6eef265ef34ca613bc0c3f 100644 (file)
--- a/action.cc
+++ b/action.cc
@@ -38,14 +38,9 @@ ModelAction::ModelAction(action_type_t type, memory_order order, void *loc,
        last_fence_release(NULL),
        cv(NULL),
        rf_cv(NULL),
-       trace_ref(NULL),
-       thrdmap_ref(NULL),
        action_ref(NULL),
-       func_act_ref(NULL),
        value(value),
        type(type),
-       original_type(ATOMIC_NOP),
-       swap_flag(false),
        order(order),
        original_order(order),
        seq_number(ACTION_INITIAL_CLOCK)
@@ -75,14 +70,9 @@ ModelAction::ModelAction(action_type_t type, memory_order order, uint64_t value,
        last_fence_release(NULL),
        cv(NULL),
        rf_cv(NULL),
-       trace_ref(NULL),
-       thrdmap_ref(NULL),
        action_ref(NULL),
-       func_act_ref(NULL),
        value(value),
        type(type),
-       original_type(ATOMIC_NOP),
-       swap_flag(false),
        order(order),
        original_order(order),
        seq_number(ACTION_INITIAL_CLOCK)
@@ -111,14 +101,9 @@ ModelAction::ModelAction(action_type_t type, memory_order order, void *loc,
        last_fence_release(NULL),
        cv(NULL),
        rf_cv(NULL),
-       trace_ref(NULL),
-       thrdmap_ref(NULL),
        action_ref(NULL),
-       func_act_ref(NULL),
        value(value),
        type(type),
-       original_type(ATOMIC_NOP),
-       swap_flag(false),
        order(order),
        original_order(order),
        seq_number(ACTION_INITIAL_CLOCK)
@@ -126,8 +111,7 @@ ModelAction::ModelAction(action_type_t type, memory_order order, void *loc,
        /* References to NULL atomic variables can end up here */
        ASSERT(loc);
        this->size = size;
-       Thread *t = thread_current();
-       this->tid = t->get_id();
+       this->tid = thread_current_id();
 }
 
 
@@ -151,14 +135,9 @@ ModelAction::ModelAction(action_type_t type, const char * position, memory_order
        last_fence_release(NULL),
        cv(NULL),
        rf_cv(NULL),
-       trace_ref(NULL),
-       thrdmap_ref(NULL),
        action_ref(NULL),
-       func_act_ref(NULL),
        value(value),
        type(type),
-       original_type(ATOMIC_NOP),
-       swap_flag(false),
        order(order),
        original_order(order),
        seq_number(ACTION_INITIAL_CLOCK)
@@ -166,8 +145,7 @@ ModelAction::ModelAction(action_type_t type, const char * position, memory_order
        /* References to NULL atomic variables can end up here */
        ASSERT(loc);
        this->size = size;
-       Thread *t = thread_current();
-       this->tid = t->get_id();
+       this->tid = thread_current_id();
 }
 
 
@@ -192,14 +170,9 @@ ModelAction::ModelAction(action_type_t type, const char * position, memory_order
        last_fence_release(NULL),
        cv(NULL),
        rf_cv(NULL),
-       trace_ref(NULL),
-       thrdmap_ref(NULL),
        action_ref(NULL),
-       func_act_ref(NULL),
        value(value),
        type(type),
-       original_type(ATOMIC_NOP),
-       swap_flag(false),
        order(order),
        original_order(order),
        seq_number(ACTION_INITIAL_CLOCK)
@@ -222,9 +195,11 @@ ModelAction::~ModelAction()
         * vectors which have already been rolled back to an unallocated state.
         */
 
-       /*
-          if (cv)
-               delete cv; */
+
+       if (cv)
+               delete cv;
+       if (rf_cv)
+               delete rf_cv;
 }
 
 int ModelAction::getSize() const {
@@ -743,6 +718,9 @@ void ModelAction::print() const
        model_print("%-4d %-2d   %-14s  %7s  %14p   %-#18" PRIx64,
                                                        seq_number, id_to_int(tid), type_str, mo_str, location, get_return_value());
        if (is_read()) {
+               if (is_write()) {
+                       model_print("(%" PRIx64 ")", get_write_value());
+               }
                if (reads_from)
                        model_print("  %-3d", reads_from->get_seq_number());
                else
@@ -787,16 +765,3 @@ cdsc::mutex * ModelAction::get_mutex() const
        else
                return NULL;
 }
-
-/** @brief Swap type with original type */
-void ModelAction::use_original_type()
-{
-       action_type_t tmp = type;
-       type = original_type;
-       original_type = tmp;
-
-       if (swap_flag)
-               swap_flag = false;
-       else
-               swap_flag = true;
-}