action: store Promise in ModelAction
authorBrian Norris <banorris@uci.edu>
Fri, 1 Feb 2013 23:27:32 +0000 (15:27 -0800)
committerBrian Norris <banorris@uci.edu>
Wed, 6 Feb 2013 21:44:38 +0000 (13:44 -0800)
action.cc
action.h
model.cc

index bb2b282..13da2b9 100644 (file)
--- 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.
index d0f02a3..2647b97 100644 (file)
--- 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;
 
index e39266d..cb78f03 100644 (file)
--- 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;