Towards erase method
authorBrian Demsky <bdemsky@uci.edu>
Thu, 12 Dec 2019 07:58:04 +0000 (23:58 -0800)
committerBrian Demsky <bdemsky@uci.edu>
Thu, 12 Dec 2019 07:58:04 +0000 (23:58 -0800)
action.h
execution.cc
execution.h

index 15bb02ea5dec0a686570bffd8d13e552a37248d5..78f6f140af0f19553ce107d090fc30ce429709e5 100644 (file)
--- a/action.h
+++ b/action.h
@@ -192,6 +192,9 @@ public:
        void setTraceRef(sllnode<ModelAction *> *ref) { trace_ref = ref; }
        void setThrdMapRef(sllnode<ModelAction *> *ref) { thrdmap_ref = ref; }
        void setActionRef(sllnode<ModelAction *> *ref) { action_ref = ref; }
+       sllnode<ModelAction *> * getTraceRef() { return trace_ref; }
+       sllnode<ModelAction *> * getThrdMapRef() { return thrdmap_ref; }
+       sllnode<ModelAction *> * getActionRef() { return action_ref; }
        SNAPSHOTALLOC
 private:
        const char * get_type_str() const;
index 185874ee7f07e560e35be0e4a301725609c87a39..68fd970691f50e2017e4bbcb275284c9c7bccdac 100644 (file)
@@ -1715,6 +1715,42 @@ Thread * ModelExecution::take_step(ModelAction *curr)
        return action_select_next_thread(curr);
 }
 
+void ModelExecution::removeAction(ModelAction *act) {
+       {
+               sllnode<ModelAction *> * listref = act->getTraceRef();
+               if (listref != NULL) {
+                       action_trace.erase(listref);
+               }
+       }
+       {
+               sllnode<ModelAction *> * listref = act->getThrdMapRef();
+               if (listref != NULL) {
+                       SnapVector<action_list_t> *vec = get_safe_ptr_vect_action(&obj_thrd_map, act->get_location());
+                       (*vec)[act->get_tid()].erase(listref);
+               }
+       }
+       if ((act->is_fence() && act->is_seqcst()) || act->is_unlock()) {
+               sllnode<ModelAction *> * listref = act->getActionRef();
+               if (listref != NULL) {
+                       action_list_t *list = get_safe_ptr_action(&obj_map, act->get_location());
+                       list->erase(listref);
+               }
+       } else if (act->is_wait()) {
+               sllnode<ModelAction *> * listref = act->getActionRef();
+               if (listref != NULL) {
+                       void *mutex_loc = (void *) act->get_value();
+                       get_safe_ptr_action(&obj_map, mutex_loc)->erase(listref);
+               }
+       } else if (act->is_write()) {
+               sllnode<ModelAction *> * listref = act->getActionRef();
+               if (listref != NULL) {
+                       SnapVector<action_list_t> *vec = get_safe_ptr_vect_action(&obj_wr_thrd_map, act->get_location());
+                       (*vec)[act->get_tid()].erase(listref);
+               }
+       }
+
+}
+
 Fuzzer * ModelExecution::getFuzzer() {
        return fuzzer;
 }
index 421781272c0aa3ae8743bac1b2b85d23460102ff..72b51fb882da49e9958a9bb41a3b3eb515566aba 100644 (file)
@@ -123,6 +123,7 @@ private:
        ClockVector * get_hb_from_write(ModelAction *rf) const;
        ModelAction * get_uninitialized_action(ModelAction *curr) const;
        ModelAction * convertNonAtomicStore(void*);
+       void removeAction(ModelAction *act);
 
 #ifdef TLS
        pthread_key_t pthreadkey;
@@ -132,13 +133,14 @@ private:
 
        /** The scheduler to use: tracks the running/ready Threads */
        Scheduler * const scheduler;
-       action_list_t action_trace;
 
 
        SnapVector<Thread *> thread_map;
        SnapVector<Thread *> pthread_map;
        uint32_t pthread_counter;
 
+       action_list_t action_trace;
+
 
        /** Per-object list of actions. Maps an object (i.e., memory location)
         * to a trace of all actions performed on the object.