From: Brian Norris Date: Fri, 1 Mar 2013 20:30:41 +0000 (-0800) Subject: action: add ModelAction::get_reads_from_value() X-Git-Url: http://plrg.eecs.uci.edu/git/?p=c11tester.git;a=commitdiff_plain;h=559511b7622dcbc48501f57b7adafb57aab5de3e action: add ModelAction::get_reads_from_value() We can always get our 'read' value from reads_from or reads_from_promise, so make it accessible via a function. --- diff --git a/action.cc b/action.cc index 0a6a1dd2..e6a621be 100644 --- 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; diff --git a/action.h b/action.h index 87939f8c..8a3650b6 100644 --- 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; }