#include <ci_lazy_methods.h>
|
| ci_lazy_methodst (const symbol_table_baset &symbol_table, const irep_idt &main_class, const std::vector< irep_idt > &main_jar_classes, const std::vector< load_extra_methodst > &lazy_methods_extra_entry_points, java_class_loadert &java_class_loader, const std::vector< irep_idt > &extra_instantiated_classes, const select_pointer_typet &pointer_type_selector, const synthetic_methods_mapt &synthetic_methods) |
| Constructor for lazy-method loading. More...
|
|
bool | operator() (symbol_table_baset &symbol_table, method_bytecodet &method_bytecode, const method_convertert &method_converter, message_handlert &message_handler) |
| Uses a simple context-insensitive ('ci') analysis to determine which methods may be reachable from the main entry point. More...
|
|
|
void | initialize_instantiated_classes (const std::unordered_set< irep_idt > &entry_points, const namespacet &ns, ci_lazy_methods_neededt &needed_lazy_methods) |
| Build up a list of methods whose type may be passed around reachable from the entry point. More...
|
|
void | gather_virtual_callsites (const exprt &e, std::unordered_set< class_method_descriptor_exprt, irep_hash > &result) |
| Get places where virtual functions are called. More...
|
|
void | get_virtual_method_targets (const class_method_descriptor_exprt &called_function, const std::unordered_set< irep_idt > &instantiated_classes, std::unordered_set< irep_idt > &callable_methods, symbol_table_baset &symbol_table) |
| Find possible callees, excluding types that are not known to be instantiated. More...
|
|
void | gather_needed_globals (const exprt &e, const symbol_table_baset &symbol_table, symbol_table_baset &needed) |
| See output. More...
|
|
irep_idt | get_virtual_method_target (const std::unordered_set< irep_idt > &instantiated_classes, const irep_idt &call_basename, const irep_idt &classname, const symbol_table_baset &symbol_table) |
| Find a virtual callee, if one is defined and the callee type is known to exist. More...
|
|
std::unordered_set< irep_idt > | entry_point_methods (const symbol_table_baset &symbol_table, message_handlert &message_handler) |
| Entry point methods are either: More...
|
|
convert_method_resultt | convert_and_analyze_method (const method_convertert &method_converter, std::unordered_set< irep_idt > &methods_already_populated, const bool class_initializer_already_seen, const irep_idt &method_name, symbol_table_baset &symbol_table, std::unordered_set< irep_idt > &methods_to_convert_later, std::unordered_set< irep_idt > &instantiated_classes, std::unordered_set< class_method_descriptor_exprt, irep_hash > &called_virtual_functions, message_handlert &message_handler) |
| Convert a method, add it to the populated set, add needed methods to methods_to_convert_later and add virtual calls from the method to virtual_functions. More...
|
|
bool | handle_virtual_methods_with_no_callees (std::unordered_set< irep_idt > &methods_to_convert_later, std::unordered_set< irep_idt > &instantiated_classes, const std::unordered_set< class_method_descriptor_exprt, irep_hash > &virtual_functions, symbol_table_baset &symbol_table) |
| Look for virtual callsites with no candidate targets. More...
|
|
Definition at line 98 of file ci_lazy_methods.h.
◆ ci_lazy_methodst()
Constructor for lazy-method loading.
- Parameters
-
symbol_table | the symbol table to use |
main_class | identifier of the entry point / main class |
main_jar_classes | specify main class of jar if main_class is empty |
lazy_methods_extra_entry_points | entry point functions to use |
java_class_loader | the Java class loader to use |
extra_instantiated_classes | list of class identifiers which are considered to be required and therefore their methods should not be removed via lazy-methods . Example of use: ArrayList as general implementation for List interface. |
pointer_type_selector | selector to handle correct pointer types |
synthetic_methods | map from synthetic method names to the type of synthetic method (e.g. stub class static initialiser). Indicates that these method bodies are produced internally, rather than generated from Java bytecode. |
Definition at line 39 of file ci_lazy_methods.cpp.
◆ build_virtual_method_name()
static irep_idt ci_lazy_methodst::build_virtual_method_name |
( |
const irep_idt & |
class_name, |
|
|
const irep_idt & |
component_method_name |
|
) |
| |
|
staticprivate |
◆ convert_and_analyze_method()
Convert a method, add it to the populated set, add needed methods to methods_to_convert_later and add virtual calls from the method to virtual_functions.
- Returns
- structure containing two Booleans:
- class_initializer_seen which is true if the class_initializer_seen argument was false and the class_model is referenced in the body of the method
- new_method_seen if the method was not converted before and was converted successfully here
Definition at line 331 of file ci_lazy_methods.cpp.
◆ entry_point_methods()
Entry point methods are either:
- the "main" function of the
main_class
if it exists
- all the methods of the main class if it is not empty
- all the methods of the main jar file
- Returns
- set of identifiers of entry point methods
Definition at line 381 of file ci_lazy_methods.cpp.
◆ gather_needed_globals()
See output.
- Parameters
-
| e | expression tree to search |
| symbol_table | global symbol table |
[out] | needed | Populated with global variable symbols referenced from e or its children. |
Definition at line 519 of file ci_lazy_methods.cpp.
◆ gather_virtual_callsites()
Get places where virtual functions are called.
- Parameters
-
| e | expression tree to search |
[out] | result | filled with pointers to each function call within e that calls a virtual function. |
Definition at line 460 of file ci_lazy_methods.cpp.
◆ get_virtual_method_target()
Find a virtual callee, if one is defined and the callee type is known to exist.
- Parameters
-
instantiated_classes | set of classes that can be instantiated. Any potential callee not in this set will be ignored. |
call_basename | unqualified function name with type signature (e.g. "f:(I)") |
classname | class name that may define or override a function named call_basename . |
symbol_table | global symtab |
- Returns
- Returns the fully qualified name of
classname
's definition of call_basename
if found and classname
is present in instantiated_classes
, or irep_idt() otherwise.
Definition at line 559 of file ci_lazy_methods.cpp.
◆ get_virtual_method_targets()
Find possible callees, excluding types that are not known to be instantiated.
- Parameters
-
| called_function | virtual function call whose concrete function calls should be determined. |
| instantiated_classes | set of classes that can be instantiated. Any potential callee not in this set will be ignored. |
[out] | callable_methods | Populated with all possible c callees, taking instantiated_classes into account (virtual function overrides defined on classes that are not 'needed' are ignored) |
| symbol_table | global symbol table |
Definition at line 492 of file ci_lazy_methods.cpp.
◆ handle_virtual_methods_with_no_callees()
Look for virtual callsites with no candidate targets.
If we have invokevirtual A.f and we don't believe either A or any of its children may exist, we assume specifically A is somehow instantiated. Note this may result in an abstract class being classified as instantiated, which stands in for some unknown concrete subclass: in this case the called method will be a stub.
- Returns
- whether a new class was encountered
Definition at line 248 of file ci_lazy_methods.cpp.
◆ initialize_instantiated_classes()
Build up a list of methods whose type may be passed around reachable from the entry point.
- Parameters
-
| entry_points | list of fully-qualified function names that we should assume are reachable |
| ns | global namespace |
[out] | needed_lazy_methods | Populated with all Java reference types whose references may be passed, directly or indirectly, to any of the functions in entry_points . |
Definition at line 425 of file ci_lazy_methods.cpp.
◆ operator()()
Uses a simple context-insensitive ('ci') analysis to determine which methods may be reachable from the main entry point.
In brief, static methods are reachable if we find a callsite in another reachable site, while virtual methods are reachable if we find a virtual callsite targeting a compatible type and a constructor callsite indicating an object of that type may be instantiated (or evidence that an object of that type exists before the main function is entered, such as being passed as a parameter). Elaborates lazily-converted methods that may be reachable starting from the main entry point (usually provided with the –function command- line option
- Parameters
-
| symbol_table | global symbol table |
[out] | method_bytecode | map from method names to relevant symbol and parsed-method objects. |
| method_converter | Function for converting methods on demand. |
| message_handler | the message handler to use for output |
- Returns
- Returns false on success
Definition at line 101 of file ci_lazy_methods.cpp.
◆ class_hierarchy
◆ extra_instantiated_classes
const std::vector<irep_idt>& ci_lazy_methodst::extra_instantiated_classes |
|
private |
◆ java_class_loader
◆ lazy_methods_extra_entry_points
◆ main_class
◆ main_jar_classes
std::vector<irep_idt> ci_lazy_methodst::main_jar_classes |
|
private |
◆ pointer_type_selector
◆ synthetic_methods
The documentation for this class was generated from the following files: