Skip to content

Commit 06ab440

Browse files
author
Thomas Kiley
authored
Merge pull request #1930 from owen-jones-diffblue/owen-jones-diffblue/skip-duplicate-callsites-in-lazy-methods-v1
Speed up resolution of virtual callsites in lazy loading v1
2 parents 3af5509 + 6eab160 commit 06ab440

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/java_bytecode/ci_lazy_methods.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -170,14 +170,15 @@ bool ci_lazy_methodst::operator()(
170170
<< " callsites)"
171171
<< eom;
172172

173-
for(const auto &callsite : virtual_callsites)
173+
std::unordered_set<exprt, irep_hash> unique_functions;
174+
for(const code_function_callt *virtual_callsite : virtual_callsites)
175+
unique_functions.insert(virtual_callsite->function());
176+
177+
for(const exprt &function : unique_functions)
174178
{
175179
// This will also create a stub if a virtual callsite has no targets.
176180
get_virtual_method_targets(
177-
*callsite,
178-
instantiated_classes,
179-
method_worklist2,
180-
symbol_table);
181+
function, instantiated_classes, method_worklist2, symbol_table);
181182
}
182183
}
183184
while(any_new_methods);
@@ -403,21 +404,20 @@ void ci_lazy_methodst::gather_virtual_callsites(
403404

404405
/// Find possible callees, excluding types that are not known to be
405406
/// instantiated.
406-
/// \param c: function call whose potential target functions should
407-
/// be determined.
407+
/// \param called_function: virtual function call whose concrete function calls
408+
/// should be determined.
408409
/// \param instantiated_classes: set of classes that can be instantiated. Any
409410
/// potential callee not in this set will be ignored.
410411
/// \param symbol_table: global symbol table
411412
/// \param [out] callable_methods: Populated with all possible `c` callees,
412413
/// taking `instantiated_classes` into account (virtual function overrides
413414
/// defined on classes that are not 'needed' are ignored)
414415
void ci_lazy_methodst::get_virtual_method_targets(
415-
const code_function_callt &c,
416+
const exprt &called_function,
416417
const std::set<irep_idt> &instantiated_classes,
417418
std::vector<irep_idt> &callable_methods,
418419
symbol_tablet &symbol_table)
419420
{
420-
const auto &called_function=c.function();
421421
PRECONDITION(called_function.id()==ID_virtual_function);
422422

423423
const auto &call_class=called_function.get(ID_C_class);

src/java_bytecode/ci_lazy_methods.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class ci_lazy_methodst:public messaget
134134
std::vector<const code_function_callt *> &result);
135135

136136
void get_virtual_method_targets(
137-
const code_function_callt &c,
137+
const exprt &called_function,
138138
const std::set<irep_idt> &instantiated_classes,
139139
std::vector<irep_idt> &callable_methods,
140140
symbol_tablet &symbol_table);

0 commit comments

Comments
 (0)