@@ -256,9 +256,57 @@ To be documented.
256
256
257
257
To be documented.
258
258
259
- \section java-bytecode-lazy-methods-v1 Context Insensitive lazy methods (aka lazy methods v1)
260
-
261
- To be documented.
259
+ \section java-bytecode-lazy-methods-v1 Context-Insensitive lazy methods (aka lazy methods v1)
260
+
261
+ Eager loading simply loads every method belonging to classes found in the first
262
+ phase; lazy loading starts at the method given by the --function argument and
263
+ walks outwards. The following paragraphs describe the mechanism used by eager
264
+ and context-insensitive lazy loading to achieve this.
265
+
266
+ \ref java_bytecode_languaget::typecheck calls
267
+ [ java_bytecode_convert_class] (\ref java_bytecode_languaget::java_bytecode_convert_class)
268
+ (for each class loaded by the class loader) to create symbols for all classes
269
+ and the methods in them. The methods, along with their parsed representation
270
+ (including bytecode) are also added to a map called
271
+ \ref java_bytecode_languaget::method_bytecode via a reference held in
272
+ \ref java_bytecode_convert_classt::method_bytecode. typecheck then performs a
273
+ switch over the value of
274
+ [ lazy_methods_mode] (\ref java_bytecode_languaget::lazy_methods_mode). If
275
+ lazy_methods_mode is
276
+ \ref lazy_methods_modet::LAZY_METHODS_MODE_CONTEXT_INSENSITIVE then
277
+ context-insensitive lazy loading is used.
278
+
279
+ Context-insensitive lazy loading is an alternative method body loading strategy
280
+ to eager loading, which is selected when lazy_methods_mode is
281
+ \ref java_bytecode_languaget::LAZY_METHODS_MODE_EAGER. Under eager loading
282
+ \ref java_bytecode_languaget::convert_single_method(const irep_idt &, symbol_table_baset &)
283
+ is called once for each method listed in method_bytecode (described above). This
284
+ then calls
285
+ \ref java_bytecode_languaget::convert_single_method(const irep_idt &, symbol_table_baset &, optionalt<ci_lazy_methods_neededt>)
286
+ without a ci_lazy_methods_neededt object, which calls
287
+ \ref java_bytecode_convert_method, passing in the method parse tree. This in
288
+ turn uses \ref java_bytecode_convert_methodt to turn the bytecode into symbols
289
+ for the parameters and local variables and finish populating the symbol for the
290
+ method, including converting the instructions to a codet.
291
+
292
+ When context-insensitive lazy loading is in operation
293
+ \ref java_bytecode_languaget::do_ci_lazy_method_conversion is called to do all
294
+ conversion. This calls
295
+ \ref ci_lazy_methodst::operator()(symbol_tablet &, method_bytecodet &, const method_convertert &),
296
+ which creates a work list of methods to check, starting with the entry point,
297
+ and classes, starting with the types of any class-typed parameters to the entry
298
+ point. For each method in the work list it calls
299
+ \ref ci_lazy_methodst::convert_and_analyze_method, which calls the same
300
+ java_bytecode_languaget::convert_single_method used by eager loading to do the
301
+ conversion (via a std::function object passed in via parameter
302
+ method_converter) and then calls
303
+ \ref ci_lazy_methodst::gather_virtual_callsites to locate virtual calls. Any
304
+ classes that may implement an override of the virtual function called are added
305
+ to the work list. Finally the symbol table is iterated over and methods that
306
+ have been converted, their parameters and local variables, globals accessed
307
+ from these methods and classes are kept, everything else is thrown away. This
308
+ leaves a symbol table that contains reachable symbols fully populated,
309
+ including the instructions for methods converted to a codet.
262
310
263
311
\section java-bytecode-core-models-library Core Models Library
264
312
0 commit comments