X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;ds=sidebyside;f=cyclegraph.h;h=4a3d083d13c19fb897a29ebe2917af04f0990423;hb=84d49e8de1334a7dad25864c5ba8827de2502947;hp=f2f30329203c226c5a7a1c6140fa3043bb260613;hpb=6152f84e7a7326643981e14884764f250fa13ea8;p=c11tester.git diff --git a/cyclegraph.h b/cyclegraph.h index f2f30329..4a3d083d 100644 --- a/cyclegraph.h +++ b/cyclegraph.h @@ -24,9 +24,11 @@ class CycleGraph { public: CycleGraph(); ~CycleGraph(); - void addEdge(const ModelAction *from, const ModelAction *to); + + template + void addEdge(const T from, const U to); + bool checkForCycles() const; - bool checkForRMWViolation() const; void addRMWEdge(const ModelAction *from, const ModelAction *rmw); bool checkPromise(const ModelAction *from, Promise *p) const; bool checkReachable(const ModelAction *from, const ModelAction *to) const; @@ -40,54 +42,69 @@ class CycleGraph { SNAPSHOTALLOC private: + void addNodeEdge(CycleNode *fromnode, CycleNode *tonode); void putNode(const ModelAction *act, CycleNode *node); CycleNode * getNode(const ModelAction *); - HashTable *discovered; + CycleNode * getNode(const Promise *promise); + + HashTable *discovered; /** @brief A table for mapping ModelActions to CycleNodes */ HashTable actionToNode; + /** @brief A table for mapping reader ModelActions to Promise + * CycleNodes */ + HashTable readerToPromiseNode; + #if SUPPORT_MOD_ORDER_DUMP std::vector nodeList; #endif - bool checkReachable(CycleNode *from, CycleNode *to) const; + bool checkReachable(const CycleNode *from, const CycleNode *to) const; /** @brief A flag: true if this graph contains cycles */ bool hasCycles; bool oldCycles; - bool hasRMWViolation; - bool oldRMWViolation; - std::vector< CycleNode *, SnapshotAlloc > rollbackvector; std::vector< CycleNode *, SnapshotAlloc > rmwrollbackvector; }; -/** @brief A node within a CycleGraph; corresponds to one ModelAction */ +/** + * @brief A node within a CycleGraph; corresponds either to one ModelAction or + * to a promised future value + */ class CycleNode { public: CycleNode(const ModelAction *act); + CycleNode(const Promise *promise); bool addEdge(CycleNode *node); CycleNode * getEdge(unsigned int i) const; unsigned int getNumEdges() const; CycleNode * getBackEdge(unsigned int i) const; unsigned int getNumBackEdges() const; + CycleNode * removeEdge(); + CycleNode * removeBackEdge(); + bool setRMW(CycleNode *); CycleNode * getRMW() const; + void clearRMW() { hasRMW = NULL; } const ModelAction * getAction() const { return action; } void popEdge() { edges.pop_back(); } - void clearRMW() { - hasRMW = NULL; - } + + bool is_promise() const { return !action; } SNAPSHOTALLOC private: /** @brief The ModelAction that this node represents */ const ModelAction *action; + /** @brief The promise represented by this node; only valid when action + * is NULL */ + const Promise *promise; + /** @brief The edges leading out from this node */ std::vector< CycleNode *, SnapshotAlloc > edges;