22
22
// / \param main_jar_classes: specify main class of jar if \p main_class is empty
23
23
// / \param lazy_methods_extra_entry_points: entry point functions to use
24
24
// / \param java_class_loader: the Java class loader to use
25
- // / \param extra_needed_classes : list of class identifiers which are considered
26
- // / to be required and therefore their methods should not be removed via
27
- // / `lazy-methods`. Example of use: `ArrayList` as general implementation for
28
- // / `List` interface.
25
+ // / \param extra_instantiated_classes : list of class identifiers which are
26
+ // / considered to be required and therefore their methods should not be
27
+ // / removed via `lazy-methods`. Example of use: `ArrayList` as general
28
+ // / implementation for `List` interface.
29
29
// / \param pointer_type_selector: selector to handle correct pointer types
30
30
// / \param message_handler: the message handler to use for output
31
31
ci_lazy_methodst::ci_lazy_methodst (
@@ -34,7 +34,7 @@ ci_lazy_methodst::ci_lazy_methodst(
34
34
const std::vector<irep_idt> &main_jar_classes,
35
35
const std::vector<irep_idt> &lazy_methods_extra_entry_points,
36
36
java_class_loadert &java_class_loader,
37
- const std::vector<irep_idt> &extra_needed_classes ,
37
+ const std::vector<irep_idt> &extra_instantiated_classes ,
38
38
const select_pointer_typet &pointer_type_selector,
39
39
message_handlert &message_handler,
40
40
const synthetic_methods_mapt &synthetic_methods)
@@ -43,7 +43,7 @@ ci_lazy_methodst::ci_lazy_methodst(
43
43
main_jar_classes(main_jar_classes),
44
44
lazy_methods_extra_entry_points(lazy_methods_extra_entry_points),
45
45
java_class_loader(java_class_loader),
46
- extra_needed_classes(extra_needed_classes ),
46
+ extra_instantiated_classes(extra_instantiated_classes ),
47
47
pointer_type_selector(pointer_type_selector),
48
48
synthetic_methods(synthetic_methods)
49
49
{
@@ -110,22 +110,22 @@ bool ci_lazy_methodst::operator()(
110
110
extra_entry_points.begin (),
111
111
extra_entry_points.end ());
112
112
113
- std::set<irep_idt> needed_classes ;
113
+ std::set<irep_idt> instantiated_classes ;
114
114
115
115
{
116
- std::vector<irep_idt> initial_needed_methods ;
116
+ std::vector<irep_idt> initial_callable_methods ;
117
117
ci_lazy_methods_neededt initial_lazy_methods (
118
- initial_needed_methods ,
119
- needed_classes ,
118
+ initial_callable_methods ,
119
+ instantiated_classes ,
120
120
symbol_table);
121
- initialize_needed_classes (
121
+ initialize_instantiated_classes (
122
122
method_worklist2,
123
123
namespacet (symbol_table),
124
124
initial_lazy_methods);
125
125
method_worklist2.insert (
126
126
method_worklist2.end (),
127
- initial_needed_methods .begin (),
128
- initial_needed_methods .end ());
127
+ initial_callable_methods .begin (),
128
+ initial_callable_methods .end ());
129
129
}
130
130
131
131
std::set<irep_idt> methods_already_populated;
@@ -146,9 +146,10 @@ bool ci_lazy_methodst::operator()(
146
146
if (
147
147
method_converter (
148
148
mname,
149
- // Note this wraps *references* to method_worklist2 & needed_classes
149
+ // Note this wraps *references* to method_worklist2 &
150
+ // instantiated_classes
150
151
ci_lazy_methods_neededt (
151
- method_worklist2, needed_classes , symbol_table)))
152
+ method_worklist2, instantiated_classes , symbol_table)))
152
153
{
153
154
// Couldn't convert this function
154
155
continue ;
@@ -174,7 +175,7 @@ bool ci_lazy_methodst::operator()(
174
175
// This will also create a stub if a virtual callsite has no targets.
175
176
get_virtual_method_targets (
176
177
*callsite,
177
- needed_classes ,
178
+ instantiated_classes ,
178
179
method_worklist2,
179
180
symbol_table);
180
181
}
@@ -275,7 +276,7 @@ void ci_lazy_methodst::resolve_method_names(
275
276
// / \param [out] needed_lazy_methods: Populated with all Java reference types
276
277
// / whose references may be passed, directly or indirectly, to any of the
277
278
// / functions in `entry_points`.
278
- void ci_lazy_methodst::initialize_needed_classes (
279
+ void ci_lazy_methodst::initialize_instantiated_classes (
279
280
const std::vector<irep_idt> &entry_points,
280
281
const namespacet &ns,
281
282
ci_lazy_methods_neededt &needed_lazy_methods)
@@ -289,7 +290,7 @@ void ci_lazy_methodst::initialize_needed_classes(
289
290
if (param.type ().id ()==ID_pointer)
290
291
{
291
292
const pointer_typet &original_pointer=to_pointer_type (param.type ());
292
- initialize_all_needed_classes_from_pointer (
293
+ initialize_all_instantiated_classes_from_pointer (
293
294
original_pointer, ns, needed_lazy_methods);
294
295
}
295
296
}
@@ -303,24 +304,27 @@ void ci_lazy_methodst::initialize_needed_classes(
303
304
needed_lazy_methods.add_needed_class (" java::java.lang.Object" );
304
305
305
306
// As in class_loader, ensure these classes stay available
306
- for (const auto &id : extra_needed_classes )
307
+ for (const auto &id : extra_instantiated_classes )
307
308
needed_lazy_methods.add_needed_class (" java::" + id2string (id));
308
309
}
309
310
310
311
// / Build up list of methods for types for a pointer and any types it
311
312
// / might be subsituted for. See
312
- // / `initialize_needed_classes ` for more details.
313
+ // / `initialize_instantiated_classes ` for more details.
313
314
// / \param pointer_type: The type to gather methods for.
314
315
// / \param ns: global namespace
315
316
// / \param [out] needed_lazy_methods: Populated with all Java reference types
316
317
// / whose references may be passed, directly or indirectly, to any of the
317
318
// / functions in `entry_points`
318
- void ci_lazy_methodst::initialize_all_needed_classes_from_pointer (
319
+ void ci_lazy_methodst::initialize_all_instantiated_classes_from_pointer (
319
320
const pointer_typet &pointer_type,
320
321
const namespacet &ns,
321
322
ci_lazy_methods_neededt &needed_lazy_methods)
322
323
{
323
- initialize_needed_classes_from_pointer (pointer_type, ns, needed_lazy_methods);
324
+ initialize_instantiated_classes_from_pointer (
325
+ pointer_type,
326
+ ns,
327
+ needed_lazy_methods);
324
328
325
329
// TODO we should be passing here a map that maps generic parameters
326
330
// to concrete types in the current context TG-2664
@@ -329,19 +333,19 @@ void ci_lazy_methodst::initialize_all_needed_classes_from_pointer(
329
333
330
334
if (subbed_pointer_type!=pointer_type)
331
335
{
332
- initialize_needed_classes_from_pointer (
336
+ initialize_instantiated_classes_from_pointer (
333
337
subbed_pointer_type, ns, needed_lazy_methods);
334
338
}
335
339
}
336
340
337
341
// / Build up list of methods for types for a specific pointer type. See
338
- // / `initialize_needed_classes ` for more details.
342
+ // / `initialize_instantiated_classes ` for more details.
339
343
// / \param pointer_type: The type to gather methods for.
340
344
// / \param ns: global namespace
341
345
// / \param [out] needed_lazy_methods: Populated with all Java reference types
342
346
// / whose references may be passed, directly or indirectly, to any of the
343
347
// / functions in `entry_points`
344
- void ci_lazy_methodst::initialize_needed_classes_from_pointer (
348
+ void ci_lazy_methodst::initialize_instantiated_classes_from_pointer (
345
349
const pointer_typet &pointer_type,
346
350
const namespacet &ns,
347
351
ci_lazy_methods_neededt &needed_lazy_methods)
@@ -367,7 +371,7 @@ void ci_lazy_methodst::initialize_needed_classes_from_pointer(
367
371
{
368
372
if (!is_java_generic_parameter (generic_arg))
369
373
{
370
- initialize_needed_classes_from_pointer (
374
+ initialize_instantiated_classes_from_pointer (
371
375
generic_arg, ns, needed_lazy_methods);
372
376
}
373
377
}
@@ -401,16 +405,16 @@ void ci_lazy_methodst::gather_virtual_callsites(
401
405
// / instantiated.
402
406
// / \param c: function call whose potential target functions should
403
407
// / be determined.
404
- // / \param needed_classes : set of classes that can be instantiated. Any
408
+ // / \param instantiated_classes : set of classes that can be instantiated. Any
405
409
// / potential callee not in this set will be ignored.
406
410
// / \param symbol_table: global symbol table
407
- // / \param [out] needed_methods : Populated with all possible `c` callees, taking
408
- // / `needed_classes ` into account (virtual function overrides defined on
409
- // / classes that are not 'needed' are ignored)
411
+ // / \param [out] callable_methods : Populated with all possible `c` callees,
412
+ // / taking `instantiated_classes ` into account (virtual function overrides
413
+ // / defined on classes that are not 'needed' are ignored)
410
414
void ci_lazy_methodst::get_virtual_method_targets (
411
415
const code_function_callt &c,
412
- const std::set<irep_idt> &needed_classes ,
413
- std::vector<irep_idt> &needed_methods ,
416
+ const std::set<irep_idt> &instantiated_classes ,
417
+ std::vector<irep_idt> &callable_methods ,
414
418
symbol_tablet &symbol_table)
415
419
{
416
420
const auto &called_function=c.function ();
@@ -424,41 +428,26 @@ void ci_lazy_methodst::get_virtual_method_targets(
424
428
!call_basename.empty (),
425
429
" Virtual function must have a reasonable name after removing class" );
426
430
427
- auto old_size=needed_methods.size ();
428
-
429
431
const irep_idt &self_method=
430
432
get_virtual_method_target (
431
- needed_classes , call_basename, call_class, symbol_table);
433
+ instantiated_classes , call_basename, call_class, symbol_table);
432
434
433
435
if (!self_method.empty ())
434
436
{
435
- needed_methods .push_back (self_method);
437
+ callable_methods .push_back (self_method);
436
438
}
437
439
438
440
const auto child_classes=class_hierarchy.get_children_trans (call_class);
439
441
for (const auto &child_class : child_classes)
440
442
{
441
443
const auto child_method=
442
444
get_virtual_method_target (
443
- needed_classes ,
445
+ instantiated_classes ,
444
446
call_basename,
445
447
child_class,
446
448
symbol_table);
447
449
if (!child_method.empty ())
448
- needed_methods.push_back (child_method);
449
- }
450
-
451
- if (needed_methods.size ()==old_size)
452
- {
453
- // Didn't find any candidate callee. Generate a stub.
454
- std::string stubname=id2string (call_class)+" ." +id2string (call_basename);
455
- symbolt symbol;
456
- symbol.name =stubname;
457
- symbol.base_name =call_basename;
458
- symbol.type =c.function ().type ();
459
- symbol.value .make_nil ();
460
- symbol.mode =ID_java;
461
- symbol_table.add (symbol);
450
+ callable_methods.push_back (child_method);
462
451
}
463
452
}
464
453
@@ -517,7 +506,7 @@ void ci_lazy_methodst::gather_field_types(
517
506
if (element_type.id () == ID_pointer)
518
507
{
519
508
// This is a reference array -- mark its element type available.
520
- initialize_all_needed_classes_from_pointer (
509
+ initialize_all_instantiated_classes_from_pointer (
521
510
to_pointer_type (element_type), ns, needed_lazy_methods);
522
511
}
523
512
}
@@ -532,7 +521,7 @@ void ci_lazy_methodst::gather_field_types(
532
521
{
533
522
if (field.type ().subtype ().id () == ID_symbol)
534
523
{
535
- initialize_all_needed_classes_from_pointer (
524
+ initialize_all_instantiated_classes_from_pointer (
536
525
to_pointer_type (field.type ()), ns, needed_lazy_methods);
537
526
}
538
527
else
@@ -553,24 +542,24 @@ void ci_lazy_methodst::gather_field_types(
553
542
554
543
// / Find a virtual callee, if one is defined and the callee type is known to
555
544
// / exist.
556
- // / \param needed_classes : set of classes that can be instantiated.
545
+ // / \param instantiated_classes : set of classes that can be instantiated.
557
546
// / Any potential callee not in this set will be ignored.
558
547
// / \param call_basename: unqualified function name with type signature (e.g.
559
548
// / "f:(I)")
560
549
// / \param classname: class name that may define or override a function named
561
550
// / `call_basename`.
562
551
// / \param symbol_table: global symtab
563
552
// / \return Returns the fully qualified name of `classname`'s definition of
564
- // / `call_basename` if found and `classname` is present in `needed_classes`,
565
- // / or irep_idt() otherwise.
553
+ // / `call_basename` if found and `classname` is present in
554
+ // / `instantiated_classes`, or irep_idt() otherwise.
566
555
irep_idt ci_lazy_methodst::get_virtual_method_target (
567
- const std::set<irep_idt> &needed_classes ,
556
+ const std::set<irep_idt> &instantiated_classes ,
568
557
const irep_idt &call_basename,
569
558
const irep_idt &classname,
570
559
const symbol_tablet &symbol_table)
571
560
{
572
561
// Program-wide, is this class ever instantiated?
573
- if (!needed_classes .count (classname))
562
+ if (!instantiated_classes .count (classname))
574
563
return irep_idt ();
575
564
576
565
resolve_inherited_componentt call_resolver (symbol_table, class_hierarchy);
0 commit comments