Skip to content

Commit 3f31ca5

Browse files
author
Owen Jones
committed
Store virtual function calls instead of virtual call-sites
Also, use an unordered list instead of a vector so we don't have to deduplicate
1 parent 0e205be commit 3f31ca5

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

src/java_bytecode/ci_lazy_methods.cpp

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ bool ci_lazy_methodst::operator()(
120120
}
121121

122122
std::unordered_set<irep_idt> methods_already_populated;
123-
std::vector<const code_function_callt *> virtual_callsites;
123+
std::unordered_set<exprt, irep_hash> virtual_function_calls;
124124

125125
bool any_new_methods = true;
126126
while(any_new_methods)
@@ -147,8 +147,7 @@ bool ci_lazy_methodst::operator()(
147147
continue;
148148
}
149149
gather_virtual_callsites(
150-
symbol_table.lookup_ref(mname).value,
151-
virtual_callsites);
150+
symbol_table.lookup_ref(mname).value, virtual_function_calls);
152151
any_new_methods=true;
153152
}
154153
}
@@ -157,15 +156,9 @@ bool ci_lazy_methodst::operator()(
157156
// possible virtual function call targets:
158157

159158
debug() << "CI lazy methods: add virtual method targets ("
160-
<< virtual_callsites.size()
161-
<< " callsites)"
162-
<< eom;
159+
<< virtual_function_calls.size() << " callsites)" << eom;
163160

164-
std::unordered_set<exprt, irep_hash> unique_functions;
165-
for(const code_function_callt *virtual_callsite : virtual_callsites)
166-
unique_functions.insert(virtual_callsite->function());
167-
168-
for(const exprt &function : unique_functions)
161+
for(const exprt &function : virtual_function_calls)
169162
{
170163
// This will also create a stub if a virtual callsite has no targets.
171164
get_virtual_method_targets(
@@ -375,15 +368,15 @@ void ci_lazy_methodst::initialize_instantiated_classes_from_pointer(
375368
/// e that calls a virtual function.
376369
void ci_lazy_methodst::gather_virtual_callsites(
377370
const exprt &e,
378-
std::vector<const code_function_callt *> &result)
371+
std::unordered_set<exprt, irep_hash> &result)
379372
{
380373
if(e.id()!=ID_code)
381374
return;
382375
const codet &c=to_code(e);
383376
if(c.get_statement()==ID_function_call &&
384377
to_code_function_call(c).function().id()==ID_virtual_function)
385378
{
386-
result.push_back(&to_code_function_call(c));
379+
result.insert(to_code_function_call(c).function());
387380
}
388381
else
389382
{

src/java_bytecode/ci_lazy_methods.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class ci_lazy_methodst:public messaget
131131

132132
void gather_virtual_callsites(
133133
const exprt &e,
134-
std::vector<const code_function_callt *> &result);
134+
std::unordered_set<exprt, irep_hash> &result);
135135

136136
void get_virtual_method_targets(
137137
const exprt &called_function,

0 commit comments

Comments
 (0)