X-Git-Url: http://plrg.eecs.uci.edu/git/?p=c11tester.git;a=blobdiff_plain;f=action.cc;h=4cdca0d7a7272b2f4c6eef265ef34ca613bc0c3f;hp=ec7332dc696dc6221628e9139e004b59e8ac8d4d;hb=7d107019dd0d32d0803fb802fc318a57101707a1;hpb=01ffef59b0692d6f43f4094372f0d70b71b0abd4 diff --git a/action.cc b/action.cc index ec7332dc..4cdca0d7 100644 --- a/action.cc +++ b/action.cc @@ -36,11 +36,8 @@ ModelAction::ModelAction(action_type_t type, memory_order order, void *loc, position(NULL), reads_from(NULL), last_fence_release(NULL), - uninitaction(NULL), cv(NULL), rf_cv(NULL), - trace_ref(NULL), - thrdmap_ref(NULL), action_ref(NULL), value(value), type(type), @@ -49,7 +46,7 @@ ModelAction::ModelAction(action_type_t type, memory_order order, void *loc, seq_number(ACTION_INITIAL_CLOCK) { /* References to NULL atomic variables can end up here */ - ASSERT(loc || type == ATOMIC_FENCE); + ASSERT(loc || type == ATOMIC_FENCE || type == ATOMIC_NOP); Thread *t = thread ? thread : thread_current(); this->tid = t!= NULL ? t->get_id() : -1; @@ -71,11 +68,8 @@ ModelAction::ModelAction(action_type_t type, memory_order order, uint64_t value, position(NULL), time(_time), last_fence_release(NULL), - uninitaction(NULL), cv(NULL), rf_cv(NULL), - trace_ref(NULL), - thrdmap_ref(NULL), action_ref(NULL), value(value), type(type), @@ -105,11 +99,8 @@ ModelAction::ModelAction(action_type_t type, memory_order order, void *loc, position(NULL), reads_from(NULL), last_fence_release(NULL), - uninitaction(NULL), cv(NULL), rf_cv(NULL), - trace_ref(NULL), - thrdmap_ref(NULL), action_ref(NULL), value(value), type(type), @@ -120,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(); } @@ -143,11 +133,8 @@ ModelAction::ModelAction(action_type_t type, const char * position, memory_order position(position), reads_from(NULL), last_fence_release(NULL), - uninitaction(NULL), cv(NULL), rf_cv(NULL), - trace_ref(NULL), - thrdmap_ref(NULL), action_ref(NULL), value(value), type(type), @@ -158,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(); } @@ -182,11 +168,8 @@ ModelAction::ModelAction(action_type_t type, const char * position, memory_order position(position), reads_from(NULL), last_fence_release(NULL), - uninitaction(NULL), cv(NULL), rf_cv(NULL), - trace_ref(NULL), - thrdmap_ref(NULL), action_ref(NULL), value(value), type(type), @@ -212,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 { @@ -228,8 +213,6 @@ void ModelAction::copy_from_new(ModelAction *newaction) void ModelAction::set_seq_number(modelclock_t num) { - /* ATOMIC_UNINIT actions should never have non-zero clock */ - ASSERT(!is_uninitialized()); ASSERT(seq_number == ACTION_INITIAL_CLOCK); seq_number = num; } @@ -302,11 +285,6 @@ bool ModelAction::is_atomic_var() const return is_read() || could_be_write(); } -bool ModelAction::is_uninitialized() const -{ - return type == ATOMIC_UNINIT; -} - bool ModelAction::is_read() const { return type == ATOMIC_READ || type == ATOMIC_RMWR || type == ATOMIC_RMWRCAS || type == ATOMIC_RMW; @@ -314,7 +292,17 @@ bool ModelAction::is_read() const bool ModelAction::is_write() const { - return type == ATOMIC_WRITE || type == ATOMIC_RMW || type == ATOMIC_INIT || type == ATOMIC_UNINIT || type == NONATOMIC_WRITE; + return type == ATOMIC_WRITE || type == ATOMIC_RMW || type == ATOMIC_INIT || type == NONATOMIC_WRITE; +} + +bool ModelAction::is_create() const +{ + return type == THREAD_CREATE || type == PTHREAD_CREATE; +} + +bool ModelAction::is_free() const +{ + return type == READY_FREE; } bool ModelAction::could_be_write() const @@ -643,19 +631,6 @@ void ModelAction::set_read_from(ModelAction *act) ASSERT(act); reads_from = act; - if (act->is_uninitialized()) { // WL - uint64_t val = *((uint64_t *) location); - ModelAction * act_uninitialized = (ModelAction *)act; - act_uninitialized->set_value(val); - reads_from = act_uninitialized; - -// disabled by WL, because LLVM IR is unable to detect atomic init -/* model->assert_bug("May read from uninitialized atomic:\n" - " action %d, thread %d, location %p (%s, %s)", - seq_number, id_to_int(tid), location, - get_type_str(), get_mo_str()); - */ - } } /** @@ -702,7 +677,6 @@ const char * ModelAction::get_type_str() const case PTHREAD_CREATE: return "pthread create"; case PTHREAD_JOIN: return "pthread join"; - case ATOMIC_UNINIT: return "uninitialized"; case NONATOMIC_WRITE: return "nonatomic write"; case ATOMIC_READ: return "atomic read"; case ATOMIC_WRITE: return "atomic write"; @@ -744,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