X-Git-Url: http://plrg.eecs.uci.edu/git/?p=model-checker.git;a=blobdiff_plain;f=cyclegraph.h;h=25401d9a3d349d07f6c4b11fe4a140e041f82394;hp=a9e46120f1f3efac17efacb9a608abca451868d4;hb=0dc4895e7c40b9588d5ece94cba09e2fe2af420d;hpb=5d0c8be1e7d652a85d36827074f4c72661e7457f diff --git a/cyclegraph.h b/cyclegraph.h index a9e4612..25401d9 100644 --- a/cyclegraph.h +++ b/cyclegraph.h @@ -9,9 +9,11 @@ #ifndef __CYCLEGRAPH_H__ #define __CYCLEGRAPH_H__ -#include "hashtable.h" #include #include +#include + +#include "hashtable.h" #include "config.h" #include "mymemory.h" @@ -28,7 +30,7 @@ class CycleGraph { ~CycleGraph(); template - bool addEdge(const T from, const U to); + bool addEdge(const T *from, const U *to); template void addRMWEdge(const T *from, const ModelAction *rmw); @@ -36,8 +38,8 @@ class CycleGraph { bool checkForCycles() const; bool checkPromise(const ModelAction *from, Promise *p) const; - template - bool checkReachable(const ModelAction *from, const T *to) const; + template + bool checkReachable(const T *from, const U *to) const; void startChanges(); void commitChanges(); @@ -45,32 +47,37 @@ class CycleGraph { #if SUPPORT_MOD_ORDER_DUMP void dumpNodes(FILE *file) const; void dumpGraphToFile(const char *filename) const; + + void dot_print_node(FILE *file, const ModelAction *act); + template + void dot_print_edge(FILE *file, const T *from, const U *to, const char *prop); #endif - bool resolvePromise(ModelAction *reader, ModelAction *writer, - promise_list_t *mustResolve); + bool resolvePromise(const Promise *promise, ModelAction *writer); SNAPSHOTALLOC private: bool addNodeEdge(CycleNode *fromnode, CycleNode *tonode); void putNode(const ModelAction *act, CycleNode *node); + void putNode(const Promise *promise, CycleNode *node); + void erasePromiseNode(const Promise *promise); CycleNode * getNode(const ModelAction *act); CycleNode * getNode(const Promise *promise); CycleNode * getNode_noCreate(const ModelAction *act) const; CycleNode * getNode_noCreate(const Promise *promise) const; - bool mergeNodes(CycleNode *node1, CycleNode *node2, - promise_list_t *mustMerge); + bool mergeNodes(CycleNode *node1, CycleNode *node2); HashTable *discovered; + std::vector< const CycleNode *, ModelAlloc > * queue; + /** @brief A table for mapping ModelActions to CycleNodes */ HashTable actionToNode; - /** @brief A table for mapping reader ModelActions to Promise - * CycleNodes */ - HashTable readerToPromiseNode; + /** @brief A table for mapping Promises to CycleNodes */ + HashTable promiseToNode; #if SUPPORT_MOD_ORDER_DUMP - std::vector nodeList; + std::vector< CycleNode *, SnapshotAlloc > nodeList; #endif bool checkReachable(const CycleNode *from, const CycleNode *to) const; @@ -127,47 +134,4 @@ class CycleNode { CycleNode *hasRMW; }; -/* - * @brief Adds an edge between objects - * - * This function will add an edge between any two objects which can be - * associated with a CycleNode. That is, if they have a CycleGraph::getNode - * implementation. - * - * The object to is ordered after the object from. - * - * @param to The edge points to this object, of type T - * @param from The edge comes from this object, of type U - * @return True, if new edge(s) are added; otherwise false - */ -template -bool CycleGraph::addEdge(const T from, const U to) -{ - ASSERT(from); - ASSERT(to); - - CycleNode *fromnode = getNode(from); - CycleNode *tonode = getNode(to); - - return addNodeEdge(fromnode, tonode); -} - -/** - * Checks whether one ModelAction can reach another ModelAction/Promise - * @param from The ModelAction from which to begin exploration - * @param to The ModelAction or Promise to reach - * @return True, @a from can reach @a to; otherwise, false - */ -template -bool CycleGraph::checkReachable(const ModelAction *from, const T *to) const -{ - CycleNode *fromnode = getNode_noCreate(from); - CycleNode *tonode = getNode_noCreate(to); - - if (!fromnode || !tonode) - return false; - - return checkReachable(fromnode, tonode); -} - #endif /* __CYCLEGRAPH_H__ */