inst_list(),
entry_insts(),
// thrd_read_map(),
- action_list_buffer()
+ action_list_buffer(),
+ predicate_tree_position()
{
predicate_tree_entry = new Predicate(NULL, true);
predicate_tree_entry->add_predicate_expr(NOPREDICATE, NULL, true);
- // memory will be reclaimed after each execution
+ // memories that are reclaimed after each execution
read_locations = new loc_set_t();
val_loc_map = new HashTable<uint64_t, loc_set_t *, uint64_t, 0>();
loc_may_equal_map = new HashTable<void *, loc_set_t *, uintptr_t, 0>();
- values_may_read_from = new value_set_t();
+ //values_may_read_from = new value_set_t();
}
-/* Reallocate some snapshotted memories when new executions start */
+/* Reallocate snapshotted memories when new executions start */
void FuncNode::set_new_exec_flag()
{
// for (uint i = 0; i < thrd_read_map.size(); i++)
for (mllnode<FuncInst *> * it = inst_list.begin(); it != NULL; it = it->getNext()) {
FuncInst * inst = it->getVal();
- inst->reset_location();
+ inst->unset_location();
}
read_locations = new loc_set_t();
val_loc_map = new HashTable<uint64_t, loc_set_t *, uint64_t, 0>();
loc_may_equal_map = new HashTable<void *, loc_set_t *, uintptr_t, 0>();
- values_may_read_from = new value_set_t();
+ //values_may_read_from = new value_set_t();
}
/* Check whether FuncInst with the same type, position, and location
}
}
- model_print("function %s\n", func_name);
+// model_print("function %s\n", func_name);
// print_val_loc_map();
update_inst_tree(&inst_list);
update_predicate_tree(&read_act_list);
- print_predicate_tree();
+// print_predicate_tree();
}
/**
/* @param tid thread id
* Store the values read by atomic read actions into thrd_read_map */
-void FuncNode::store_read(ModelAction * act, uint32_t tid)
+void FuncNode::store_read(ModelAction * act, thread_id_t tid)
{
/*
ASSERT(act);
*/
}
-uint64_t FuncNode::query_last_read(void * location, uint32_t tid)
+uint64_t FuncNode::query_last_read(void * location, thread_id_t tid)
{
/*
if (thrd_read_map.size() <= tid)
* Reset read map for a thread. This function shall only be called
* when a thread exits a function
*/
-void FuncNode::clear_read_map(uint32_t tid)
+void FuncNode::clear_read_map(thread_id_t tid)
{
/*
if (thrd_read_map.size() <= tid)
update_loc_may_equal_map(loc, locations);
locations->add(loc);
- values_may_read_from->add(val);
+ // values_may_read_from->add(val);
}
void FuncNode::add_to_val_loc_map(value_set_t * values, void * loc)
}
}
+void FuncNode::init_predicate_tree_position(thread_id_t tid)
+{
+ uint thread_id = id_to_int(tid);
+ if (predicate_tree_position.size() <= thread_id)
+ predicate_tree_position.resize(thread_id + 1);
+
+ predicate_tree_position[thread_id] = predicate_tree_entry;
+}
+
+void FuncNode::unset_predicate_tree_position(thread_id_t tid)
+{
+ uint thread_id = id_to_int(tid);
+ predicate_tree_position[thread_id] = NULL;
+}
+
void FuncNode::print_predicate_tree()
{
model_print("digraph function_%s {\n", func_name);
void FuncNode::print_val_loc_map()
{
+/*
value_set_iter * val_it = values_may_read_from->iterator();
while (val_it->hasNext()) {
uint64_t value = val_it->next();
}
model_print("\n");
}
+*/
}
/* @param tid thread id
* Print the values read by the last read actions for each memory location
*/
/*
-void FuncNode::print_last_read(uint32_t tid)
+void FuncNode::print_last_read(thread_id_t tid)
{
ASSERT(thrd_read_map.size() > tid);
read_map_t * read_map = thrd_read_map[tid];
void update_tree(action_list_t * act_list);
void update_inst_tree(func_inst_list_t * inst_list);
- void store_read(ModelAction * act, uint32_t tid);
- uint64_t query_last_read(void * location, uint32_t tid);
- void clear_read_map(uint32_t tid);
+ void store_read(ModelAction * act, thread_id_t tid);
+ uint64_t query_last_read(void * location, thread_id_t tid);
+ void clear_read_map(thread_id_t tid);
void update_predicate_tree(action_list_t * act_list);
bool follow_branch(Predicate ** curr_pred, FuncInst * next_inst, ModelAction * next_act, HashTable<FuncInst *, ModelAction *, uintptr_t, 0>* inst_act_map, SnapVector<Predicate *> * unset_predicates);
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 unset_predicate_tree_position(thread_id_t tid);
+ Predicate * get_predicate_tree_position(thread_id_t tid);
+
void print_predicate_tree();
void print_val_loc_map();
- void print_last_read(uint32_t tid);
+ void print_last_read(thread_id_t tid);
MEMALLOC
private:
loc_set_t * read_locations;
HashTable<uint64_t, loc_set_t *, uint64_t, 0> * val_loc_map;
HashTable<void *, loc_set_t *, uintptr_t, 0> * loc_may_equal_map;
- value_set_t * values_may_read_from;
+ // value_set_t * values_may_read_from;
+
+ /* run-time position in the predicate tree for each thread */
+ ModelVector<Predicate *> predicate_tree_position;
};
#endif /* __FUNCNODE_H__ */
if ( func_nodes.size() <= func_id )
resize_func_nodes( func_id + 1 );
+
+ FuncNode * func_node = func_nodes[func_id];
+ func_node->init_predicate_tree_position(tid);
}
/* @param func_id a non-zero value */
if (last_func_id == func_id) {
FuncNode * func_node = func_nodes[func_id];
+ func_node->unset_predicate_tree_position(tid);
//func_node->clear_read_map(tid);
action_list_t * curr_act_list = func_act_lists->back();
/* defer the processing of curr_act_list until the function has exits a few times
- * (currently 2 times) so that more information can be gathered to infer nullity predicates.
+ * (currently twice) so that more information can be gathered to infer nullity predicates.
*/
func_node->incr_exit_count();
if (func_node->get_exit_count() >= 2) {
if ( old_size < new_size )
func_nodes.resize(new_size);
- for (uint32_t id = old_size;id < new_size;id++) {
+ for (uint32_t id = old_size; id < new_size; id++) {
const char * func_name = func_map_rev[id];
FuncNode * func_node = new FuncNode(this);
func_node->set_func_id(id);