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 bb2b282a67a9c5aa3852d57c7936b438fc3688d1..13da2b96312f0ee9c524b04fb13f0fcc997697b5 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;
 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");
 }
 
        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.
 /**
  * Synchronize the current thread with the thread corresponding to the
  * ModelAction parameter.
index d0f02a327e6d8373d35b2d56c3dd250a40aa948b..2647b977c23665997fa703404a8401d61b776ad6 100644 (file)
--- a/action.h
+++ b/action.h
@@ -15,6 +15,7 @@
 
 class ClockVector;
 class Thread;
 
 class ClockVector;
 class Thread;
+class Promise;
 
 using std::memory_order;
 using std::memory_order_relaxed;
 
 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 * 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 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);
 
        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 */
 
        /** 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 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;
 
        /** The last fence release from the same thread */
        const ModelAction *last_fence_release;
 
index e39266d41218feecb14d4fde94701c22cd2040d3..cb78f030a3ff3d730d11e6748935797d0aee4d59 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();
                } 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;
                        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;
                }
                get_thread(curr)->set_return_value(value);
                return updated;