@@ -256,9 +256,72 @@ 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 loading-strategies Loading strategies
260
+
261
+ Loading strategies are policies that determine what classes and method bodies
262
+ are loaded. On an initial pass, the symbols for all classes in all paths on
263
+ the Java classpath are loaded. Eager loading is a policy that then loads
264
+ all the method bodies for every one of these classes. Lazy loading
265
+ strategies are policies that only load class symbols and/or method bodies
266
+ when they are in some way requested.
267
+
268
+ The mechanism used to achieve this is initially common to both eager and
269
+ context-insensitive lazy loading. \ref java_bytecode_languaget::typecheck calls
270
+ [ java_bytecode_convert_class] (\ref java_bytecode_languaget::java_bytecode_convert_class)
271
+ (for each class loaded by the class loader) to create symbols for all classes
272
+ and the methods in them. The methods, along with their parsed representation
273
+ (including bytecode) are also added to a map called
274
+ \ref java_bytecode_languaget::method_bytecode via a reference held in
275
+ \ref java_bytecode_convert_classt::method_bytecode. typecheck then performs a
276
+ switch over the value of
277
+ [ lazy_methods_mode] (\ref java_bytecode_languaget::lazy_methods_mode) to
278
+ determine which loading strategy to use.
279
+
280
+ \subsection eager-loading Eager loading
281
+
282
+ If [ lazy_methods_mode] (\ref java_bytecode_languaget::lazy_methods_mode) is
283
+ \ref java_bytecode_languaget::LAZY_METHODS_MODE_EAGER then eager loading is
284
+ used. Under eager loading
285
+ \ref java_bytecode_languaget::convert_single_method(const irep_idt &, symbol_table_baset &)
286
+ is called once for each method listed in method_bytecode (described above). This
287
+ then calls
288
+ \ref java_bytecode_languaget::convert_single_method(const irep_idt &, symbol_table_baset &, optionalt<ci_lazy_methods_neededt>)
289
+ without a ci_lazy_methods_neededt object, which calls
290
+ \ref java_bytecode_convert_method, passing in the method parse tree. This in
291
+ turn uses \ref java_bytecode_convert_methodt to turn the bytecode into symbols
292
+ for the parameters and local variables and finish populating the symbol for the
293
+ method, including converting the instructions to a codet.
294
+
295
+ \subsection java-bytecode-lazy-methods-v1 Context-Insensitive lazy methods (aka lazy methods v1)
296
+
297
+ Context-insensitive lazy loading is an alternative method body loading strategy
298
+ to eager loading that has been used in Deeptest for a while.
299
+ Context-insensitive lazy loading starts at the method given by the ` --function `
300
+ argument and follows type references (e.g. in the definitions of fields and
301
+ method parameters) and function references (at function call sites) to
302
+ locate further classes and methods to load. The following paragraph describes
303
+ the mechanism used.
304
+
305
+ If [ lazy_methods_mode] (\ref java_bytecode_languaget::lazy_methods_mode) is
306
+ \ref lazy_methods_modet::LAZY_METHODS_MODE_CONTEXT_INSENSITIVE then
307
+ context-insensitive lazy loading is used. Under this stragegy
308
+ \ref java_bytecode_languaget::do_ci_lazy_method_conversion is called to do all
309
+ conversion. This calls
310
+ \ref ci_lazy_methodst::operator()(symbol_tablet &, method_bytecodet &, const method_convertert &),
311
+ which creates a work list of methods to check, starting with the entry point,
312
+ and classes, starting with the types of any class-typed parameters to the entry
313
+ point. For each method in the work list it calls
314
+ \ref ci_lazy_methodst::convert_and_analyze_method, which calls the same
315
+ java_bytecode_languaget::convert_single_method used by eager loading to do the
316
+ conversion (via a ` std::function ` object passed in via parameter
317
+ method_converter) and then calls
318
+ \ref ci_lazy_methodst::gather_virtual_callsites to locate virtual calls. Any
319
+ classes that may implement an override of the virtual function called are added
320
+ to the work list. Finally the symbol table is iterated over and methods that
321
+ have been converted, their parameters and local variables, globals accessed
322
+ from these methods and classes are kept, everything else is thrown away. This
323
+ leaves a symbol table that contains reachable symbols fully populated,
324
+ including the instructions for methods converted to a \ref codet.
262
325
263
326
\section java-bytecode-core-models-library Core Models Library
264
327
0 commit comments