Skip to content

Commit ddb31a0

Browse files
Extract draw_edges_from_ret_to_jsr function
1 parent 390063f commit ddb31a0

File tree

2 files changed

+25
-11
lines changed

2 files changed

+25
-11
lines changed

jbmc/src/java_bytecode/java_bytecode_convert_method.cpp

+17-11
Original file line numberDiff line numberDiff line change
@@ -1091,17 +1091,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
10911091
ret_instructions.push_back(i_it);
10921092
}
10931093
}
1094-
1095-
// Draw edges from every `ret` to every `jsr` successor. Could do better with
1096-
// flow analysis to distinguish multiple subroutines within the same function.
1097-
for(const auto retinst : ret_instructions)
1098-
{
1099-
auto &a_entry=address_map.at(retinst->address);
1100-
a_entry.successors.insert(
1101-
a_entry.successors.end(),
1102-
jsr_ret_targets.begin(),
1103-
jsr_ret_targets.end());
1104-
}
1094+
draw_edges_from_ret_to_jsr(address_map, jsr_ret_targets, ret_instructions);
11051095

11061096
for(const auto &address : address_map)
11071097
{
@@ -2719,6 +2709,22 @@ codet java_bytecode_convert_methodt::convert_instructions(
27192709
return code;
27202710
}
27212711

2712+
void java_bytecode_convert_methodt::draw_edges_from_ret_to_jsr(
2713+
java_bytecode_convert_methodt::address_mapt &address_map,
2714+
const std::vector<unsigned int> &jsr_ret_targets,
2715+
const std::vector<
2716+
std::vector<java_bytecode_parse_treet::instructiont>::const_iterator>
2717+
&ret_instructions) const
2718+
{ // Draw edges from every `ret` to every `jsr` successor. Could do better with
2719+
// flow analysis to distinguish multiple subroutines within the same function.
2720+
for(const auto &retinst : ret_instructions)
2721+
{
2722+
auto &a_entry = address_map.at(retinst->address);
2723+
a_entry.successors.insert(
2724+
a_entry.successors.end(), jsr_ret_targets.begin(), jsr_ret_targets.end());
2725+
}
2726+
}
2727+
27222728
std::vector<unsigned> java_bytecode_convert_methodt::try_catch_handler(
27232729
const unsigned int address,
27242730
const java_bytecode_parse_treet::methodt::exception_tablet &exception_table)

jbmc/src/java_bytecode/java_bytecode_convert_method_class.h

+8
Original file line numberDiff line numberDiff line change
@@ -279,4 +279,12 @@ class java_bytecode_convert_methodt:public messaget
279279
const java_bytecode_parse_treet::methodt::exception_tablet &exception_table)
280280
const;
281281

282+
void draw_edges_from_ret_to_jsr(
283+
address_mapt &address_map,
284+
const std::vector<unsigned int> &jsr_ret_targets,
285+
const std::vector<
286+
std::vector<java_bytecode_parse_treet::instructiont>::const_iterator>
287+
&ret_instructions) const;
288+
};
289+
282290
#endif

0 commit comments

Comments
 (0)