Skip to content

Speed up resolution of virtual callsites in lazy loading v1 #1930

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/java_bytecode/ci_lazy_methods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,15 @@ bool ci_lazy_methodst::operator()(
<< " callsites)"
<< eom;

for(const auto &callsite : virtual_callsites)
std::unordered_set<exprt, irep_hash> unique_functions;
for(const code_function_callt *virtual_callsite : virtual_callsites)
unique_functions.insert(virtual_callsite->function());

for(const exprt &function : unique_functions)
{
// This will also create a stub if a virtual callsite has no targets.
get_virtual_method_targets(
*callsite,
instantiated_classes,
method_worklist2,
symbol_table);
function, instantiated_classes, method_worklist2, symbol_table);
}
}
while(any_new_methods);
Expand Down Expand Up @@ -403,21 +404,20 @@ void ci_lazy_methodst::gather_virtual_callsites(

/// Find possible callees, excluding types that are not known to be
/// instantiated.
/// \param c: function call whose potential target functions should
/// be determined.
/// \param called_function: virtual function call whose concrete function calls
/// should be determined.
/// \param instantiated_classes: set of classes that can be instantiated. Any
/// potential callee not in this set will be ignored.
/// \param symbol_table: global symbol table
/// \param [out] callable_methods: Populated with all possible `c` callees,
/// taking `instantiated_classes` into account (virtual function overrides
/// defined on classes that are not 'needed' are ignored)
void ci_lazy_methodst::get_virtual_method_targets(
const code_function_callt &c,
const exprt &called_function,
const std::set<irep_idt> &instantiated_classes,
std::vector<irep_idt> &callable_methods,
symbol_tablet &symbol_table)
{
const auto &called_function=c.function();
PRECONDITION(called_function.id()==ID_virtual_function);

const auto &call_class=called_function.get(ID_C_class);
Expand Down
2 changes: 1 addition & 1 deletion src/java_bytecode/ci_lazy_methods.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class ci_lazy_methodst:public messaget
std::vector<const code_function_callt *> &result);

void get_virtual_method_targets(
const code_function_callt &c,
const exprt &called_function,
const std::set<irep_idt> &instantiated_classes,
std::vector<irep_idt> &callable_methods,
symbol_tablet &symbol_table);
Expand Down