-
Notifications
You must be signed in to change notification settings - Fork 274
Support for an external lazy methods driver to control when the INITIALIZE_FUNCTION
is generated
#5156
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
thomasspriggs
merged 4 commits into
diffblue:develop
from
thomasspriggs:tas/lazy_initialize
Oct 9, 2019
Merged
Support for an external lazy methods driver to control when the INITIALIZE_FUNCTION
is generated
#5156
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e53acb9
Generate `INITIALIZE_FUNCTION` from `convert_single_method`
thomasspriggs 3989689
Add unit tests of lazy `cprover_initialize` generation
thomasspriggs cd75f9f
Update comment
thomasspriggs 082b368
Restructure TEST_CASEs as SCENARIOs
thomasspriggs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,8 @@ Author: Daniel Kroening, [email protected] | |
|
||
#include <string> | ||
|
||
#include <linking/static_lifetime_init.h> | ||
|
||
#include <util/cmdline.h> | ||
#include <util/config.h> | ||
#include <util/expr_iterator.h> | ||
|
@@ -757,6 +759,7 @@ bool java_bytecode_languaget::typecheck( | |
"the Java front-end should only be used with an empty symbol table"); | ||
|
||
java_internal_additions(symbol_table); | ||
create_java_initialize(symbol_table); | ||
|
||
if(language_options->string_refinement_enabled) | ||
string_preprocess.initialize_conversion_table(); | ||
|
@@ -942,6 +945,8 @@ bool java_bytecode_languaget::typecheck( | |
convert_single_method( | ||
method_sig.first, journalling_symbol_table, class_to_declared_symbols); | ||
} | ||
convert_single_method( | ||
INITIALIZE_FUNCTION, journalling_symbol_table, class_to_declared_symbols); | ||
// Now convert all newly added string methods | ||
for(const auto &fn_name : journalling_symbol_table.get_inserted()) | ||
{ | ||
|
@@ -1095,6 +1100,7 @@ void java_bytecode_languaget::methods_provided( | |
// Add all synthetic methods to map | ||
for(const auto &kv : synthetic_methods) | ||
methods.insert(kv.first); | ||
methods.insert(INITIALIZE_FUNCTION); | ||
} | ||
|
||
/// \brief Promote a lazy-converted method (one whose type is known but whose | ||
|
@@ -1120,7 +1126,7 @@ void java_bytecode_languaget::convert_lazy_method( | |
convert_single_method(function_id, symbol_table, class_to_declared_symbols); | ||
|
||
// Instrument runtime exceptions (unless symbol is a stub) | ||
if(symbol.value.is_not_nil()) | ||
if(symbol.value.is_not_nil() && function_id != INITIALIZE_FUNCTION) | ||
owen-mc-diffblue marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
java_bytecode_instrument_symbol( | ||
symbol_table, | ||
|
@@ -1201,6 +1207,20 @@ bool java_bytecode_languaget::convert_single_method( | |
// Nothing to do if body is already loaded | ||
if(symbol.value.is_not_nil()) | ||
return false; | ||
|
||
if(function_id == INITIALIZE_FUNCTION) | ||
{ | ||
java_static_lifetime_init( | ||
symbol_table, | ||
symbol.location, | ||
language_options->assume_inputs_non_null, | ||
object_factory_parameters, | ||
*pointer_type_selector, | ||
language_options->string_refinement_enabled, | ||
get_message_handler()); | ||
return false; | ||
} | ||
|
||
INVARIANT(declaring_class(symbol), "Method must have a declaring class."); | ||
|
||
bool ret = convert_single_method_code( | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
jbmc/unit/java_bytecode/java_bytecode_language/module_dependencies.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
java_bytecode | ||
java-testing-utils | ||
linking | ||
testing-utils | ||
util |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about old ci-lazy-methods?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is already indirectly tested via the regression tests. I chose to add a unit test of the new functionality in this PR, because it would otherwise be untested within this repository.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I could add a unit test of that...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.