- FuncNode * func_node = func_atomics[func_id];
- if (func_node == NULL) {
- func_node = new FuncNode();
- func_atomics[func_id] = func_node;
+ if (inst == NULL)
+ return;
+
+ if (inst->is_read())
+ func_node->store_read(act, tid);
+
+ if (inst->is_write())
+ add_to_write_history(act->get_location(), act->get_write_value());
+
+ /* add to curr_inst_list */
+ func_inst_list_t * curr_inst_list = func_inst_lists->back();
+ ASSERT(curr_inst_list != NULL);
+ curr_inst_list->push_back(inst);
+}
+
+/* return the FuncNode given its func_id */
+FuncNode * ModelHistory::get_func_node(uint32_t func_id)
+{
+ if (func_nodes.size() <= func_id) // this node has not been added
+ return NULL;
+
+ return func_nodes[func_id];
+}
+
+uint64_t ModelHistory::query_last_read(void * location, thread_id_t tid)
+{
+ SnapVector<func_id_list_t> * thrd_func_list = model->get_execution()->get_thrd_func_list();
+ uint32_t id = id_to_int(tid);
+
+ ASSERT( thrd_func_list->size() > id );
+ uint32_t func_id = (*thrd_func_list)[id].back();
+ FuncNode * func_node = func_nodes[func_id];
+
+ uint64_t last_read_val = 0xdeadbeef;
+ if (func_node != NULL) {
+ last_read_val = func_node->query_last_read(location, tid);
+ }
+
+ return last_read_val;
+}
+
+void ModelHistory::add_to_write_history(void * location, uint64_t write_val)
+{
+ write_set_t * write_set = write_history.get(location);
+
+ if (write_set == NULL) {
+ write_set = new write_set_t();
+ write_history.put(location, write_set);