~FuncInst();
const char * get_position() const { return position; }
+
void * get_location() const { return location; }
+ void set_location(void * loc) { location = loc; }
+ void reset_location() { location = NULL; }
+
action_type get_type() const { return type; }
memory_order get_mo() const { return order; }
FuncNode * get_func_node() const { return func_node; }
#include "funcnode.h"
-FuncNode::FuncNode() :
+FuncNode::FuncNode(ModelHistory * history) :
+ history(history),
predicate_tree_initialized(false),
predicate_tree_entry(new Predicate(NULL, true)),
exit_count(0),
func_inst_map(),
inst_list(),
entry_insts(),
- thrd_read_map()
+ thrd_read_map(),
+ action_list_buffer()
{
predicate_tree_entry->add_predicate_expr(NOPREDICATE, NULL, true);
}
+void FuncNode::set_new_exec_flag()
+{
+ for (uint i = 0; i < thrd_read_map.size(); i++)
+ thrd_read_map[i] = new read_map_t();
+
+ for (mllnode<FuncInst *> * it = inst_list.begin(); it != NULL; it = it->getNext()) {
+ FuncInst * inst = it->getVal();
+ inst->reset_location();
+ }
+}
+
/* Check whether FuncInst with the same type, position, and location
* as act has been added to func_inst_map or not. If not, add it.
*
FuncInst * inst = func_inst_map.get(position);
ASSERT(inst->get_type() == act->get_type());
+
+ // locations are set to NULL when new executions start
+ if (inst->get_location() == NULL)
+ inst->set_location(act->get_location());
+
if (inst->get_location() != act->get_location())
inst->not_single_location();
*/
void FuncNode::update_tree(action_list_t * act_list)
{
- if (act_list == NULL)
- return;
- else if (act_list->size() == 0)
+ if (act_list == NULL || act_list->size() == 0)
return;
/* build inst_list from act_list for later processing */
update_predicate_tree(&read_act_list);
// deep_update(predicate_tree_entry);
- print_predicate_tree();
+// print_predicate_tree();
}
/**
uint64_t read_from_val = act->get_reads_from_value();
/* resize and initialize */
+
uint32_t old_size = thrd_read_map.size();
if (old_size <= tid) {
thrd_read_map.resize(tid + 1);
#include "hashtable.h"
#include "hashset.h"
#include "predicate.h"
+#include "history.h"
typedef ModelList<FuncInst *> func_inst_list_mt;
-typedef HashTable<void *, uint64_t, uintptr_t, 4, model_malloc, model_calloc, model_free> read_map_t;
+typedef HashTable<void *, uint64_t, uintptr_t, 4> read_map_t;
class FuncNode {
public:
- FuncNode();
+ FuncNode(ModelHistory * history);
~FuncNode();
uint32_t get_func_id() { return func_id; }
const char * get_func_name() { return func_name; }
void set_func_id(uint32_t id) { func_id = id; }
void set_func_name(const char * name) { func_name = name; }
+ void set_new_exec_flag();
void add_inst(ModelAction *act);
FuncInst * get_inst(ModelAction *act);
private:
uint32_t func_id;
const char * func_name;
+ ModelHistory * history;
bool predicate_tree_initialized;
Predicate * predicate_tree_entry; // a dummy node whose children are the real entries
func_node->clear_read_map(tid);
action_list_t * curr_act_list = func_act_lists->back();
+
func_node->incr_exit_count();
/* defer the processing of curr_act_list until the function has exits a few times
for (uint32_t id = old_size;id < new_size;id++) {
const char * func_name = func_map_rev[id];
- FuncNode * func_node = new FuncNode();
+ FuncNode * func_node = new FuncNode(this);
func_node->set_func_id(id);
func_node->set_func_name(func_name);
func_nodes[id] = func_node;
uint32_t func_id = (*thrd_func_list)[id].back();
SnapList<action_list_t *> * func_act_lists = (*thrd_func_act_lists)[id];
+ if (act->is_write())
+ add_to_write_history(act->get_location(), act->get_write_value());
+
if (func_id == 0)
return;
else if ( func_nodes.size() <= func_id )
FuncNode * func_node = func_nodes[func_id];
/* do not care about actions without a position */
+
if (act->get_position() == NULL)
return;
if (act->is_read())
func_node->store_read(act, tid);
- if (act->is_write())
- add_to_write_history(act->get_location(), act->get_write_value());
-
/* add to curr_inst_list */
+
bool second_part_of_rmw = act->is_rmwc() || act->is_rmw();
if (!second_part_of_rmw) {
action_list_t * curr_act_list = func_act_lists->back();
write_locations.add(location);
}
+void ModelHistory::set_new_exec_flag()
+{
+ for (uint i = 1; i < func_nodes.size(); i++) {
+ FuncNode * func_node = func_nodes[i];
+ func_node->set_new_exec_flag();
+ }
+}
+
void ModelHistory::print_write()
{
}
void add_to_write_history(void * location, uint64_t write_val);
HashTable<void *, write_set_t *, uintptr_t, 4> * getWriteHistory() { return &write_history; }
+ void set_new_exec_flag();
void print_write();
void print_func_node();
// test code
execution_number ++;
reset_to_initial_state();
+ history->set_new_exec_flag();
return false;
}