From: Brian Norris Date: Fri, 1 Feb 2013 23:27:32 +0000 (-0800) Subject: action: store Promise in ModelAction X-Git-Tag: oopsla2013~301 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=model-checker.git;a=commitdiff_plain;h=7f0963612d33cd3c1e1330bb42c9962259a03da3 action: store Promise in ModelAction --- diff --git a/action.cc b/action.cc index bb2b282..13da2b9 100644 --- a/action.cc +++ b/action.cc @@ -393,10 +393,22 @@ Node * ModelAction::get_node() const void ModelAction::set_read_from(const ModelAction *act) { reads_from = act; + reads_from_promise = NULL; if (act && act->is_uninitialized()) model->assert_bug("May read from uninitialized atomic\n"); } +/** + * Set this action's read-from promise + * @param promise The promise to read from + */ +void ModelAction::set_read_from_promise(const Promise *promise) +{ + ASSERT(is_read()); + reads_from_promise = promise; + reads_from = NULL; +} + /** * Synchronize the current thread with the thread corresponding to the * ModelAction parameter. diff --git a/action.h b/action.h index d0f02a3..2647b97 100644 --- a/action.h +++ b/action.h @@ -15,6 +15,7 @@ class ClockVector; class Thread; +class Promise; using std::memory_order; using std::memory_order_relaxed; @@ -79,13 +80,14 @@ public: void * get_location() const { return location; } modelclock_t get_seq_number() const { return seq_number; } uint64_t get_value() const { return value; } - void set_value(uint64_t v) { value = v; } const ModelAction * get_reads_from() const { return reads_from; } + const Promise * get_reads_from_promise() const { return reads_from_promise; } Node * get_node() const; void set_node(Node *n) { node = n; } void set_read_from(const ModelAction *act); + void set_read_from_promise(const Promise *promise); /** Store the most recent fence-release from the same thread * @param fence The fence-release that occured prior to this */ @@ -170,6 +172,9 @@ private: /** The action that this action reads from. Only valid for reads */ const ModelAction *reads_from; + /** The promise that this action reads from. Only valid for reads */ + const Promise *reads_from_promise; + /** The last fence release from the same thread */ const ModelAction *last_fence_release; diff --git a/model.cc b/model.cc index e39266d..cb78f03 100644 --- a/model.cc +++ b/model.cc @@ -735,10 +735,10 @@ bool ModelChecker::process_read(ModelAction *curr, bool second_part_of_rmw) } else if (!second_part_of_rmw) { /* Read from future value */ struct future_value fv = curr->get_node()->get_future_value(); + Promise *promise = new Promise(curr, fv); value = fv.value; - curr->set_value(fv.value); - curr->set_read_from(NULL); - promises->push_back(new Promise(curr, fv)); + curr->set_read_from_promise(promise); + promises->push_back(promise); } get_thread(curr)->set_return_value(value); return updated;