@@ -7,17 +7,19 @@ Author: Diffblue Ltd.
77\*******************************************************************/
88
99#include " ci_lazy_methods.h"
10- #include " java_bytecode_language.h"
11- #include " java_class_loader.h"
12- #include " java_entry_point.h"
13- #include " remove_exceptions.h"
1410
1511#include < util/expr_iterator.h>
1612#include < util/namespace.h>
1713#include < util/suffix.h>
14+ #include < util/symbol_table.h>
1815
1916#include < goto-programs/resolve_inherited_component.h>
2017
18+ #include " java_bytecode_language.h"
19+ #include " java_class_loader.h"
20+ #include " java_entry_point.h"
21+ #include " remove_exceptions.h"
22+
2123// / Constructor for lazy-method loading
2224// / \param symbol_table: the symbol table to use
2325// / \param main_class: identifier of the entry point / main class
@@ -34,7 +36,7 @@ Author: Diffblue Ltd.
3436// / these method bodies are produced internally, rather than generated from
3537// / Java bytecode.
3638ci_lazy_methodst::ci_lazy_methodst (
37- const symbol_tablet &symbol_table,
39+ const symbol_table_baset &symbol_table,
3840 const irep_idt &main_class,
3941 const std::vector<irep_idt> &main_jar_classes,
4042 const std::vector<load_extra_methodst> &lazy_methods_extra_entry_points,
@@ -96,7 +98,7 @@ static bool references_class_model(const exprt &expr)
9698// / \param message_handler: the message handler to use for output
9799// / \return Returns false on success
98100bool ci_lazy_methodst::operator ()(
99- symbol_tablet &symbol_table,
101+ symbol_table_baset &symbol_table,
100102 method_bytecodet &method_bytecode,
101103 const method_convertert &method_converter,
102104 message_handlert &message_handler)
@@ -221,7 +223,16 @@ bool ci_lazy_methodst::operator()(
221223 << symbol_table.symbols .size () - keep_symbols.symbols .size ()
222224 << " unreachable methods and globals" << messaget::eom;
223225
224- symbol_table.swap (keep_symbols);
226+ auto sorted_to_keep = keep_symbols.sorted_symbol_names ();
227+ auto all_sorted = symbol_table.sorted_symbol_names ();
228+ auto it = sorted_to_keep.cbegin ();
229+ for (const auto &id : all_sorted)
230+ {
231+ if (it == sorted_to_keep.cend () || id != *it)
232+ symbol_table.remove (id);
233+ else
234+ ++it;
235+ }
225236
226237 return false ;
227238}
@@ -238,7 +249,7 @@ bool ci_lazy_methodst::handle_virtual_methods_with_no_callees(
238249 std::unordered_set<irep_idt> &instantiated_classes,
239250 const std::unordered_set<class_method_descriptor_exprt, irep_hash>
240251 &virtual_functions,
241- symbol_tablet &symbol_table)
252+ symbol_table_baset &symbol_table)
242253{
243254 ci_lazy_methods_neededt lazy_methods_loader (
244255 methods_to_convert_later,
@@ -321,7 +332,7 @@ ci_lazy_methodst::convert_and_analyze_method(
321332 std::unordered_set<irep_idt> &methods_already_populated,
322333 const bool class_initializer_already_seen,
323334 const irep_idt &method_name,
324- symbol_tablet &symbol_table,
335+ symbol_table_baset &symbol_table,
325336 std::unordered_set<irep_idt> &methods_to_convert_later,
326337 std::unordered_set<irep_idt> &instantiated_classes,
327338 std::unordered_set<class_method_descriptor_exprt, irep_hash>
@@ -367,7 +378,7 @@ ci_lazy_methodst::convert_and_analyze_method(
367378// / * all the methods of the main jar file
368379// / \return set of identifiers of entry point methods
369380std::unordered_set<irep_idt> ci_lazy_methodst::entry_point_methods (
370- const symbol_tablet &symbol_table,
381+ const symbol_table_baset &symbol_table,
371382 message_handlert &message_handler)
372383{
373384 std::unordered_set<irep_idt> methods_to_convert_later;
@@ -481,7 +492,7 @@ void ci_lazy_methodst::get_virtual_method_targets(
481492 const class_method_descriptor_exprt &called_function,
482493 const std::unordered_set<irep_idt> &instantiated_classes,
483494 std::unordered_set<irep_idt> &callable_methods,
484- symbol_tablet &symbol_table)
495+ symbol_table_baset &symbol_table)
485496{
486497 const auto &call_class = called_function.class_id ();
487498 const auto &method_name = called_function.mangled_method_name ();
@@ -506,8 +517,8 @@ void ci_lazy_methodst::get_virtual_method_targets(
506517// / `e` or its children.
507518void ci_lazy_methodst::gather_needed_globals (
508519 const exprt &e,
509- const symbol_tablet &symbol_table,
510- symbol_tablet &needed)
520+ const symbol_table_baset &symbol_table,
521+ symbol_table_baset &needed)
511522{
512523 if (e.id ()==ID_symbol)
513524 {
@@ -546,7 +557,7 @@ irep_idt ci_lazy_methodst::get_virtual_method_target(
546557 const std::unordered_set<irep_idt> &instantiated_classes,
547558 const irep_idt &call_basename,
548559 const irep_idt &classname,
549- const symbol_tablet &symbol_table)
560+ const symbol_table_baset &symbol_table)
550561{
551562 // Program-wide, is this class ever instantiated?
552563 if (!instantiated_classes.count (classname))
0 commit comments