action: add ModelAction::get_reads_from_value()
authorBrian Norris <banorris@uci.edu>
Fri, 1 Mar 2013 20:30:41 +0000 (12:30 -0800)
committerBrian Norris <banorris@uci.edu>
Fri, 1 Mar 2013 20:52:46 +0000 (12:52 -0800)
We can always get our 'read' value from reads_from or
reads_from_promise, so make it accessible via a function.

action.cc
action.h

index 0a6a1dd26665a6d553b4e0b7c258f519330bba56..e6a621be6ec4222b25190a52e7c5ebf97533bce6 100644 (file)
--- a/action.cc
+++ b/action.cc
@@ -378,6 +378,25 @@ void ModelAction::set_try_lock(bool obtainedlock) {
                value = VALUE_TRYFAILED;
 }
 
+/**
+ * @brief Get the value read by this load
+ *
+ * We differentiate this function from ModelAction::get_write_value and
+ * ModelAction::get_value for the purpose of RMW's, which may have both a
+ * 'read' and a 'write' value.
+ *
+ * Note: 'this' must be a load.
+ *
+ * @return The value read by this load
+ */
+uint64_t ModelAction::get_reads_from_value() const
+{
+       ASSERT(is_read());
+       if (reads_from)
+               return reads_from->get_write_value();
+       return reads_from_promise->get_value();
+}
+
 /** @return The Node associated with this ModelAction */
 Node * ModelAction::get_node() const
 {
@@ -511,10 +530,8 @@ void ModelAction::print() const
        }
 
        uint64_t valuetoprint;
-       if (is_read() && reads_from)
-               valuetoprint = reads_from->value;
-       else if (is_read() && reads_from_promise)
-               valuetoprint = reads_from_promise->get_value();
+       if (is_read())
+               valuetoprint = get_reads_from_value();
        else
                valuetoprint = value;
 
index 87939f8c73512e84496016a3fe399edede067907..8a3650b64c8e1ad8103d6767522a4aa36c56f879 100644 (file)
--- a/action.h
+++ b/action.h
@@ -80,6 +80,7 @@ public:
        void * get_location() const { return location; }
        modelclock_t get_seq_number() const { return seq_number; }
        uint64_t get_value() const { return value; }
+       uint64_t get_reads_from_value() const;
        const ModelAction * get_reads_from() const { return reads_from; }
        Promise * get_reads_from_promise() const { return reads_from_promise; }