Skip to content

Add an overview of what lowerings are done [DOC-25] #2792

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
merged 2 commits into from
Aug 31, 2018

Conversation

thk123
Copy link
Contributor

@thk123 thk123 commented Aug 21, 2018

As expressed on #2775 we should have one place that explains what is meant by lowering in a holistic sense, with links to the new sections.

@@ -6,6 +6,21 @@ This module provides a front end for Java.
\section java-bytecode-conversion-section Overview of conversion from bytecode to codet

To be documented.
\subsection java-bytecode-lowering-to-goto Lowering to GOTO

The Java language contains high level programming concepts like virtual functions and throw/catch semantics. We need to rewrite these in terms of other, more fundamental operations in order to analyse it. This operation is referred to as "lowering".
Copy link
Member

Choose a reason for hiding this comment

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

high-level

Copy link
Member

Choose a reason for hiding this comment

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

it -> Java programs?


The Java language contains high level programming concepts like virtual functions and throw/catch semantics. We need to rewrite these in terms of other, more fundamental operations in order to analyse it. This operation is referred to as "lowering".

The following lowering operations are done on java bytecode after converting into a basic codet representation.
Copy link
Member

Choose a reason for hiding this comment

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

Java

Copy link
Member

Choose a reason for hiding this comment

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

codet


The following lowering operations are done on java bytecode after converting into a basic codet representation.

- \ref java-bytecode-runtime-exceptions "Add runtime exceptions"
Copy link
Member

Choose a reason for hiding this comment

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

This is not a lowering in the strict sense. It is adding part of the JVM's execution algorithm into the analysed program.

Copy link
Member

Choose a reason for hiding this comment

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

We should also mention remove_nondet then.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm - I consider it in the same bucket since the JVM detects null pointer access and throws an exception - we lower that "high level feature" of the JVM into a fundamental operation of if(a == null), what would you call it?

Remove_nondet is kind of a weird one since it doesn't exist in Java bytecode or the JVM - it is a CPROVER construct right?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should carefully distinguish between lowering and instrumentation. The former is a rewrite of the code (supposedly semantics-preserving), while the latter will add or modify behaviour.

- \ref java-bytecode-runtime-exceptions "Add runtime exceptions"
- \ref java-bytecode-remove-java-new "Remove new calls"
- \ref java-bytecode-remove-exceptions "Remove thrown exceptions"
- As well as other non-java specific transformations (see \ref goto-programs for details on these)
Copy link
Member

Choose a reason for hiding this comment

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

There is remove_instanceof and remove_virtual_methods

Copy link
Contributor Author

Choose a reason for hiding this comment

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

remove-virtual-methods is not Java specific (covered by the link to goto-programs). The section for remove_instanceof is missing so will add after #2775 is merged.

These are performed in `process_goto_function` for example
\ref jbmc_parse_optionst::process_goto_function

Once these lowerings have been completed, you have a GOTO model that can be analysed.
Copy link
Member

Choose a reason for hiding this comment

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

analysed: maybe be more specific 'handled by \ref goto-symex'. Also the lowering passes do some kind of 'analysis'.

@thk123
Copy link
Contributor Author

thk123 commented Aug 22, 2018

@peterschrammel some comments addressed - I have questions about the others.

@cesaro
Copy link
Contributor

cesaro commented Aug 22, 2018

@thk123 The term lowering will be defined in the section on "background concepts", subsection "glossary". There is already a sketch of the definition in #2806

@thk123
Copy link
Contributor Author

thk123 commented Aug 29, 2018

@cesaro Hi - sorry is there an action you want me to take from your comment? Perhaps a link to this section: https://github.com/diffblue/cbmc/pull/2806/files#diff-6988ca396abc0c4e424da9d8494e2f1fR814 from the word lowering.

If I do that, would you be happy to approve?

Copy link
Member

@peterschrammel peterschrammel left a comment

Choose a reason for hiding this comment

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

Good to go after fixing the last nitpicks.

The following lowering operations are done on Java bytecode after converting into a basic `codet` representation.

- \ref java-bytecode-runtime-exceptions "Add runtime exceptions"
- \ref java-bytecode-remove-java-new "Remove new calls"
Copy link
Member

Choose a reason for hiding this comment

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

Remove new calls

- \ref java-bytecode-remove-java-new "Remove new calls"
- \ref java-bytecode-remove-exceptions "Remove thrown exceptions"
- \ref java-bytecode-remove-instance-of
- As well as other non-java specific transformations (see \ref goto-programs for details on these)
Copy link
Member

Choose a reason for hiding this comment

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

non-Java

@thk123
Copy link
Contributor Author

thk123 commented Aug 30, 2018

Done, will wait until I've merged the other (colliding) doc change to avoid spamming Travis #2773

@cesaro
Copy link
Contributor

cesaro commented Aug 30, 2018

@thk123 Yes, good to merge with just a reference to the background concepts. Since this will probably be merged before #2806 you can just a reference to the section Background Concepts in plain English when you explain what a lowering are and we will create the link from here in #2806 to the specific term in the Glossary subsection.

@thk123 thk123 force-pushed the thk/lowerings-overview branch from 58b41bf to 31963a3 Compare August 30, 2018 15:27
@thk123 thk123 merged commit f466751 into diffblue:develop Aug 31, 2018
@thk123 thk123 deleted the thk/lowerings-overview branch August 31, 2018 08:47
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.

5 participants