@@ -289,10 +289,12 @@ static void populate_predecessor_map(
289
289
if (it->is_parameter )
290
290
continue ;
291
291
292
- msg.debug () << " ppm: processing var idx " << it->var .index
292
+ #ifdef DEBUG
293
+ msg.debug () << " jcm: ppm: processing var idx " << it->var .index
293
294
<< " name '" << it->var .name << " ' start-pc "
294
295
<< it->var .start_pc << " len " << it->var .length
295
296
<< " ; holes " << it->holes .size () << messaget::eom;
297
+ #endif
296
298
297
299
// Find the last instruction within the live range:
298
300
unsigned end_pc=it->var .start_pc +it->var .length ;
@@ -362,11 +364,11 @@ static void populate_predecessor_map(
362
364
*(inst_before_this->second .source ),
363
365
it->var .index ))
364
366
{
365
- msg.error () << " Local variable table: didn't find initializing "
366
- << " store for predecessor of bytecode at address "
367
- << amapit->first << " ("
368
- << amapit->second .predecessors .size ()
369
- << " predecessors)" << msg.eom ;
367
+ msg.warning () << " Local variable table: didn't find initializing "
368
+ << " store for predecessor of bytecode at address "
369
+ << amapit->first << " ("
370
+ << amapit->second .predecessors .size ()
371
+ << " predecessors)" << msg.eom ;
370
372
throw " local variable table: unexpected live ranges" ;
371
373
}
372
374
new_start_pc=pred;
@@ -541,7 +543,7 @@ static void merge_variable_table_entries(
541
543
// / Given a sequence of users of the same local variable slot, this figures out
542
544
// / which ones are related by control flow, and combines them into a single
543
545
// / entry with holes, such that after combination we can create a single
544
- // / declaration per variable table entry, placed at the live range's start
546
+ // / GOTO variable per variable table entry, placed at the live range's start
545
547
// / address, which may be moved back so that the declaration dominates all uses.
546
548
// / \par parameters: `firstvar`-`varlimit`: sequence of variable table entries,
547
549
// / all of which should concern the same slot index.
@@ -720,8 +722,24 @@ void java_bytecode_convert_methodt::setup_local_variables(
720
722
for (const auto &v : m.local_variable_table )
721
723
vars_with_holes.push_back ({v, is_parameter (v), {}});
722
724
723
- // Merge variable records:
724
- find_initializers (vars_with_holes, amap, dominator_analysis);
725
+ // Merge variable records. See documentation of in
726
+ // `find_initializers_for_slot` for more details. If the strategy employed
727
+ // there fails with an exception, we just ignore the LVT for this method, no
728
+ // variable is generated in `this->variables[]` (because we return here and
729
+ // dont let the for loop below to execute), and as a result the method
730
+ // this->variable() will be forced to create new `anonlocal::` variables, as
731
+ // the only source of variable names for that method is `this->variables[]`.
732
+ try
733
+ {
734
+ find_initializers (vars_with_holes, amap, dominator_analysis);
735
+ }
736
+ catch (const char *message)
737
+ {
738
+ warning () << " Bytecode -> codet translation error: " << message << eom
739
+ << " This is probably due to an unexpected LVT, "
740
+ << " falling back to translation without LVT" << eom;
741
+ return ;
742
+ }
725
743
726
744
// Clean up removed records from the variable table:
727
745
cleanup_var_table (vars_with_holes);
0 commit comments