6 #include "concretepredicate.h"
11 FuncNode::FuncNode(ModelHistory * history) :
23 thrd_predicate_tree_position(),
24 thrd_predicate_trace(),
29 predicate_tree_entry = new Predicate(NULL, true);
30 predicate_tree_entry->add_predicate_expr(NOPREDICATE, NULL, true);
32 predicate_tree_exit = new Predicate(NULL, false, true);
33 predicate_tree_exit->set_depth(MAX_DEPTH);
35 /* Snapshot data structures below */
36 read_locations = new loc_set_t();
37 write_locations = new loc_set_t();
38 val_loc_map = new HashTable<uint64_t, loc_set_t *, uint64_t, 0, snapshot_malloc, snapshot_calloc, snapshot_free, int64_hash>();
39 loc_may_equal_map = new HashTable<void *, loc_set_t *, uintptr_t, 0>();
41 //values_may_read_from = new value_set_t();
44 /* Reallocate snapshotted memories when new executions start */
45 void FuncNode::set_new_exec_flag()
47 read_locations = new loc_set_t();
48 write_locations = new loc_set_t();
49 val_loc_map = new HashTable<uint64_t, loc_set_t *, uint64_t, 0, snapshot_malloc, snapshot_calloc, snapshot_free, int64_hash>();
50 loc_may_equal_map = new HashTable<void *, loc_set_t *, uintptr_t, 0>();
52 //values_may_read_from = new value_set_t();
55 /* Check whether FuncInst with the same type, position, and location
56 * as act has been added to func_inst_map or not. If not, add it.
58 void FuncNode::add_inst(ModelAction *act)
61 const char * position = act->get_position();
63 /* THREAD* actions, ATOMIC_LOCK, ATOMIC_TRYLOCK, and ATOMIC_UNLOCK
64 * actions are not tagged with their source line numbers
69 FuncInst * func_inst = func_inst_map.get(position);
71 /* This position has not been inserted into hashtable before */
72 if (func_inst == NULL) {
73 func_inst = create_new_inst(act);
74 func_inst_map.put(position, func_inst);
78 /* Volatile variables that use ++ or -- syntax may result in read and write actions with the same position */
79 if (func_inst->get_type() != act->get_type()) {
80 FuncInst * collision_inst = func_inst->search_in_collision(act);
82 if (collision_inst == NULL) {
83 collision_inst = create_new_inst(act);
84 func_inst->add_to_collision(collision_inst);
87 func_inst = collision_inst;
91 ASSERT(func_inst->get_type() == act->get_type());
92 int curr_execution_number = model->get_execution_number();
94 /* Reset locations when new executions start */
95 if (func_inst->get_execution_number() != curr_execution_number) {
96 func_inst->set_location(act->get_location());
97 func_inst->set_execution_number(curr_execution_number);
100 /* Mark the memory location of such inst as not unique */
101 if (func_inst->get_location() != act->get_location())
102 func_inst->not_single_location();
105 FuncInst * FuncNode::create_new_inst(ModelAction * act)
107 FuncInst * func_inst = new FuncInst(act, this);
108 int exec_num = model->get_execution_number();
109 func_inst->set_execution_number(exec_num);
111 inst_list.push_back(func_inst);
117 /* Get the FuncInst with the same type, position, and location
120 * @return FuncInst with the same type, position, and location as act */
121 FuncInst * FuncNode::get_inst(ModelAction *act)
124 const char * position = act->get_position();
126 /* THREAD* actions, ATOMIC_LOCK, ATOMIC_TRYLOCK, and ATOMIC_UNLOCK
127 * actions are not tagged with their source line numbers
129 if (position == NULL)
132 FuncInst * inst = func_inst_map.get(position);
136 action_type inst_type = inst->get_type();
137 action_type act_type = act->get_type();
139 if (inst_type == act_type) {
142 /* RMWRCAS actions are converted to RMW or READ actions */
143 else if (inst_type == ATOMIC_RMWRCAS &&
144 (act_type == ATOMIC_RMW || act_type == ATOMIC_READ)) {
147 /* Return the FuncInst in the collision list */
149 return inst->search_in_collision(act);
153 void FuncNode::add_entry_inst(FuncInst * inst)
158 mllnode<FuncInst *> * it;
159 for (it = entry_insts.begin();it != NULL;it = it->getNext()) {
160 if (inst == it->getVal())
164 entry_insts.push_back(inst);
167 void FuncNode::function_entry_handler(thread_id_t tid)
170 init_inst_act_map(tid);
171 init_local_maps(tid);
172 init_predicate_tree_data_structure(tid);
175 void FuncNode::function_exit_handler(thread_id_t tid)
179 reset_inst_act_map(tid);
180 reset_local_maps(tid);
182 Predicate * exit_pred = get_predicate_tree_position(tid);
183 if (exit_pred->get_exit() == NULL) {
184 // Exit predicate is unset yet
185 exit_pred->set_exit(predicate_tree_exit);
188 update_predicate_tree_weight(tid);
189 reset_predicate_tree_data_structure(tid);
193 * @brief Convert ModelAdtion list to FuncInst list
194 * @param act_list A list of ModelActions
196 void FuncNode::update_tree(ModelAction * act)
198 bool should_process = act->is_read() || act->is_write();
202 HashTable<void *, value_set_t *, uintptr_t, 0> * write_history = history->getWriteHistory();
204 /* build inst_list from act_list for later processing */
205 // func_inst_list_t inst_list;
207 FuncInst * func_inst = get_inst(act);
208 void * loc = act->get_location();
210 if (func_inst == NULL)
213 // inst_list.push_back(func_inst);
215 if (act->is_write()) {
216 if (!write_locations->contains(loc)) {
217 write_locations->add(loc);
218 history->update_loc_wr_func_nodes_map(loc, this);
221 // Do not process writes for now
225 if (act->is_read()) {
227 /* If func_inst may only read_from a single location, then:
229 * The first time an action reads from some location,
230 * import all the values that have been written to this
231 * location from ModelHistory and notify ModelHistory
232 * that this FuncNode may read from this location.
234 if (!read_locations->contains(loc) && func_inst->is_single_location()) {
235 read_locations->add(loc);
236 value_set_t * write_values = write_history->get(loc);
237 add_to_val_loc_map(write_values, loc);
238 history->update_loc_rd_func_nodes_map(loc, this);
242 // update_inst_tree(&inst_list); TODO
243 update_predicate_tree(act);
245 // print_predicate_tree();
249 * @brief Link FuncInsts in inst_list - add one FuncInst to another's predecessors and successors
250 * @param inst_list A list of FuncInsts
252 void FuncNode::update_inst_tree(func_inst_list_t * inst_list)
254 if (inst_list == NULL)
256 else if (inst_list->size() == 0)
260 sllnode<FuncInst *>* it = inst_list->begin();
261 sllnode<FuncInst *>* prev;
263 /* add the first instruction to the list of entry insts */
264 FuncInst * entry_inst = it->getVal();
265 add_entry_inst(entry_inst);
269 prev = it->getPrev();
271 FuncInst * prev_inst = prev->getVal();
272 FuncInst * curr_inst = it->getVal();
274 prev_inst->add_succ(curr_inst);
275 curr_inst->add_pred(prev_inst);
281 void FuncNode::update_predicate_tree(ModelAction * next_act)
283 thread_id_t tid = next_act->get_tid();
284 int thread_id = id_to_int(tid);
285 int this_marker = thrd_marker[thread_id];
287 loc_inst_map_t * loc_inst_map = thrd_loc_inst_map[thread_id];
288 inst_pred_map_t * inst_pred_map = thrd_inst_pred_map[thread_id];
289 inst_id_map_t * inst_id_map = thrd_inst_id_map[thread_id];
291 Predicate * curr_pred = get_predicate_tree_position(tid);
293 FuncInst * next_inst = get_inst(next_act);
294 next_inst->set_associated_read(tid, next_act->get_reads_from_value(), this_marker);
296 Predicate * unset_predicate = NULL;
297 bool branch_found = follow_branch(&curr_pred, next_inst, next_act, &unset_predicate);
299 // A branch with unset predicate expression is detected
300 if (!branch_found && unset_predicate != NULL) {
301 bool amended = amend_predicate_expr(curr_pred, next_inst, next_act);
305 curr_pred = unset_predicate;
311 if (!branch_found && inst_id_map->contains(next_inst)) {
312 FuncInst * curr_inst = curr_pred->get_func_inst();
313 uint32_t curr_id = inst_id_map->get(curr_inst);
314 uint32_t next_id = inst_id_map->get(next_inst);
316 if (curr_id >= next_id) {
317 Predicate * old_pred = inst_pred_map->get(next_inst);
318 Predicate * back_pred = old_pred->get_parent();
320 // Add to the set of backedges
321 curr_pred->add_backedge(back_pred);
322 curr_pred = back_pred;
328 // Generate new branches
330 SnapVector<struct half_pred_expr *> half_pred_expressions;
331 infer_predicates(next_inst, next_act, &half_pred_expressions);
332 generate_predicates(curr_pred, next_inst, &half_pred_expressions);
336 if (next_act->is_write())
337 curr_pred->set_write(true);
339 if (next_act->is_read()) {
340 /* Only need to store the locations of read actions */
341 loc_inst_map->put(next_inst->get_location(), next_inst);
344 inst_pred_map->put(next_inst, curr_pred);
345 set_predicate_tree_position(tid, curr_pred);
347 if (!inst_id_map->contains(next_inst))
348 inst_id_map->put(next_inst, inst_counter++);
350 curr_pred->incr_expl_count();
351 add_predicate_to_trace(tid, curr_pred);
356 /* Given curr_pred and next_inst, find the branch following curr_pred that
357 * contains next_inst and the correct predicate.
358 * @return true if branch found, false otherwise.
360 bool FuncNode::follow_branch(Predicate ** curr_pred, FuncInst * next_inst,
361 ModelAction * next_act, Predicate ** unset_predicate)
363 /* Check if a branch with func_inst and corresponding predicate exists */
364 bool branch_found = false;
365 thread_id_t tid = next_act->get_tid();
366 int this_marker = thrd_marker[id_to_int(tid)];
368 ModelVector<Predicate *> * branches = (*curr_pred)->get_children();
369 for (uint i = 0;i < branches->size();i++) {
370 Predicate * branch = (*branches)[i];
371 if (branch->get_func_inst() != next_inst)
374 /* Check against predicate expressions */
375 bool predicate_correct = true;
376 PredExprSet * pred_expressions = branch->get_pred_expressions();
378 /* Only read and rmw actions my have unset predicate expressions */
379 if (pred_expressions->getSize() == 0) {
380 predicate_correct = false;
382 if (*unset_predicate == NULL)
383 *unset_predicate = branch;
390 PredExprSetIter * pred_expr_it = pred_expressions->iterator();
391 while (pred_expr_it->hasNext()) {
392 pred_expr * pred_expression = pred_expr_it->next();
393 uint64_t last_read, next_read;
396 switch(pred_expression->token) {
398 predicate_correct = true;
401 FuncInst * to_be_compared;
402 to_be_compared = pred_expression->func_inst;
404 last_read = to_be_compared->get_associated_read(tid, this_marker);
405 ASSERT(last_read != VALUE_NONE);
407 next_read = next_act->get_reads_from_value();
408 equality = (last_read == next_read);
409 if (equality != pred_expression->value)
410 predicate_correct = false;
414 next_read = next_act->get_reads_from_value();
415 // TODO: implement likely to be null
416 equality = ( (void*) (next_read & 0xffffffff) == NULL);
417 if (equality != pred_expression->value)
418 predicate_correct = false;
421 predicate_correct = false;
422 model_print("unkown predicate token\n");
429 if (predicate_correct) {
439 /* Infer predicate expressions, which are generated in FuncNode::generate_predicates */
440 void FuncNode::infer_predicates(FuncInst * next_inst, ModelAction * next_act,
441 SnapVector<struct half_pred_expr *> * half_pred_expressions)
443 void * loc = next_act->get_location();
444 int thread_id = id_to_int(next_act->get_tid());
445 loc_inst_map_t * loc_inst_map = thrd_loc_inst_map[thread_id];
447 if (next_inst->is_read()) {
449 if ( loc_inst_map->contains(loc) ) {
450 FuncInst * last_inst = loc_inst_map->get(loc);
451 struct half_pred_expr * expression = new half_pred_expr(EQUALITY, last_inst);
452 half_pred_expressions->push_back(expression);
453 } else if ( next_inst->is_single_location() ) {
454 loc_set_t * loc_may_equal = loc_may_equal_map->get(loc);
456 if (loc_may_equal != NULL) {
457 loc_set_iter * loc_it = loc_may_equal->iterator();
458 while (loc_it->hasNext()) {
459 void * neighbor = loc_it->next();
460 if (loc_inst_map->contains(neighbor)) {
461 FuncInst * last_inst = loc_inst_map->get(neighbor);
463 struct half_pred_expr * expression = new half_pred_expr(EQUALITY, last_inst);
464 half_pred_expressions->push_back(expression);
471 // next_inst is not single location
472 uint64_t read_val = next_act->get_reads_from_value();
474 // only infer NULLITY predicate when it is actually NULL.
475 if ( (void*)read_val == NULL) {
476 struct half_pred_expr * expression = new half_pred_expr(NULLITY, NULL);
477 half_pred_expressions->push_back(expression);
482 // TODO: do anything here?
486 /* Able to generate complex predicates when there are multiple predciate expressions */
487 void FuncNode::generate_predicates(Predicate * curr_pred, FuncInst * next_inst,
488 SnapVector<struct half_pred_expr *> * half_pred_expressions)
490 if (half_pred_expressions->size() == 0) {
491 Predicate * new_pred = new Predicate(next_inst);
492 curr_pred->add_child(new_pred);
493 new_pred->set_parent(curr_pred);
495 /* entry predicates and predicates containing pure write actions
496 * have no predicate expressions */
497 if ( curr_pred->is_entry_predicate() )
498 new_pred->add_predicate_expr(NOPREDICATE, NULL, true);
499 else if (next_inst->is_write()) {
500 /* next_inst->is_write() <==> pure writes */
501 new_pred->add_predicate_expr(NOPREDICATE, NULL, true);
507 SnapVector<Predicate *> predicates;
509 struct half_pred_expr * half_expr = (*half_pred_expressions)[0];
510 predicates.push_back(new Predicate(next_inst));
511 predicates.push_back(new Predicate(next_inst));
513 predicates[0]->add_predicate_expr(half_expr->token, half_expr->func_inst, true);
514 predicates[1]->add_predicate_expr(half_expr->token, half_expr->func_inst, false);
516 for (uint i = 1;i < half_pred_expressions->size();i++) {
517 half_expr = (*half_pred_expressions)[i];
519 uint old_size = predicates.size();
520 for (uint j = 0;j < old_size;j++) {
521 Predicate * pred = predicates[j];
522 Predicate * new_pred = new Predicate(next_inst);
523 new_pred->copy_predicate_expr(pred);
525 pred->add_predicate_expr(half_expr->token, half_expr->func_inst, true);
526 new_pred->add_predicate_expr(half_expr->token, half_expr->func_inst, false);
528 predicates.push_back(new_pred);
532 for (uint i = 0;i < predicates.size();i++) {
533 Predicate * pred= predicates[i];
534 curr_pred->add_child(pred);
535 pred->set_parent(curr_pred);
538 /* Free memories allocated by infer_predicate */
539 for (uint i = 0;i < half_pred_expressions->size();i++) {
540 struct half_pred_expr * tmp = (*half_pred_expressions)[i];
545 /* Amend predicates that contain no predicate expressions. Currenlty only amend with NULLITY predicates */
546 bool FuncNode::amend_predicate_expr(Predicate * curr_pred, FuncInst * next_inst, ModelAction * next_act)
548 ModelVector<Predicate *> * children = curr_pred->get_children();
550 Predicate * unset_pred = NULL;
551 for (uint i = 0;i < children->size();i++) {
552 Predicate * child = (*children)[i];
553 if (child->get_func_inst() == next_inst) {
559 uint64_t read_val = next_act->get_reads_from_value();
561 // only generate NULLITY predicate when it is actually NULL.
562 if ( !next_inst->is_single_location() && (void*)read_val == NULL ) {
563 Predicate * new_pred = new Predicate(next_inst);
565 curr_pred->add_child(new_pred);
566 new_pred->set_parent(curr_pred);
568 unset_pred->add_predicate_expr(NULLITY, NULL, false);
569 new_pred->add_predicate_expr(NULLITY, NULL, true);
577 void FuncNode::add_to_val_loc_map(uint64_t val, void * loc)
579 loc_set_t * locations = val_loc_map->get(val);
581 if (locations == NULL) {
582 locations = new loc_set_t();
583 val_loc_map->put(val, locations);
586 update_loc_may_equal_map(loc, locations);
588 // values_may_read_from->add(val);
591 void FuncNode::add_to_val_loc_map(value_set_t * values, void * loc)
596 value_set_iter * it = values->iterator();
597 while (it->hasNext()) {
598 uint64_t val = it->next();
599 add_to_val_loc_map(val, loc);
605 void FuncNode::update_loc_may_equal_map(void * new_loc, loc_set_t * old_locations)
607 if ( old_locations->contains(new_loc) )
610 loc_set_t * neighbors = loc_may_equal_map->get(new_loc);
612 if (neighbors == NULL) {
613 neighbors = new loc_set_t();
614 loc_may_equal_map->put(new_loc, neighbors);
617 loc_set_iter * loc_it = old_locations->iterator();
618 while (loc_it->hasNext()) {
619 // new_loc: { old_locations, ... }
620 void * member = loc_it->next();
621 neighbors->add(member);
623 // for each i in old_locations, i : { new_loc, ... }
624 loc_set_t * _neighbors = loc_may_equal_map->get(member);
625 if (_neighbors == NULL) {
626 _neighbors = new loc_set_t();
627 loc_may_equal_map->put(member, _neighbors);
629 _neighbors->add(new_loc);
635 void FuncNode::set_predicate_tree_position(thread_id_t tid, Predicate * pred)
637 int thread_id = id_to_int(tid);
638 ModelVector<Predicate *> * stack = thrd_predicate_tree_position[thread_id];
639 (*stack)[stack->size() - 1] = pred;
642 /* @return The position of a thread in a predicate tree */
643 Predicate * FuncNode::get_predicate_tree_position(thread_id_t tid)
645 int thread_id = id_to_int(tid);
646 return thrd_predicate_tree_position[thread_id]->back();
649 void FuncNode::add_predicate_to_trace(thread_id_t tid, Predicate * pred)
651 int thread_id = id_to_int(tid);
652 thrd_predicate_trace[thread_id]->back()->push_back(pred);
655 /* Make sure elements of thrd_inst_act_map are initialized properly when threads enter functions */
656 void FuncNode::init_inst_act_map(thread_id_t tid)
658 int thread_id = id_to_int(tid);
659 SnapVector<inst_act_map_t *> * thrd_inst_act_map = history->getThrdInstActMap(func_id);
660 uint old_size = thrd_inst_act_map->size();
662 if (old_size <= (uint) thread_id) {
663 uint new_size = thread_id + 1;
664 thrd_inst_act_map->resize(new_size);
666 for (uint i = old_size;i < new_size;i++)
667 (*thrd_inst_act_map)[i] = new inst_act_map_t(128);
671 /* Reset elements of thrd_inst_act_map when threads exit functions */
672 void FuncNode::reset_inst_act_map(thread_id_t tid)
674 int thread_id = id_to_int(tid);
675 SnapVector<inst_act_map_t *> * thrd_inst_act_map = history->getThrdInstActMap(func_id);
677 inst_act_map_t * map = (*thrd_inst_act_map)[thread_id];
681 void FuncNode::update_inst_act_map(thread_id_t tid, ModelAction * read_act)
683 int thread_id = id_to_int(tid);
684 SnapVector<inst_act_map_t *> * thrd_inst_act_map = history->getThrdInstActMap(func_id);
686 inst_act_map_t * map = (*thrd_inst_act_map)[thread_id];
687 FuncInst * read_inst = get_inst(read_act);
688 map->put(read_inst, read_act);
691 inst_act_map_t * FuncNode::get_inst_act_map(thread_id_t tid)
693 int thread_id = id_to_int(tid);
694 SnapVector<inst_act_map_t *> * thrd_inst_act_map = history->getThrdInstActMap(func_id);
696 return (*thrd_inst_act_map)[thread_id];
699 void FuncNode::set_marker(thread_id_t tid)
702 uint thread_id = id_to_int(tid);
703 for (uint i = thrd_marker.size(); i < thread_id + 1; i++) {
704 thrd_marker.push_back(0);
707 thrd_marker[thread_id] = marker;
710 /* Make sure elements of maps are initialized properly when threads enter functions */
711 void FuncNode::init_local_maps(thread_id_t tid)
713 int thread_id = id_to_int(tid);
714 uint old_size = thrd_loc_inst_map.size();
716 if (old_size <= (uint) thread_id) {
717 uint new_size = thread_id + 1;
719 thrd_loc_inst_map.resize(new_size);
720 thrd_inst_id_map.resize(new_size);
721 thrd_inst_pred_map.resize(new_size);
723 for (uint i = old_size; i < new_size; i++) {
724 thrd_loc_inst_map[i] = new loc_inst_map_t(128);
725 thrd_inst_id_map[i] = new inst_id_map_t(128);
726 thrd_inst_pred_map[i] = new inst_pred_map_t(128);
731 /* Reset elements of maps when threads exit functions */
732 void FuncNode::reset_local_maps(thread_id_t tid)
734 int thread_id = id_to_int(tid);
735 thrd_loc_inst_map[thread_id]->reset();
736 thrd_inst_id_map[thread_id]->reset();
737 thrd_inst_pred_map[thread_id]->reset();
740 void FuncNode::init_predicate_tree_data_structure(thread_id_t tid)
742 int thread_id = id_to_int(tid);
743 int old_size = thrd_predicate_tree_position.size();
745 if (old_size <= thread_id + 1) {
746 thrd_predicate_tree_position.resize(thread_id + 1);
747 thrd_predicate_trace.resize(thread_id + 1);
749 for (int i = old_size; i < thread_id + 1; i++) {
750 thrd_predicate_tree_position[i] = new ModelVector<Predicate *>();
751 thrd_predicate_trace[i] = new ModelVector<predicate_trace_t *>();
755 thrd_predicate_tree_position[thread_id]->push_back(predicate_tree_entry);
756 thrd_predicate_trace[thread_id]->push_back(new predicate_trace_t());
759 void FuncNode::reset_predicate_tree_data_structure(thread_id_t tid)
761 int thread_id = id_to_int(tid);
762 thrd_predicate_tree_position[thread_id]->pop_back();
764 predicate_trace_t * trace = thrd_predicate_trace[thread_id]->back();
766 thrd_predicate_trace[thread_id]->pop_back();
769 /* Add FuncNodes that this node may follow */
770 void FuncNode::add_out_edge(FuncNode * other)
772 if ( !edge_table.contains(other) ) {
773 edge_table.put(other, OUT_EDGE);
774 out_edges.push_back(other);
778 edge_type_t edge = edge_table.get(other);
779 if (edge == IN_EDGE) {
780 edge_table.put(other, BI_EDGE);
781 out_edges.push_back(other);
785 /* Compute the distance between this FuncNode and the target node.
786 * Return -1 if the target node is unreachable or the actual distance
787 * is greater than max_step.
789 int FuncNode::compute_distance(FuncNode * target, int max_step)
793 else if (target == this)
796 SnapList<FuncNode *> queue;
797 HashTable<FuncNode *, int, uintptr_t, 0> distances(128);
799 queue.push_back(this);
800 distances.put(this, 0);
802 while (!queue.empty()) {
803 FuncNode * curr = queue.front();
805 int dist = distances.get(curr);
807 if (max_step <= dist)
810 ModelList<FuncNode *> * outEdges = curr->get_out_edges();
811 mllnode<FuncNode *> * it;
812 for (it = outEdges->begin();it != NULL;it = it->getNext()) {
813 FuncNode * out_node = it->getVal();
815 /* This node has not been visited before */
816 if ( !distances.contains(out_node) ) {
817 if (out_node == target)
820 queue.push_back(out_node);
821 distances.put(out_node, dist + 1);
826 /* Target node is unreachable */
830 void FuncNode::add_failed_predicate(Predicate * pred)
832 failed_predicates.add(pred);
835 void FuncNode::update_predicate_tree_weight(thread_id_t tid)
837 failed_predicates.reset();
839 predicate_trace_t * trace = thrd_predicate_trace[id_to_int(tid)]->back();
841 // Update predicate weights based on prediate trace
842 for (mllnode<Predicate *> * rit = trace->end(); rit != NULL; rit = rit->getPrev()) {
843 Predicate * node = rit->getVal();
844 ModelVector<Predicate *> * children = node->get_children();
846 if (children->size() == 0) {
847 double weight = 100.0 / sqrt(node->get_expl_count() + node->get_fail_count() + 1);
848 node->set_weight(weight);
850 double weight_sum = 0.0;
851 for (uint i = 0;i < children->size();i++) {
852 Predicate * child = (*children)[i];
853 double weight = child->get_weight();
854 weight_sum += weight;
857 double average_weight = (double) weight_sum / (double) children->size();
858 double weight = average_weight * pow(0.9, node->get_depth());
859 node->set_weight(weight);
864 void FuncNode::print_predicate_tree()
866 model_print("digraph function_%s {\n", func_name);
867 predicate_tree_entry->print_pred_subtree();
868 predicate_tree_exit->print_predicate();
869 model_print("}\n"); // end of graph