small changes
[c11tester.git] / newfuzzer.h
index c70960e7cf3db0b46d0f85c1210379e40ad7530b..26fab3f6c2fff4e0ed995e4d68a8dd7733ecb5f5 100644 (file)
@@ -5,29 +5,66 @@
 #include "classlist.h"
 #include "mymemory.h"
 #include "stl-model.h"
+#include "predicate.h"
+
+struct node_dist_info {
+       node_dist_info(thread_id_t tid, FuncNode * node, int distance) :
+               tid(tid),
+               target(node),
+               dist(distance)
+       {}
+
+       thread_id_t tid;
+       FuncNode * target;
+       int dist;
+
+       SNAPSHOTALLOC
+};
 
 class NewFuzzer : public Fuzzer {
 public:
        NewFuzzer();
        int selectWrite(ModelAction *read, SnapVector<ModelAction *>* rf_set);
-       void selectBranch(int thread_id, Predicate * curr_pred, FuncInst * read_inst);
-       Predicate * get_selected_child_branch(thread_id_t tid);
+       bool has_paused_threads();
+       void notify_paused_thread(Thread * thread);
 
        Thread * selectThread(int * threadlist, int numthreads);
-       Thread * selectNotify(action_list_t * waiters);
-       bool shouldSleep(const ModelAction *sleep);
-       bool shouldWake(const ModelAction *sleep);
+       Thread * selectNotify(simple_action_list_t * waiters);
+       bool shouldSleep(const ModelAction * sleep);
+       bool shouldWake(const ModelAction * sleep);
+       bool shouldWait(const ModelAction * wait);
 
-       void register_engine(ModelHistory * history, ModelExecution * execution);
+       void register_engine(ModelChecker * model, ModelExecution * execution);
+       Predicate * get_selected_child_branch(thread_id_t tid);
 
-       MEMALLOC
+       SNAPSHOTALLOC
 private:
        ModelHistory * history;
        ModelExecution * execution;
 
        SnapVector<ModelAction *> thrd_last_read_act;
-       SnapVector<Predicate *> thrd_curr_pred;
+       SnapVector<FuncInst *> thrd_last_func_inst;
+
+       SnapVector<Predicate *> available_branches_tmp_storage;
        SnapVector<Predicate *> thrd_selected_child_branch;
+       SnapVector< SnapVector<ModelAction *> *> thrd_pruned_writes;
+
+       bool check_branch_inst(Predicate * curr_pred, FuncInst * read_inst, SnapVector<ModelAction *> * rf_set);
+       Predicate * selectBranch(thread_id_t tid, Predicate * curr_pred, FuncInst * read_inst);
+       bool prune_writes(thread_id_t tid, Predicate * pred, SnapVector<ModelAction *> * rf_set);
+       int choose_branch_index(SnapVector<Predicate *> * branches);
+
+       /* The set of Threads put to sleep by NewFuzzer because no writes in rf_set satisfies the selected predicate. Only used by selectWrite.
+        */
+       SnapVector<Thread *> paused_thread_list;        //-- (not in use)
+       HashTable<Thread *, int, uintptr_t, 0> paused_thread_table;     //--
+
+       SnapVector<struct node_dist_info> dist_info_vec;        //--
+
+       void conditional_sleep(Thread * thread);        //--
+       void wake_up_paused_threads(int * threadlist, int * numthreads);        //--
+
+       bool find_threads(ModelAction * pending_read);  //--
 };
 
-#endif /* end of __NEWFUZZER_H__ */
+#endif /* end of __NEWFUZZER_H__ */