Skip to content

Commit a4ab1ee

Browse files
Make class_to_declared_symbols take multimap argument
This is an intermediary commit that gets us closer to avoiding recomputing this map everytime.
1 parent 6135e97 commit a4ab1ee

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

jbmc/src/java_bytecode/java_bytecode_language.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1212,13 +1212,16 @@ bool java_bytecode_languaget::convert_single_method(
12121212
class_name, "user_specified_clinit must be declared by a class.");
12131213
INVARIANT(
12141214
static_values_json.has_value(), "static-values JSON must be available");
1215+
const auto class_to_declared_symbols_map =
1216+
class_to_declared_symbols(symbol_table);
12151217
writable_symbol.value = get_user_specified_clinit_body(
12161218
*class_name,
12171219
*static_values_json,
12181220
symbol_table,
12191221
needed_lazy_methods,
12201222
max_user_array_length,
1221-
references);
1223+
references,
1224+
class_to_declared_symbols_map);
12221225
break;
12231226
}
12241227
case synthetic_method_typet::STUB_CLASS_STATIC_INITIALIZER:

jbmc/src/java_bytecode/java_static_initializers.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ code_ifthenelset get_clinit_wrapper_body(
768768
}
769769

770770
/// \return map associating classes to the symbols they declare
771-
static std::unordered_multimap<irep_idt, symbolt>
771+
std::unordered_multimap<irep_idt, symbolt>
772772
class_to_declared_symbols(const symbol_tablet &symbol_table)
773773
{
774774
std::unordered_multimap<irep_idt, symbolt> result;
@@ -787,7 +787,9 @@ code_blockt get_user_specified_clinit_body(
787787
symbol_table_baset &symbol_table,
788788
optionalt<ci_lazy_methods_neededt> needed_lazy_methods,
789789
size_t max_user_array_length,
790-
std::unordered_map<std::string, object_creation_referencet> &references)
790+
std::unordered_map<std::string, object_creation_referencet> &references,
791+
const std::unordered_multimap<irep_idt, symbolt>
792+
&class_to_declared_symbols_map)
791793
{
792794
const irep_idt &real_clinit_name = clinit_function_name(class_id);
793795
const auto class_entry =
@@ -799,8 +801,6 @@ code_blockt get_user_specified_clinit_body(
799801
{
800802
const auto &class_json_object = to_json_object(class_json_value);
801803
std::map<symbol_exprt, jsont> static_field_values;
802-
const auto class_to_declared_symbols_map =
803-
class_to_declared_symbols(symbol_table);
804804
for(const auto &symbol_pair :
805805
equal_range(class_to_declared_symbols_map, class_id))
806806
{

jbmc/src/java_bytecode/java_static_initializers.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ code_ifthenelset get_clinit_wrapper_body(
5252
const select_pointer_typet &pointer_type_selector,
5353
message_handlert &message_handler);
5454

55+
/// \return map associating classes to the symbols they declare
56+
std::unordered_multimap<irep_idt, symbolt>
57+
class_to_declared_symbols(const symbol_tablet &symbol_table);
58+
5559
/// Create the body of a user_specified_clinit function for a given class, which
5660
/// includes assignments for all static fields of the class to values read from
5761
/// an input file. If the file could not be parsed or an entry for this class
@@ -72,14 +76,18 @@ code_ifthenelset get_clinit_wrapper_body(
7276
/// arrays. Any arrays that were specified to be of nondeterministic length in
7377
/// the input file will be limited by this value.
7478
/// \param references: map to keep track of reference-equal objets.
79+
/// \param class_to_declared_symbols_map: map classes to the symbols that
80+
/// they declare.
7581
/// \return the body of the user_specified_clinit function as a code block.
7682
code_blockt get_user_specified_clinit_body(
7783
const irep_idt &class_id,
7884
const json_objectt &static_values_json,
7985
symbol_table_baset &symbol_table,
8086
optionalt<ci_lazy_methods_neededt> needed_lazy_methods,
8187
size_t max_user_array_length,
82-
std::unordered_map<std::string, object_creation_referencet> &references);
88+
std::unordered_map<std::string, object_creation_referencet> &references,
89+
const std::unordered_multimap<irep_idt, symbolt>
90+
&class_to_declared_symbols_map);
8391

8492
class stub_global_initializer_factoryt
8593
{

0 commit comments

Comments
 (0)