From d6749bd306dfa3003d583e3b1290996651fbcbd9 Mon Sep 17 00:00:00 2001 From: weiyu Date: Wed, 24 Jul 2019 18:04:18 -0700 Subject: [PATCH] little fixes --- execution.cc | 3 +-- funcnode.cc | 15 +++++++-------- funcnode.h | 2 +- history.cc | 4 +--- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/execution.cc b/execution.cc index 33a608d6..01125bb2 100644 --- a/execution.cc +++ b/execution.cc @@ -277,7 +277,6 @@ ModelAction * ModelExecution::convertNonAtomicStore(void * location) { return act; } - /** * Processes a read model action. * @param curr is the read model action to process. @@ -1632,7 +1631,7 @@ Thread * ModelExecution::take_step(ModelAction *curr) ASSERT(curr); /* Process this action in ModelHistory for records*/ - model->get_history()->process_action( curr, curr_thrd->get_id() ); + model->get_history()->process_action( curr, curr->get_tid() ); if (curr_thrd->is_blocked() || curr_thrd->is_complete()) scheduler->remove_thread(curr_thrd); diff --git a/funcnode.cc b/funcnode.cc index 8e76ebc6..281e0f05 100644 --- a/funcnode.cc +++ b/funcnode.cc @@ -112,15 +112,15 @@ void FuncNode::store_read(ModelAction * act, uint32_t tid) void * location = act->get_location(); uint64_t read_from_val = act->get_reads_from_value(); - if (thrd_read_map.size() <= tid) + /* resize and initialize */ + uint32_t old_size = thrd_read_map.size(); + if (old_size <= tid) { thrd_read_map.resize(tid + 1); - - read_map_t * read_map = thrd_read_map[tid]; - if (read_map == NULL) { - read_map = new read_map_t(); - thrd_read_map[tid] = read_map; + for (uint32_t i = old_size; i < tid + 1; i++) + thrd_read_map[i] = new read_map_t(); } + read_map_t * read_map = thrd_read_map[tid]; read_map->put(location, read_from_val); /* Store the memory locations where atomic reads happen */ @@ -137,13 +137,12 @@ void FuncNode::store_read(ModelAction * act, uint32_t tid) read_locations.push_back(location); } -uint64_t FuncNode::query_last_read(ModelAction * act, uint32_t tid) +uint64_t FuncNode::query_last_read(void * location, uint32_t tid) { if (thrd_read_map.size() <= tid) return 0xdeadbeef; read_map_t * read_map = thrd_read_map[tid]; - void * location = act->get_location(); /* last read value not found */ if ( !read_map->contains(location) ) diff --git a/funcnode.h b/funcnode.h index be6f406a..f80e9266 100644 --- a/funcnode.h +++ b/funcnode.h @@ -26,7 +26,7 @@ public: void link_insts(func_inst_list_t * inst_list); void store_read(ModelAction * act, uint32_t tid); - uint64_t query_last_read(ModelAction * act, uint32_t tid); + uint64_t query_last_read(void * location, uint32_t tid); void clear_read_map(uint32_t tid); void print_last_read(uint32_t tid); diff --git a/history.cc b/history.cc index abf11823..267205db 100644 --- a/history.cc +++ b/history.cc @@ -98,13 +98,11 @@ void ModelHistory::process_action(ModelAction *act, thread_id_t tid) uint32_t id = id_to_int(tid); if ( thrd_func_list->size() <= id ) return; -// else if ( (*thrd_func_list)[id] == NULL) -// return; /* get the function id that thread i is currently in */ + uint32_t func_id = (*thrd_func_list)[id].back(); SnapList * func_inst_lists = thrd_func_inst_lists->at(id); - uint32_t func_id = (*thrd_func_list)[id].back(); if ( func_nodes.size() <= func_id ) resize_func_nodes( func_id + 1 ); -- 2.34.1