nodestack: move "behaviors" increment all into Node wrapper function
authorBrian Norris <banorris@uci.edu>
Thu, 28 Mar 2013 22:27:17 +0000 (15:27 -0700)
committerBrian Norris <banorris@uci.edu>
Thu, 28 Mar 2013 22:27:17 +0000 (15:27 -0700)
model.cc
nodestack.cc
nodestack.h

index 879f1de..0423c6e 100644 (file)
--- a/model.cc
+++ b/model.cc
@@ -260,20 +260,8 @@ Thread * ModelChecker::get_next_thread()
                scheduler->update_sleep_set(prevnode);
 
                /* Reached divergence point */
-               if (nextnode->increment_misc()) {
-                       /* The next node will try to satisfy a different misc_index values. */
-                       tid = next->get_tid();
-                       node_stack->pop_restofstack(2);
-               } else if (nextnode->increment_promise()) {
-                       /* The next node will try to satisfy a different set of promises. */
-                       tid = next->get_tid();
-                       node_stack->pop_restofstack(2);
-               } else if (nextnode->increment_read_from()) {
-                       /* The next node will read from a different value. */
-                       tid = next->get_tid();
-                       node_stack->pop_restofstack(2);
-               } else if (nextnode->increment_relseq_break()) {
-                       /* The next node will try to resolve a release sequence differently */
+               if (nextnode->increment_behaviors()) {
+                       /* Execute the same thread with a new behavior */
                        tid = next->get_tid();
                        node_stack->pop_restofstack(2);
                } else {
index 2fa8784..f46e4b7 100644 (file)
@@ -726,6 +726,27 @@ bool Node::relseq_break_empty() const
 
 /******************* end breaking release sequences ***************************/
 
+/**
+ * Increments some behavior's index, if a new behavior is available
+ * @return True if there is a new behavior available; otherwise false
+ */
+bool Node::increment_behaviors()
+{
+       /* satisfy a different misc_index values */
+       if (increment_misc())
+               return true;
+       /* satisfy a different set of promises */
+       if (increment_promise())
+               return true;
+       /* read from a different value */
+       if (increment_read_from())
+               return true;
+       /* resolve a release sequence differently */
+       if (increment_relseq_break())
+               return true;
+       return false;
+}
+
 NodeStack::NodeStack() :
        node_list(),
        head_idx(-1),
index 99374a3..8573e9f 100644 (file)
@@ -112,6 +112,8 @@ public:
        bool increment_relseq_break();
        bool relseq_break_empty() const;
 
+       bool increment_behaviors();
+
        void print() const;
 
        MEMALLOC