9 /* Check whether FuncInst with the same type, position, and location
10 * as act has been added to func_inst_map or not. If so, return it;
11 * if not, add it and return it.
13 * @return FuncInst with the same type, position, and location as act */
14 FuncInst * FuncNode::get_or_add_action(ModelAction *act)
17 const char * position = act->get_position();
19 /* Actions THREAD_CREATE, THREAD_START, THREAD_YIELD, THREAD_JOIN,
20 * THREAD_FINISH, PTHREAD_CREATE, PTHREAD_JOIN,
21 * ATOMIC_LOCK, ATOMIC_TRYLOCK, and ATOMIC_UNLOCK are not tagged with their
27 if ( func_inst_map.contains(position) ) {
28 FuncInst * inst = func_inst_map.get(position);
30 if (inst->get_type() != act->get_type() ) {
31 // model_print("action with a different type occurs at line number %s\n", position);
32 FuncInst * func_inst = inst->search_in_collision(act);
34 if (func_inst != NULL) {
35 // return the FuncInst found in the collision list
39 func_inst = new FuncInst(act, this);
40 inst->get_collisions()->push_back(func_inst);
41 inst_list.push_back(func_inst); // delete?
42 if (func_inst->is_read())
43 group_reads_by_loc(func_inst);
51 FuncInst * func_inst = new FuncInst(act, this);
52 func_inst_map.put(position, func_inst);
53 inst_list.push_back(func_inst);
55 if (func_inst->is_read())
56 group_reads_by_loc(func_inst);
61 void FuncNode::add_entry_inst(FuncInst * inst)
66 func_inst_list_mt::iterator it;
67 for (it = entry_insts.begin(); it != entry_insts.end(); it++) {
72 entry_insts.push_back(inst);
75 /* group atomic read actions by memory location */
76 void FuncNode::group_reads_by_loc(FuncInst * inst)
79 if ( !inst->is_read() )
82 void * location = inst->get_location();
84 func_inst_list_mt * reads;
85 if ( !reads_by_loc.contains(location) ) {
86 reads = new func_inst_list_mt();
87 reads->push_back(inst);
88 reads_by_loc.put(location, reads);
92 reads = reads_by_loc.get(location);
93 func_inst_list_mt::iterator it;
94 for (it = reads->begin(); it != reads->end(); it++) {
99 reads->push_back(inst);