Skip to content

Commit 668f30f

Browse files
committed
Always convert methods in two phases, even in eager mode
Previously in lazy mode we first converted all the method prototypes, then later populated bodies, while in eager mode bodies were populated as we went. Now we always use the former method, so eager mode is like lazy mode except we then populate every method regardless of reachability. This makes the process more uniform, and as a useful side-effect means that the symbol table is populated by the time method conversion happens, so we can check for static initialisers' existence or otherwise.
1 parent 318ab86 commit 668f30f

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/java_bytecode/java_bytecode_convert_class.cpp

+1-15
Original file line numberDiff line numberDiff line change
@@ -171,21 +171,7 @@ void java_bytecode_convert_classt::convert(const classt &c)
171171
method_identifier,
172172
method,
173173
symbol_table);
174-
if(lazy_methods_mode==LAZY_METHODS_MODE_EAGER)
175-
{
176-
// Upgrade to a fully-realized symbol now:
177-
java_bytecode_convert_method(
178-
*class_symbol,
179-
method,
180-
symbol_table,
181-
get_message_handler(),
182-
max_array_length);
183-
}
184-
else
185-
{
186-
// Wait for our caller to decide what needs elaborating.
187-
lazy_methods[method_identifier]=std::make_pair(class_symbol, &method);
188-
}
174+
lazy_methods[method_identifier]=std::make_pair(class_symbol, &method);
189175
}
190176

191177
// is this a root class?

src/java_bytecode/java_bytecode_language.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,20 @@ bool java_bytecode_languaget::typecheck(
542542
if(do_ci_lazy_method_conversion(symbol_table, lazy_methods))
543543
return true;
544544
}
545+
else if(lazy_methods_mode==LAZY_METHODS_MODE_EAGER)
546+
{
547+
// Simply elaborate all methods symbols now.
548+
for(const auto &method_sig : lazy_methods)
549+
{
550+
java_bytecode_convert_method(
551+
*method_sig.second.first,
552+
*method_sig.second.second,
553+
symbol_table,
554+
get_message_handler(),
555+
max_user_array_length);
556+
}
557+
}
558+
// Otherwise our caller is in charge of elaborating methods on demand.
545559

546560
// now typecheck all
547561
if(java_bytecode_typecheck(

0 commit comments

Comments
 (0)