Skip to content

Commit 17f1d2e

Browse files
authored
Merge pull request #5592 from tautschnig/messaget-ci_lazy_methodst
ci_lazy_methodst isn't a messaget
2 parents 2d803cf + 6d1e47e commit 17f1d2e

File tree

3 files changed

+34
-26
lines changed

3 files changed

+34
-26
lines changed

jbmc/src/java_bytecode/ci_lazy_methods.cpp

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ Author: Diffblue Ltd.
2929
/// removed via `lazy-methods`. Example of use: `ArrayList` as general
3030
/// implementation for `List` interface.
3131
/// \param pointer_type_selector: selector to handle correct pointer types
32-
/// \param message_handler: the message handler to use for output
3332
/// \param synthetic_methods: map from synthetic method names to the type of
3433
/// synthetic method (e.g. stub class static initialiser). Indicates that
3534
/// these method bodies are produced internally, rather than generated from
@@ -42,10 +41,8 @@ ci_lazy_methodst::ci_lazy_methodst(
4241
java_class_loadert &java_class_loader,
4342
const std::vector<irep_idt> &extra_instantiated_classes,
4443
const select_pointer_typet &pointer_type_selector,
45-
message_handlert &message_handler,
4644
const synthetic_methods_mapt &synthetic_methods)
47-
: messaget(message_handler),
48-
main_class(main_class),
45+
: main_class(main_class),
4946
main_jar_classes(main_jar_classes),
5047
lazy_methods_extra_entry_points(lazy_methods_extra_entry_points),
5148
java_class_loader(java_class_loader),
@@ -96,14 +93,16 @@ static bool references_class_model(const exprt &expr)
9693
/// \param [out] method_bytecode: map from method names to relevant symbol and
9794
/// parsed-method objects.
9895
/// \param method_converter: Function for converting methods on demand.
96+
/// \param message_handler: the message handler to use for output
9997
/// \return Returns false on success
10098
bool ci_lazy_methodst::operator()(
10199
symbol_tablet &symbol_table,
102100
method_bytecodet &method_bytecode,
103-
const method_convertert &method_converter)
101+
const method_convertert &method_converter,
102+
message_handlert &message_handler)
104103
{
105104
std::unordered_set<irep_idt> methods_to_convert_later =
106-
entry_point_methods(symbol_table);
105+
entry_point_methods(symbol_table, message_handler);
107106

108107
// Add any extra entry points specified; we should elaborate these in the
109108
// same way as the main function.
@@ -134,6 +133,8 @@ bool ci_lazy_methodst::operator()(
134133
called_virtual_functions;
135134
bool class_initializer_seen = false;
136135

136+
messaget log{message_handler};
137+
137138
bool any_new_classes = true;
138139
while(any_new_classes)
139140
{
@@ -155,7 +156,8 @@ bool ci_lazy_methodst::operator()(
155156
symbol_table,
156157
methods_to_convert_later,
157158
instantiated_classes,
158-
called_virtual_functions);
159+
called_virtual_functions,
160+
message_handler);
159161
any_new_methods |= conversion_result.new_method_seen;
160162
class_initializer_seen |= conversion_result.class_initializer_seen;
161163
}
@@ -164,8 +166,9 @@ bool ci_lazy_methodst::operator()(
164166
// Given the object types we now know may be created, populate more
165167
// possible virtual function call targets:
166168

167-
debug() << "CI lazy methods: add virtual method targets ("
168-
<< called_virtual_functions.size() << " callsites)" << eom;
169+
log.debug() << "CI lazy methods: add virtual method targets ("
170+
<< called_virtual_functions.size() << " callsites)"
171+
<< messaget::eom;
169172

170173
for(const class_method_descriptor_exprt &called_virtual_function :
171174
called_virtual_functions)
@@ -214,9 +217,9 @@ bool ci_lazy_methodst::operator()(
214217
keep_symbols.add(sym.second);
215218
}
216219

217-
debug() << "CI lazy methods: removed "
218-
<< symbol_table.symbols.size() - keep_symbols.symbols.size()
219-
<< " unreachable methods and globals" << eom;
220+
log.debug() << "CI lazy methods: removed "
221+
<< symbol_table.symbols.size() - keep_symbols.symbols.size()
222+
<< " unreachable methods and globals" << messaget::eom;
220223

221224
symbol_table.swap(keep_symbols);
222225

@@ -322,13 +325,15 @@ ci_lazy_methodst::convert_and_analyze_method(
322325
std::unordered_set<irep_idt> &methods_to_convert_later,
323326
std::unordered_set<irep_idt> &instantiated_classes,
324327
std::unordered_set<class_method_descriptor_exprt, irep_hash>
325-
&called_virtual_functions)
328+
&called_virtual_functions,
329+
message_handlert &message_handler)
326330
{
327331
convert_method_resultt result;
328332
if(!methods_already_populated.insert(method_name).second)
329333
return result;
330334

331-
debug() << "CI lazy methods: elaborate " << method_name << eom;
335+
messaget log{message_handler};
336+
log.debug() << "CI lazy methods: elaborate " << method_name << messaget::eom;
332337

333338
// Note this wraps *references* to methods_to_convert_later &
334339
// instantiated_classes
@@ -361,13 +366,14 @@ ci_lazy_methodst::convert_and_analyze_method(
361366
/// * all the methods of the main class if it is not empty
362367
/// * all the methods of the main jar file
363368
/// \return set of identifiers of entry point methods
364-
std::unordered_set<irep_idt>
365-
ci_lazy_methodst::entry_point_methods(const symbol_tablet &symbol_table)
369+
std::unordered_set<irep_idt> ci_lazy_methodst::entry_point_methods(
370+
const symbol_tablet &symbol_table,
371+
message_handlert &message_handler)
366372
{
367373
std::unordered_set<irep_idt> methods_to_convert_later;
368374

369-
const main_function_resultt main_function = get_main_symbol(
370-
symbol_table, this->main_class, this->get_message_handler());
375+
const main_function_resultt main_function =
376+
get_main_symbol(symbol_table, this->main_class, message_handler);
371377
if(!main_function.is_success())
372378
{
373379
// Failed, mark all functions in the given main class(es)

jbmc/src/java_bytecode/ci_lazy_methods.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ typedef std::function<
9494
typedef std::function<std::vector<irep_idt>(const symbol_tablet &)>
9595
load_extra_methodst;
9696

97-
class ci_lazy_methodst:public messaget
97+
class ci_lazy_methodst
9898
{
9999
public:
100100
ci_lazy_methodst(
@@ -105,14 +105,14 @@ class ci_lazy_methodst:public messaget
105105
java_class_loadert &java_class_loader,
106106
const std::vector<irep_idt> &extra_instantiated_classes,
107107
const select_pointer_typet &pointer_type_selector,
108-
message_handlert &message_handler,
109108
const synthetic_methods_mapt &synthetic_methods);
110109

111110
// not const since messaget
112111
bool operator()(
113112
symbol_tablet &symbol_table,
114113
method_bytecodet &method_bytecode,
115-
const method_convertert &method_converter);
114+
const method_convertert &method_converter,
115+
message_handlert &message_handler);
116116

117117
private:
118118
void initialize_instantiated_classes(
@@ -154,8 +154,9 @@ class ci_lazy_methodst:public messaget
154154
const select_pointer_typet &pointer_type_selector;
155155
const synthetic_methods_mapt &synthetic_methods;
156156

157-
std::unordered_set<irep_idt>
158-
entry_point_methods(const symbol_tablet &symbol_table);
157+
std::unordered_set<irep_idt> entry_point_methods(
158+
const symbol_tablet &symbol_table,
159+
message_handlert &message_handler);
159160

160161
struct convert_method_resultt
161162
{
@@ -172,7 +173,8 @@ class ci_lazy_methodst:public messaget
172173
std::unordered_set<irep_idt> &methods_to_convert_later,
173174
std::unordered_set<irep_idt> &instantiated_classes,
174175
std::unordered_set<class_method_descriptor_exprt, irep_hash>
175-
&called_virtual_functions);
176+
&called_virtual_functions,
177+
message_handlert &message_handler);
176178

177179
bool handle_virtual_methods_with_no_callees(
178180
std::unordered_set<irep_idt> &methods_to_convert_later,

jbmc/src/java_bytecode/java_bytecode_language.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,10 +1141,10 @@ bool java_bytecode_languaget::do_ci_lazy_method_conversion(
11411141
java_class_loader,
11421142
language_options->java_load_classes,
11431143
get_pointer_type_selector(),
1144-
get_message_handler(),
11451144
synthetic_methods);
11461145

1147-
return method_gather(symbol_table, method_bytecode, method_converter);
1146+
return method_gather(
1147+
symbol_table, method_bytecode, method_converter, get_message_handler());
11481148
}
11491149

11501150
const select_pointer_typet &

0 commit comments

Comments
 (0)