Skip to content

Documentation of lazy loading v1 [DOC-38] #2803

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

NathanJPhillips
Copy link
Contributor

No description provided.


To be documented.
\ref java_bytecode_languaget::typecheck calls [java_bytecode_convert_class](\ref java_bytecode_languaget::java_bytecode_convert_class) (for each class loaded by the class loader) to create symbols for all classes and the methods in them. The methods, along with their parsed representation (including bytecode) are also added to a map called \ref java_bytecode_languaget::method_bytecode via a reference held in \ref java_bytecode_convert_classt::method_bytecode. typecheck then performs a switch over the value of [lazy_methods_mode](\ref java_bytecode_languaget::lazy_methods_mode). If lazy_methods_mode is \ref lazy_methods_modet::LAZY_METHODS_MODE_CONTEXT_INSENSITIVE then context-insensitive lazy loading is used.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have lines broken at 80 characters? It's much easier to read diffs

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a link for typecheck


To be documented.
\ref java_bytecode_languaget::typecheck calls [java_bytecode_convert_class](\ref java_bytecode_languaget::java_bytecode_convert_class) (for each class loaded by the class loader) to create symbols for all classes and the methods in them. The methods, along with their parsed representation (including bytecode) are also added to a map called \ref java_bytecode_languaget::method_bytecode via a reference held in \ref java_bytecode_convert_classt::method_bytecode. typecheck then performs a switch over the value of [lazy_methods_mode](\ref java_bytecode_languaget::lazy_methods_mode). If lazy_methods_mode is \ref lazy_methods_modet::LAZY_METHODS_MODE_CONTEXT_INSENSITIVE then context-insensitive lazy loading is used.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a link for typecheck

To be documented.
\ref java_bytecode_languaget::typecheck calls [java_bytecode_convert_class](\ref java_bytecode_languaget::java_bytecode_convert_class) (for each class loaded by the class loader) to create symbols for all classes and the methods in them. The methods, along with their parsed representation (including bytecode) are also added to a map called \ref java_bytecode_languaget::method_bytecode via a reference held in \ref java_bytecode_convert_classt::method_bytecode. typecheck then performs a switch over the value of [lazy_methods_mode](\ref java_bytecode_languaget::lazy_methods_mode). If lazy_methods_mode is \ref lazy_methods_modet::LAZY_METHODS_MODE_CONTEXT_INSENSITIVE then context-insensitive lazy loading is used.

Context-insensitive lazy loading is an alternative method body loading strategy to eager loading, which is selected when lazy_methods_mode is \ref java_bytecode_languaget::LAZY_METHODS_MODE_EAGER. Under eager loading \ref java_bytecode_languaget::convert_single_method(const irep_idt &, symbol_table_baset &) is called once for each method listed in method_bytecode (described above). This then calls \ref java_bytecode_languaget::convert_single_method(const irep_idt &, symbol_table_baset &, optionalt<ci_lazy_methods_neededt>) without a ci_lazy_methods_neededt object, which calls java_bytecode_convert_method, passing in the method parse tree. This in turn uses java_bytecode_convert_methodt to turn the bytecode into symbols for the parameters and local variables and finish populating the symbol for the method, including converting the instructions to a codet.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turn all identifiers into links (entire document)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just first occurrence of each reference or every one?

@smowton
Copy link
Contributor

smowton commented Aug 22, 2018

Suggest adding a short section prior to all this close-up technical detail that briefly describes the strategies without citing particular method names. Eager loading simply loads every method belonging to classes found in the first phase; lazy loading starts at the method given by the --function argument and walks outwards, briefly explain the virtual call strategy, briefly explain reasons why we consider a method accessible...

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR failed Diffblue compatibility checks (cbmc commit: 6c05a85).
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.

Common spurious failures:

  • the cbmc commit has disappeared in the mean time (e.g. in a force-push)
  • the author is not in the list of contributors (e.g. first-time contributors).

have been converted, their parameters and local variables, globals accessed
from these methods and classes are kept, everything else is thrown away. This
leaves a symbol table that contains reachable symbols fully populated,
including the instructions for methods converted to a codet.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\ref codet

@NathanJPhillips NathanJPhillips force-pushed the documentation/lazy-loading branch from 6c05a85 to be8e0b3 Compare September 7, 2018 13:29
Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passed Diffblue compatibility checks (cbmc commit: be8e0b3).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/84138811

To be documented.
\section java-bytecode-lazy-methods-v1 Context-Insensitive lazy methods (aka lazy methods v1)

Eager loading simply loads every method belonging to classes found in the first
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not clear what Eager Loading is. I think it would be clearer to make this section about Loading Strategies and have subsections for Eager Loading and Context-Insensitive Lazy Methods. If you don't want to do that, at least have a first sentence which introduces Eager Loading.

Copy link
Contributor

@owen-mc-diffblue owen-mc-diffblue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More suggestions to improve it, but it's good enough that you could just merge it if you want.

\section loading-strategies Loading strategies

Loading strategies are policies that determine what classes and method bodies
are loaded. On an inital pass, the symbols for all classes in all paths on the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inital -> initial

Loading strategies are policies that determine what classes and method bodies
are loaded. On an inital pass, the symbols for all classes in all paths on the
Java classpath are loaded. Eager loading is a policy that then loads method
bodies for every one of these classes and for all the method bodies in these
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sentence doesn't make sense to me... we load all the method bodies for all the method bodies...

Context-insensitive lazy loading starts at the method given by the `--function`
argument and follows type references (e.g. in the definitions of fields and
method parameters) and function references (at function call sites) to
locate further classes and methods to load.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line and the two above are indented by a space

method parameters) and function references (at function call sites) to
locate further classes and methods to load.

If [lazy_methods_mode](\ref java_bytecode_languaget::lazy_methods_mode) is
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sentence seems out of place here. Would it be better at the beginning of this subsection? The first few sentences of this subsection don't really flow, like they were written separately and put together later.

@NathanJPhillips NathanJPhillips force-pushed the documentation/lazy-loading branch from d411a2a to d85ed15 Compare September 10, 2018 15:53
@NathanJPhillips NathanJPhillips merged commit e32c469 into diffblue:develop Sep 10, 2018
@NathanJPhillips NathanJPhillips deleted the documentation/lazy-loading branch September 10, 2018 17:03
Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passed Diffblue compatibility checks (cbmc commit: d85ed15).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/84322492

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants