void FuncNode::function_entry_handler(thread_id_t tid)
{
set_marker(tid);
- set_predicate_tree_position(tid, predicate_tree_entry);
+ init_predicate_tree_position(tid);
init_inst_act_map(tid);
init_maps(tid);
}
exit_pred->set_exit(predicate_tree_exit);
}
- set_predicate_tree_position(tid, NULL);
+ int thread_id = id_to_int(tid);
+ predicate_tree_position[thread_id]->pop_back();
}
/**
*/
void FuncNode::update_tree(ModelAction * act)
{
+ bool should_process = act->is_read() || act->is_write();
+ if (!should_process)
+ return;
+
HashTable<void *, value_set_t *, uintptr_t, 0> * write_history = history->getWriteHistory();
/* build inst_list from act_list for later processing */
delete loc_it;
}
-void FuncNode::set_predicate_tree_position(thread_id_t tid, Predicate * pred)
+void FuncNode::init_predicate_tree_position(thread_id_t tid)
{
int thread_id = id_to_int(tid);
- if (predicate_tree_position.size() <= (uint) thread_id)
+ int old_size = predicate_tree_position.size();
+
+ if (old_size <= thread_id + 1) {
predicate_tree_position.resize(thread_id + 1);
- predicate_tree_position[thread_id] = pred;
+ for (int i = old_size; i < thread_id + 1; i++)
+ predicate_tree_position[i] = new ModelVector<Predicate *>();
+ }
+
+ predicate_tree_position[thread_id]->push_back(predicate_tree_entry);
+}
+
+void FuncNode::set_predicate_tree_position(thread_id_t tid, Predicate * pred)
+{
+ int thread_id = id_to_int(tid);
+ ModelVector<Predicate *> * stack = predicate_tree_position[thread_id];
+ (*stack)[stack->size() - 1] = pred;
}
/* @return The position of a thread in a predicate tree */
Predicate * FuncNode::get_predicate_tree_position(thread_id_t tid)
{
int thread_id = id_to_int(tid);
- return predicate_tree_position[thread_id];
+ return predicate_tree_position[thread_id]->back();
}
/* Make sure elements of thrd_inst_act_map are initialized properly when threads enter functions */
void add_to_val_loc_map(value_set_t * values, void * loc);
void update_loc_may_equal_map(void * new_loc, loc_set_t * old_locations);
+ void init_predicate_tree_position(thread_id_t tid);
void set_predicate_tree_position(thread_id_t tid, Predicate * pred);
Predicate * get_predicate_tree_position(thread_id_t tid);
// value_set_t * values_may_read_from;
- /* Run-time position in the predicate tree for each thread */
- ModelVector<Predicate *> predicate_tree_position;
+ /* Run-time position in the predicate tree for each thread
+ * The inner vector is used to deal with recursive functions. */
+ ModelVector< ModelVector<Predicate *> * > predicate_tree_position;
PredSet predicate_leaves;
ModelVector<Predicate *> leaves_tmp_storage;
(*thrd_func_list)[id].pop_back();
} else {
- model_print("trying to exit with a wrong function id\n");
- model_print("--- last_func: %d, func_id: %d\n", last_func_id, func_id);
+ ASSERT(false);
}
//model_print("thread %d exiting func %d\n", tid, func_id);
}