From: Brian Norris Date: Thu, 7 Mar 2013 22:56:22 +0000 (-0800) Subject: Revert "switch to snapshot/modelalloc versions of stl classes" X-Git-Tag: oopsla2013~150 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=model-checker.git;a=commitdiff_plain;h=b2f34d7f1d030f414786ea0b1a5709dcac604c7b Revert "switch to snapshot/modelalloc versions of stl classes" 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. --- diff --git a/cyclegraph.cc b/cyclegraph.cc index 2062334..e96549f 100644 --- a/cyclegraph.cc +++ b/cyclegraph.cc @@ -8,7 +8,7 @@ /** Initializes a CycleGraph object. */ CycleGraph::CycleGraph() : discovered(new HashTable(16)), - queue(new model_vector< const CycleNode * >()), + queue(new std::vector< const CycleNode *, ModelAlloc >()), hasCycles(false), oldCycles(false) { diff --git a/cyclegraph.h b/cyclegraph.h index d5c6a92..25401d9 100644 --- a/cyclegraph.h +++ b/cyclegraph.h @@ -9,7 +9,7 @@ #ifndef __CYCLEGRAPH_H__ #define __CYCLEGRAPH_H__ -#include "stl_wrappers.h" +#include #include #include @@ -21,7 +21,7 @@ class Promise; class CycleNode; class ModelAction; -typedef model_vector< const Promise * > promise_list_t; +typedef std::vector< const Promise *, ModelAlloc > 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 *discovered; - model_vector< const CycleNode * > * queue; + std::vector< const CycleNode *, ModelAlloc > * queue; /** @brief A table for mapping ModelActions to CycleNodes */ diff --git a/model.cc b/model.cc index f492af3..0122922 100644 --- a/model.cc +++ b/model.cc @@ -85,12 +85,12 @@ ModelChecker::ModelChecker(struct model_params params) : obj_map(new HashTable()), lock_waiters_map(new HashTable()), condvar_waiters_map(new HashTable()), - obj_thrd_map(new HashTable *, 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 *, uintptr_t, 4 >()), + promises(new std::vector< Promise *, SnapshotAlloc >()), + futurevalues(new std::vector< struct PendingFutureValue, SnapshotAlloc >()), + pending_rel_seqs(new std::vector< struct release_seq *, SnapshotAlloc >()), + thrd_last_action(new std::vector< ModelAction *, SnapshotAlloc >(1)), + thrd_last_fence_release(new std::vector< ModelAction *, SnapshotAlloc >()), 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 * get_safe_ptr_vect_action(HashTable *, uintptr_t, 4> * hash, void * ptr) +static std::vector * get_safe_ptr_vect_action(HashTable *, uintptr_t, 4> * hash, void * ptr) { - snap_vector *tmp = hash->get(ptr); + std::vector *tmp = hash->get(ptr); if (tmp == NULL) { - tmp = new snap_vector(); + tmp = new std::vector(); 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 *thrd_lists = get_safe_ptr_vect_action(obj_thrd_map, curr->get_location()); + std::vector *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 *thrd_lists = get_safe_ptr_vect_action(obj_thrd_map, curr->get_location()); + std::vector *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 bool ModelChecker::r_modification_order(ModelAction *curr, const rf_type *rf) { - snap_vector *thrd_lists = get_safe_ptr_vect_action(obj_thrd_map, curr->get_location()); + std::vector *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 > *send_fv) { - snap_vector *thrd_lists = get_safe_ptr_vect_action(obj_thrd_map, curr->get_location()); + std::vector *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 *thrd_lists = get_safe_ptr_vect_action(obj_thrd_map, reader->get_location()); + std::vector *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 *thrd_lists = get_safe_ptr_vect_action(obj_thrd_map, rf->get_location()); + std::vector *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 >::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 *vec = get_safe_ptr_vect_action(obj_thrd_map, act->get_location()); + std::vector *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 *vec = get_safe_ptr_vect_action(obj_thrd_map, mutex_loc); + std::vector *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 *thrd_lists = get_safe_ptr_vect_action(obj_thrd_map, curr->get_location()); + std::vector *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 0af3425..96c1ec7 100644 --- a/model.h +++ b/model.h @@ -5,7 +5,7 @@ #ifndef __MODEL_H__ #define __MODEL_H__ -#include "stl_wrappers.h" +#include #include #include #include @@ -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 > rel_heads_list_t; -typedef snap_list< ModelAction * > action_list_t; +typedef std::list< ModelAction *, SnapshotAlloc > 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 condvar_waiters_map; - HashTable *, uintptr_t, 4 > * const obj_thrd_map; - snap_vector< Promise * > * const promises; - snap_vector< struct PendingFutureValue > * const futurevalues; + HashTable *, uintptr_t, 4 > * const obj_thrd_map; + std::vector< Promise *, SnapshotAlloc > * const promises; + std::vector< struct PendingFutureValue, SnapshotAlloc > * 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 > * const pending_rel_seqs; - snap_vector< ModelAction * > * const thrd_last_action; - snap_vector< ModelAction * > * const thrd_last_fence_release; + std::vector< ModelAction *, SnapshotAlloc > * const thrd_last_action; + std::vector< ModelAction *, SnapshotAlloc > * const thrd_last_fence_release; NodeStack * const node_stack; /** Private data members that should be snapshotted. They are grouped diff --git a/nodestack.h b/nodestack.h index 47c0272..8ad329e 100644 --- a/nodestack.h +++ b/nodestack.h @@ -5,7 +5,7 @@ #ifndef __NODESTACK_H__ #define __NODESTACK_H__ -#include "stl_wrappers.h" +#include #include #include @@ -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 index 061fce0..0000000 --- a/stl_wrappers.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef STL_WRAPPERS_H -#define STL_WRAPPERS_H - -#include -#include -#include "mymemory.h" - -template -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 -class model_vector:public std::vector<_Tp, ModelAlloc<_Tp> > { - public: - MEMALLOC -}; - -template -class snap_list:public std::list<_Tp, SnapshotAlloc<_Tp> > { - public: - SNAPSHOTALLOC -}; - -template -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 diff --git a/workqueue.h b/workqueue.h index 3e2481b..f08f63c 100644 --- a/workqueue.h +++ b/workqueue.h @@ -6,7 +6,7 @@ #ifndef __WORKQUEUE_H__ #define __WORKQUEUE_H__ -#include "stl_wrappers.h" +#include #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 > work_queue_t; #endif /* __WORKQUEUE_H__ */