forked from diffblue/cbmc
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Java frontend: create synthetic static initialisers for stub globals
Previously the Java frontend discovered static field references during method conversion, and when it found them it created global symbols with nondet values, causing an object tree to be created in __CPROVER_initialize. This caused two problems: (1) they were created late, meaning when incrementally loading functions, __CPROVER_initialize may already have been created when a new stub static field is discovered, and (2) by creating potentially large trees of potential objects in __CPROVER_initialize, symex would be compelled to accrue a lot of possibly-unused state. This change moves the object tree creation into a synthetic static initialiser, which both defers executing the initialisation until their class is actually used, and also creates the static initialisers before method conversion, such that its already_run variable is mentioned in __CPROVER_initialize when it is created (the initialize function is now both smaller and "right first time").
- Loading branch information
Showing
11 changed files
with
424 additions
and
116 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 |
---|---|---|
|
@@ -19,7 +19,10 @@ Author: Daniel Kroening, [email protected] | |
#include "ci_lazy_methods.h" | ||
#include "ci_lazy_methods_needed.h" | ||
#include "java_class_loader.h" | ||
#include "java_static_initializers.h" | ||
#include "java_string_library_preprocess.h" | ||
#include "object_factory_parameters.h" | ||
#include "synthetic_methods_map.h" | ||
|
||
#include <java_bytecode/select_pointer_type.h> | ||
|
||
|
@@ -53,10 +56,6 @@ Author: Daniel Kroening, [email protected] | |
" the purpose of lazy method loading\n" /* NOLINT(*) */ \ | ||
" A '.*' wildcard is allowed to specify all class members\n" | ||
|
||
#define MAX_NONDET_ARRAY_LENGTH_DEFAULT 5 | ||
#define MAX_NONDET_STRING_LENGTH std::numeric_limits<std::int32_t>::max() | ||
#define MAX_NONDET_TREE_DEPTH 5 | ||
|
||
class symbolt; | ||
|
||
enum lazy_methods_modet | ||
|
@@ -66,26 +65,6 @@ enum lazy_methods_modet | |
LAZY_METHODS_MODE_CONTEXT_SENSITIVE | ||
}; | ||
|
||
struct object_factory_parameterst final | ||
{ | ||
/// Maximum value for the non-deterministically-chosen length of an array. | ||
size_t max_nondet_array_length=MAX_NONDET_ARRAY_LENGTH_DEFAULT; | ||
|
||
/// Maximum value for the non-deterministically-chosen length of a string. | ||
size_t max_nondet_string_length=MAX_NONDET_STRING_LENGTH; | ||
|
||
/// Maximum depth for object hierarchy on input. | ||
/// Used to prevent object factory to loop infinitely during the | ||
/// generation of code that allocates/initializes data structures of recursive | ||
/// data types or unbounded depth. We bound the maximum number of times we | ||
/// dereference a pointer using a 'depth counter'. We set a pointer to null if | ||
/// such depth becomes >= than this maximum value. | ||
size_t max_nondet_tree_depth=MAX_NONDET_TREE_DEPTH; | ||
|
||
/// Force string content to be ASCII printable characters when set to true. | ||
bool string_printable = false; | ||
}; | ||
|
||
class java_bytecode_languaget:public languaget | ||
{ | ||
public: | ||
|
@@ -192,6 +171,8 @@ class java_bytecode_languaget:public languaget | |
|
||
private: | ||
const std::unique_ptr<const select_pointer_typet> pointer_type_selector; | ||
synthetic_methods_mapt synthetic_methods; | ||
stub_global_initializer_factoryt stub_global_initializer_factory; | ||
}; | ||
|
||
std::unique_ptr<languaget> new_java_bytecode_language(); | ||
|
This file contains 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
Oops, something went wrong.