Revert "switch to snapshot/modelalloc versions of stl classes"
authorBrian Norris <banorris@uci.edu>
Thu, 7 Mar 2013 22:56:22 +0000 (14:56 -0800)
committerBrian Norris <banorris@uci.edu>
Thu, 7 Mar 2013 22:56:22 +0000 (14:56 -0800)
This reverts commit 7524803854c2de38c0311fe5037e3c17105ccfaa.

It was missing a lot of conversions, and I did duplicate work. So I'll
just check in my changes instead.

cyclegraph.cc
cyclegraph.h
model.cc
model.h
nodestack.h
stl_wrappers.h [deleted file]
workqueue.h

index 20623347213d0958bfdff79d142595420461b015..e96549ff1fddcace369f57102572edf2c6bf9c32 100644 (file)
@@ -8,7 +8,7 @@
 /** Initializes a CycleGraph object. */
 CycleGraph::CycleGraph() :
        discovered(new HashTable<const CycleNode *, const CycleNode *, uintptr_t, 4, model_malloc, model_calloc, model_free>(16)),
-       queue(new model_vector< const CycleNode * >()),
+       queue(new std::vector< const CycleNode *, ModelAlloc<const CycleNode *> >()),
        hasCycles(false),
        oldCycles(false)
 {
index d5c6a92af78715de0ff4f2c323a578b7a43f6ff1..25401d9a3d349d07f6c4b11fe4a140e041f82394 100644 (file)
@@ -9,7 +9,7 @@
 #ifndef __CYCLEGRAPH_H__
 #define __CYCLEGRAPH_H__
 
-#include "stl_wrappers.h"
+#include <vector>
 #include <inttypes.h>
 #include <stdio.h>
 
@@ -21,7 +21,7 @@ class Promise;
 class CycleNode;
 class ModelAction;
 
-typedef model_vector< const Promise * > promise_list_t;
+typedef std::vector< const Promise *, ModelAlloc<const Promise *> > promise_list_t;
 
 /** @brief A graph of Model Actions for tracking cycles. */
 class CycleGraph {
@@ -68,7 +68,7 @@ class CycleGraph {
        bool mergeNodes(CycleNode *node1, CycleNode *node2);
 
        HashTable<const CycleNode *, const CycleNode *, uintptr_t, 4, model_malloc, model_calloc, model_free> *discovered;
-       model_vector< const CycleNode * > * queue;
+       std::vector< const CycleNode *, ModelAlloc<const CycleNode *> > * queue;
 
 
        /** @brief A table for mapping ModelActions to CycleNodes */
index f492af30d35b39ac00fbb080184cb6ec11b523f7..0122922d376ca03a742f03729585f3c48db7b09a 100644 (file)
--- a/model.cc
+++ b/model.cc
@@ -85,12 +85,12 @@ ModelChecker::ModelChecker(struct model_params params) :
        obj_map(new HashTable<const void *, action_list_t *, uintptr_t, 4>()),
        lock_waiters_map(new HashTable<const void *, action_list_t *, uintptr_t, 4>()),
        condvar_waiters_map(new HashTable<const void *, action_list_t *, uintptr_t, 4>()),
-       obj_thrd_map(new HashTable<void *, snap_vector<action_list_t> *, uintptr_t, 4 >()),
-       promises(new snap_vector< Promise * >()),
-       futurevalues(new snap_vector< struct PendingFutureValue >()),
-       pending_rel_seqs(new snap_vector< struct release_seq * >()),
-       thrd_last_action(new snap_vector< ModelAction * >(1)),
-       thrd_last_fence_release(new snap_vector< ModelAction * >()),
+       obj_thrd_map(new HashTable<void *, std::vector<action_list_t> *, uintptr_t, 4 >()),
+       promises(new std::vector< Promise *, SnapshotAlloc<Promise *> >()),
+       futurevalues(new std::vector< struct PendingFutureValue, SnapshotAlloc<struct PendingFutureValue> >()),
+       pending_rel_seqs(new std::vector< struct release_seq *, SnapshotAlloc<struct release_seq *> >()),
+       thrd_last_action(new std::vector< ModelAction *, SnapshotAlloc<ModelAction *> >(1)),
+       thrd_last_fence_release(new std::vector< ModelAction *, SnapshotAlloc<ModelAction *> >()),
        node_stack(new NodeStack()),
        priv(new struct model_snapshot_members()),
        mo_graph(new CycleGraph())
@@ -137,11 +137,11 @@ static action_list_t * get_safe_ptr_action(HashTable<const void *, action_list_t
        return tmp;
 }
 
-static snap_vector<action_list_t> * get_safe_ptr_vect_action(HashTable<void *, snap_vector<action_list_t> *, uintptr_t, 4> * hash, void * ptr)
+static std::vector<action_list_t> * get_safe_ptr_vect_action(HashTable<void *, std::vector<action_list_t> *, uintptr_t, 4> * hash, void * ptr)
 {
-       snap_vector<action_list_t> *tmp = hash->get(ptr);
+       std::vector<action_list_t> *tmp = hash->get(ptr);
        if (tmp == NULL) {
-               tmp = new snap_vector<action_list_t>();
+               tmp = new std::vector<action_list_t>();
                hash->put(ptr, tmp);
        }
        return tmp;
@@ -1704,7 +1704,7 @@ bool ModelChecker::should_read_instead(const ModelAction *curr, const T *rf, con
        if (!mo_graph->checkReachable(rf, other_rf))
                return false;
 
-       snap_vector<action_list_t> *thrd_lists = get_safe_ptr_vect_action(obj_thrd_map, curr->get_location());
+       std::vector<action_list_t> *thrd_lists = get_safe_ptr_vect_action(obj_thrd_map, curr->get_location());
        action_list_t *list = &(*thrd_lists)[id_to_int(curr->get_tid())];
        action_list_t::reverse_iterator rit = list->rbegin();
        ASSERT((*rit) == curr);
@@ -1747,7 +1747,7 @@ bool ModelChecker::check_recency(ModelAction *curr, const T *rf) const
                        curr->get_node()->get_read_from_promise_size() <= 1)
                return true;
 
-       snap_vector<action_list_t> *thrd_lists = get_safe_ptr_vect_action(obj_thrd_map, curr->get_location());
+       std::vector<action_list_t> *thrd_lists = get_safe_ptr_vect_action(obj_thrd_map, curr->get_location());
        int tid = id_to_int(curr->get_tid());
        ASSERT(tid < (int)thrd_lists->size());
        action_list_t *list = &(*thrd_lists)[tid];
@@ -1805,7 +1805,7 @@ bool ModelChecker::check_recency(ModelAction *curr, const T *rf) const
 template <typename rf_type>
 bool ModelChecker::r_modification_order(ModelAction *curr, const rf_type *rf)
 {
-       snap_vector<action_list_t> *thrd_lists = get_safe_ptr_vect_action(obj_thrd_map, curr->get_location());
+       std::vector<action_list_t> *thrd_lists = get_safe_ptr_vect_action(obj_thrd_map, curr->get_location());
        unsigned int i;
        bool added = false;
        ASSERT(curr->is_read());
@@ -1913,7 +1913,7 @@ bool ModelChecker::r_modification_order(ModelAction *curr, const rf_type *rf)
  */
 bool ModelChecker::w_modification_order(ModelAction *curr, std::vector< ModelAction *, ModelAlloc<ModelAction *> > *send_fv)
 {
-       snap_vector<action_list_t> *thrd_lists = get_safe_ptr_vect_action(obj_thrd_map, curr->get_location());
+       std::vector<action_list_t> *thrd_lists = get_safe_ptr_vect_action(obj_thrd_map, curr->get_location());
        unsigned int i;
        bool added = false;
        ASSERT(curr->is_write());
@@ -2057,7 +2057,7 @@ bool ModelChecker::thin_air_constraint_may_allow(const ModelAction *writer, cons
  */
 bool ModelChecker::mo_may_allow(const ModelAction *writer, const ModelAction *reader)
 {
-       snap_vector<action_list_t> *thrd_lists = get_safe_ptr_vect_action(obj_thrd_map, reader->get_location());
+       std::vector<action_list_t> *thrd_lists = get_safe_ptr_vect_action(obj_thrd_map, reader->get_location());
        unsigned int i;
        /* Iterate over all threads */
        for (i = 0; i < thrd_lists->size(); i++) {
@@ -2158,7 +2158,7 @@ bool ModelChecker::release_seq_heads(const ModelAction *rf,
                release_heads->push_back(fence_release);
 
        int tid = id_to_int(rf->get_tid());
-       snap_vector<action_list_t> *thrd_lists = get_safe_ptr_vect_action(obj_thrd_map, rf->get_location());
+       std::vector<action_list_t> *thrd_lists = get_safe_ptr_vect_action(obj_thrd_map, rf->get_location());
        action_list_t *list = &(*thrd_lists)[tid];
        action_list_t::const_reverse_iterator rit;
 
@@ -2301,7 +2301,7 @@ void ModelChecker::get_release_seq_heads(ModelAction *acquire,
 bool ModelChecker::resolve_release_sequences(void *location, work_queue_t *work_queue)
 {
        bool updated = false;
-       snap_vector< struct release_seq * >::iterator it = pending_rel_seqs->begin();
+       std::vector< struct release_seq *, SnapshotAlloc<struct release_seq *> >::iterator it = pending_rel_seqs->begin();
        while (it != pending_rel_seqs->end()) {
                struct release_seq *pending = *it;
                ModelAction *acquire = pending->acquire;
@@ -2382,7 +2382,7 @@ void ModelChecker::add_action_to_lists(ModelAction *act)
        if (uninit)
                action_trace->push_front(uninit);
 
-       snap_vector<action_list_t> *vec = get_safe_ptr_vect_action(obj_thrd_map, act->get_location());
+       std::vector<action_list_t> *vec = get_safe_ptr_vect_action(obj_thrd_map, act->get_location());
        if (tid >= (int)vec->size())
                vec->resize(priv->next_thread_id);
        (*vec)[tid].push_back(act);
@@ -2405,7 +2405,7 @@ void ModelChecker::add_action_to_lists(ModelAction *act)
                void *mutex_loc = (void *) act->get_value();
                get_safe_ptr_action(obj_map, mutex_loc)->push_back(act);
 
-               snap_vector<action_list_t> *vec = get_safe_ptr_vect_action(obj_thrd_map, mutex_loc);
+               std::vector<action_list_t> *vec = get_safe_ptr_vect_action(obj_thrd_map, mutex_loc);
                if (tid >= (int)vec->size())
                        vec->resize(priv->next_thread_id);
                (*vec)[tid].push_back(act);
@@ -2724,7 +2724,7 @@ void ModelChecker::compute_relseq_breakwrites(ModelAction *curr)
  */
 void ModelChecker::build_may_read_from(ModelAction *curr)
 {
-       snap_vector<action_list_t> *thrd_lists = get_safe_ptr_vect_action(obj_thrd_map, curr->get_location());
+       std::vector<action_list_t> *thrd_lists = get_safe_ptr_vect_action(obj_thrd_map, curr->get_location());
        unsigned int i;
        ASSERT(curr->is_read());
 
diff --git a/model.h b/model.h
index 0af3425deefa1743fd03ca99c055678c26f48e22..96c1ec78a60ca343400c309b2e756ae53fb39967 100644 (file)
--- a/model.h
+++ b/model.h
@@ -5,7 +5,7 @@
 #ifndef __MODEL_H__
 #define __MODEL_H__
 
-#include "stl_wrappers.h"
+#include <vector>
 #include <cstddef>
 #include <ucontext.h>
 #include <inttypes.h>
@@ -27,9 +27,9 @@ class ClockVector;
 struct model_snapshot_members;
 
 /** @brief Shorthand for a list of release sequence heads */
-typedef model_vector< const ModelAction * > rel_heads_list_t;
+typedef std::vector< const ModelAction *, ModelAlloc<const ModelAction *> > rel_heads_list_t;
 
-typedef snap_list< ModelAction * > action_list_t;
+typedef std::list< ModelAction *, SnapshotAlloc<ModelAction *> > action_list_t;
 
 /**
  * Model checker parameter structure. Holds run-time configuration options for
@@ -231,9 +231,9 @@ private:
         * to a trace of all actions performed on the object. */
        HashTable<const void *, action_list_t *, uintptr_t, 4> * const condvar_waiters_map;
 
-       HashTable<void *, snap_vector<action_list_t> *, uintptr_t, 4 > * const obj_thrd_map;
-       snap_vector< Promise * > * const promises;
-       snap_vector< struct PendingFutureValue > * const futurevalues;
+       HashTable<void *, std::vector<action_list_t> *, uintptr_t, 4 > * const obj_thrd_map;
+       std::vector< Promise *, SnapshotAlloc<Promise *> > * const promises;
+       std::vector< struct PendingFutureValue, SnapshotAlloc<struct PendingFutureValue> > * const futurevalues;
 
        /**
         * List of pending release sequences. Release sequences might be
@@ -241,10 +241,10 @@ private:
         * are established. Each entry in the list may only be partially
         * filled, depending on its pending status.
         */
-       snap_vector< struct release_seq * > * const pending_rel_seqs;
+       std::vector< struct release_seq *, SnapshotAlloc<struct release_seq *> > * const pending_rel_seqs;
 
-       snap_vector< ModelAction * > * const thrd_last_action;
-       snap_vector< ModelAction * > * const thrd_last_fence_release;
+       std::vector< ModelAction *, SnapshotAlloc<ModelAction *> > * const thrd_last_action;
+       std::vector< ModelAction *, SnapshotAlloc<ModelAction *> > * const thrd_last_fence_release;
        NodeStack * const node_stack;
 
        /** Private data members that should be snapshotted. They are grouped
index 47c0272f95fa917e8710235fa0d56b02194a4d08..8ad329eeaf04f09eb4037c6d9dc6931e8cc1524a 100644 (file)
@@ -5,7 +5,7 @@
 #ifndef __NODESTACK_H__
 #define __NODESTACK_H__
 
-#include "stl_wrappers.h"
+#include <vector>
 #include <cstddef>
 #include <inttypes.h>
 
@@ -163,7 +163,7 @@ private:
        int * yield_data;
 };
 
-typedef model_vector< Node * > node_list_t;
+typedef std::vector< Node *, ModelAlloc< Node * > > node_list_t;
 
 /**
  * @brief A stack of nodes
diff --git a/stl_wrappers.h b/stl_wrappers.h
deleted file mode 100644 (file)
index 061fce0..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-#ifndef STL_WRAPPERS_H
-#define STL_WRAPPERS_H
-
-#include <vector>
-#include <list>
-#include "mymemory.h"
-
-template<typename _Tp >
-class snap_vector:public std::vector<_Tp, SnapshotAlloc<_Tp> > {
- public:
- snap_vector() : std::vector<_Tp, SnapshotAlloc<_Tp> >() {
-       }
- snap_vector(int __n) : std::vector<_Tp, SnapshotAlloc<_Tp> >(__n) {
-       }
-
-       SNAPSHOTALLOC
-};
-
-template<typename _Tp >
-class model_vector:public std::vector<_Tp, ModelAlloc<_Tp> > {
- public:
-       MEMALLOC
-};
-
-template<typename _Tp >
-class snap_list:public std::list<_Tp, SnapshotAlloc<_Tp> > {
- public:
-       SNAPSHOTALLOC
-};
-
-template<typename _Tp >
-class model_list:public std::list<_Tp, ModelAlloc<_Tp> > {
- public:
- model_list() : std::list<_Tp, ModelAlloc<_Tp> >() {
-       }
- model_list(int __n, _Tp t) : std::list<_Tp, ModelAlloc<_Tp> >(__n, t) {
-       }
-       MEMALLOC
-};
-#endif
index 3e2481b97eb2080437beb02e22863db25fdbfac3..f08f63c783596968e9dd13a5595fa1f23fcd865f 100644 (file)
@@ -6,7 +6,7 @@
 #ifndef __WORKQUEUE_H__
 #define __WORKQUEUE_H__
 
-#include "stl_wrappers.h"
+#include <list>
 #include "mymemory.h"
 
 class ModelAction;
@@ -102,6 +102,6 @@ class MOEdgeWorkEntry : public WorkQueueEntry {
 };
 
 /** @brief typedef for the work queue type */
-typedef model_list< WorkQueueEntry > work_queue_t;
+typedef std::list< WorkQueueEntry, ModelAlloc<WorkQueueEntry> > work_queue_t;
 
 #endif /* __WORKQUEUE_H__ */