@@ -257,17 +257,25 @@ static void get_virtual_method_targets(
257
257
auto child_classes=class_hierarchy.get_children_trans (call_class);
258
258
for (const auto & child_class : child_classes)
259
259
{
260
- auto child_method=get_virtual_method_target (needed_classes,call_basename,
261
- child_class,symbol_table);
260
+ auto child_method=
261
+ get_virtual_method_target (
262
+ needed_classes,
263
+ call_basename,
264
+ child_class,
265
+ symbol_table);
262
266
if (child_method!=irep_idt ())
263
267
needed_methods.push_back (child_method);
264
268
}
265
269
266
270
irep_idt parent_class_id=call_class;
267
271
while (1 )
268
272
{
269
- auto parent_method=get_virtual_method_target (needed_classes,call_basename,
270
- parent_class_id,symbol_table);
273
+ auto parent_method=
274
+ get_virtual_method_target (
275
+ needed_classes,
276
+ call_basename,
277
+ parent_class_id,
278
+ symbol_table);
271
279
if (parent_method!=irep_idt ())
272
280
{
273
281
needed_methods.push_back (parent_method);
@@ -301,7 +309,6 @@ static void get_virtual_method_targets(
301
309
symbol.mode =ID_java;
302
310
symbol_table.add (symbol);
303
311
}
304
-
305
312
}
306
313
307
314
/* ******************************************************************\
@@ -317,7 +324,9 @@ Function: gather_virtual_callsites
317
324
318
325
\*******************************************************************/
319
326
320
- static void gather_virtual_callsites (const exprt& e, std::vector<const code_function_callt*>& result)
327
+ static void gather_virtual_callsites (
328
+ const exprt& e,
329
+ std::vector<const code_function_callt*>& result)
321
330
{
322
331
if (e.id ()!=ID_code)
323
332
return ;
@@ -326,8 +335,8 @@ static void gather_virtual_callsites(const exprt& e, std::vector<const code_func
326
335
to_code_function_call (c).function ().id ()==ID_virtual_function)
327
336
result.push_back (&to_code_function_call (c));
328
337
else
329
- forall_operands (it,e)
330
- gather_virtual_callsites (*it,result);
338
+ forall_operands (it, e)
339
+ gather_virtual_callsites (*it, result);
331
340
}
332
341
333
342
/* ******************************************************************\
@@ -344,7 +353,10 @@ Function: gather_needed_globals
344
353
345
354
\*******************************************************************/
346
355
347
- static void gather_needed_globals (const exprt& e, const symbol_tablet& symbol_table, symbol_tablet& needed)
356
+ static void gather_needed_globals (
357
+ const exprt& e,
358
+ const symbol_tablet& symbol_table,
359
+ symbol_tablet& needed)
348
360
{
349
361
if (e.id ()==ID_symbol)
350
362
{
@@ -353,8 +365,8 @@ static void gather_needed_globals(const exprt& e, const symbol_tablet& symbol_ta
353
365
needed.add (sym);
354
366
}
355
367
else
356
- forall_operands (opit,e)
357
- gather_needed_globals (*opit,symbol_table,needed);
368
+ forall_operands (opit, e)
369
+ gather_needed_globals (*opit, symbol_table, needed);
358
370
}
359
371
360
372
/* ******************************************************************\
@@ -383,15 +395,16 @@ static void gather_field_types(
383
395
for (const auto & field : underlying_type.components ())
384
396
{
385
397
if (field.type ().id ()==ID_struct || field.type ().id ()==ID_symbol)
386
- gather_field_types (field.type (),ns,needed_classes);
398
+ gather_field_types (field.type (), ns, needed_classes);
387
399
else if (field.type ().id ()==ID_pointer)
388
400
{
389
401
// Skip array primitive pointers, for example:
390
402
if (field.type ().subtype ().id ()!=ID_symbol)
391
- continue ;
392
- const auto & field_classid=to_symbol_type (field.type ().subtype ()).get_identifier ();
403
+ continue ;
404
+ const auto & field_classid=
405
+ to_symbol_type (field.type ().subtype ()).get_identifier ();
393
406
if (needed_classes.insert (field_classid).second )
394
- gather_field_types (field.type ().subtype (),ns,needed_classes);
407
+ gather_field_types (field.type ().subtype (), ns, needed_classes);
395
408
}
396
409
}
397
410
}
@@ -427,12 +440,14 @@ static void initialise_needed_classes(
427
440
{
428
441
if (param.type ().id ()==ID_pointer)
429
442
{
430
- const auto & param_classid=to_symbol_type (param.type ().subtype ()).get_identifier ();
431
- std::vector<irep_idt> class_and_parents=ch.get_parents_trans (param_classid);
443
+ const auto & param_classid=
444
+ to_symbol_type (param.type ().subtype ()).get_identifier ();
445
+ std::vector<irep_idt> class_and_parents=
446
+ ch.get_parents_trans (param_classid);
432
447
class_and_parents.push_back (param_classid);
433
448
for (const auto & classid : class_and_parents)
434
449
needed_classes.insert (classid);
435
- gather_field_types (param.type ().subtype (),ns,needed_classes);
450
+ gather_field_types (param.type ().subtype (), ns, needed_classes);
436
451
}
437
452
}
438
453
}
@@ -483,7 +498,8 @@ bool java_bytecode_languaget::typecheck(
483
498
return true ;
484
499
}
485
500
486
- // Now incrementally elaborate methods that are reachable from this entry point.
501
+ // Now incrementally elaborate methods
502
+ // that are reachable from this entry point.
487
503
if (lazy_methods_mode==LAZY_METHODS_MODE_CONTEXT_INSENSITIVE)
488
504
{
489
505
if (do_ci_lazy_method_conversion (symbol_table, lazy_methods))
@@ -508,7 +524,8 @@ bool java_bytecode_languaget::do_ci_lazy_method_conversion(
508
524
std::vector<irep_idt> method_worklist1;
509
525
std::vector<irep_idt> method_worklist2;
510
526
511
- auto main_function=get_main_symbol (symbol_table,main_class,get_message_handler (),true );
527
+ auto main_function=
528
+ get_main_symbol (symbol_table, main_class, get_message_handler (), true );
512
529
if (main_function.stop_convert )
513
530
{
514
531
// Failed, mark all functions in the given main class(es) reachable.
@@ -519,7 +536,8 @@ bool java_bytecode_languaget::do_ci_lazy_method_conversion(
519
536
reachable_classes=main_jar_classes;
520
537
for (const auto & classname : reachable_classes)
521
538
{
522
- const auto & methods=java_class_loader.class_map .at (classname).parsed_class .methods ;
539
+ const auto & methods=
540
+ java_class_loader.class_map .at (classname).parsed_class .methods ;
523
541
for (const auto & method : methods)
524
542
{
525
543
const irep_idt methodid=" java::" +id2string (classname)+" ." +
@@ -533,18 +551,22 @@ bool java_bytecode_languaget::do_ci_lazy_method_conversion(
533
551
method_worklist2.push_back (main_function.main_function .name );
534
552
535
553
std::set<irep_idt> needed_classes;
536
- initialise_needed_classes (method_worklist2,namespacet (symbol_table),ch,needed_classes);
554
+ initialise_needed_classes (
555
+ method_worklist2,
556
+ namespacet (symbol_table),
557
+ ch,
558
+ needed_classes);
537
559
538
560
std::set<irep_idt> methods_already_populated;
539
561
std::vector<const code_function_callt*> virtual_callsites;
540
562
541
563
bool any_new_methods;
542
- do {
543
-
564
+ do
565
+ {
544
566
any_new_methods=false ;
545
567
while (method_worklist2.size ()!=0 )
546
568
{
547
- std::swap (method_worklist1,method_worklist2);
569
+ std::swap (method_worklist1, method_worklist2);
548
570
for (const auto & mname : method_worklist1)
549
571
{
550
572
if (!methods_already_populated.insert (mname).second )
@@ -566,7 +588,9 @@ bool java_bytecode_languaget::do_ci_lazy_method_conversion(
566
588
max_user_array_length,
567
589
&method_worklist2,
568
590
&needed_classes);
569
- gather_virtual_callsites (symbol_table.lookup (mname).value ,virtual_callsites);
591
+ gather_virtual_callsites (
592
+ symbol_table.lookup (mname).value ,
593
+ virtual_callsites);
570
594
any_new_methods=true ;
571
595
}
572
596
method_worklist1.clear ();
@@ -575,14 +599,16 @@ bool java_bytecode_languaget::do_ci_lazy_method_conversion(
575
599
// Given the object types we now know may be created, populate more
576
600
// possible virtual function call targets:
577
601
578
- debug () << " CI lazy methods: add virtual method targets (" << virtual_callsites.size () <<
579
- " callsites)" << eom;
602
+ debug () << " CI lazy methods: add virtual method targets ("
603
+ << virtual_callsites.size ()
604
+ << " callsites)"
605
+ << eom;
580
606
581
607
for (const auto & callsite : virtual_callsites)
582
608
{
583
609
// This will also create a stub if a virtual callsite has no targets.
584
- get_virtual_method_targets (*callsite,needed_classes,method_worklist2,
585
- symbol_table,ch);
610
+ get_virtual_method_targets (*callsite, needed_classes, method_worklist2,
611
+ symbol_table, ch);
586
612
}
587
613
588
614
} while (any_new_methods);
@@ -594,14 +620,20 @@ bool java_bytecode_languaget::do_ci_lazy_method_conversion(
594
620
{
595
621
if (sym.second .is_static_lifetime )
596
622
continue ;
597
- if (lazy_methods.count (sym.first ) && !methods_already_populated.count (sym.first ))
623
+ if (lazy_methods.count (sym.first ) &&
624
+ !methods_already_populated.count (sym.first ))
625
+ {
598
626
continue ;
627
+ }
599
628
if (sym.second .type .id ()==ID_code)
600
- gather_needed_globals (sym.second .value ,symbol_table,keep_symbols);
629
+ gather_needed_globals (sym.second .value , symbol_table, keep_symbols);
601
630
keep_symbols.add (sym.second );
602
631
}
603
632
604
- debug () << " CI lazy methods: removed " << symbol_table.symbols .size () - keep_symbols.symbols .size () << " unreachable methods and globals" << eom;
633
+ debug () << " CI lazy methods: removed "
634
+ << symbol_table.symbols .size () - keep_symbols.symbols .size ()
635
+ << " unreachable methods and globals"
636
+ << eom;
605
637
606
638
symbol_table.swap (keep_symbols);
607
639
0 commit comments