X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=action.cc;h=893c812a1f39bd33f60a3b97291ffe9a525ae124;hb=745b71256a4b96ddf4843c7f66b11d0cb3daa3cb;hp=e6a621be6ec4222b25190a52e7c5ebf97533bce6;hpb=559511b7622dcbc48501f57b7adafb57aab5de3e;p=model-checker.git diff --git a/action.cc b/action.cc index e6a621b..893c812 100644 --- a/action.cc +++ b/action.cc @@ -394,7 +394,26 @@ 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(); + else if (reads_from_promise) + return reads_from_promise->get_value(); + return VALUE_NONE; /* Only for new actions with no reads-from */ +} + +/** + * @brief Get the value written by this store + * + * We differentiate this function from ModelAction::get_reads_from_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 store. + * + * @return The value written by this store + */ +uint64_t ModelAction::get_write_value() const +{ + ASSERT(is_write()); + return value; } /** @return The Node associated with this ModelAction */ @@ -532,6 +551,8 @@ void ModelAction::print() const uint64_t valuetoprint; if (is_read()) valuetoprint = get_reads_from_value(); + else if (is_write()) + valuetoprint = get_write_value(); else valuetoprint = value; @@ -592,3 +613,29 @@ unsigned int ModelAction::hash() const hash ^= reads_from->get_seq_number(); return hash; } + +/** + * @brief Checks the NodeStack to see if a ModelAction is in our may-read-from set + * @param write The ModelAction to check for + * @return True if the ModelAction is found; false otherwise + */ +bool ModelAction::may_read_from(const ModelAction *write) const +{ + for (int i = 0; i < node->get_read_from_past_size(); i++) + if (node->get_read_from_past(i) == write) + return true; + return false; +} + +/** + * @brief Checks the NodeStack to see if a Promise is in our may-read-from set + * @param promise The Promise to check for + * @return True if the Promise is found; false otherwise + */ +bool ModelAction::may_read_from(const Promise *promise) const +{ + for (int i = 0; i < node->get_read_from_promise_size(); i++) + if (node->get_read_from_promise(i) == promise) + return true; + return false; +}