-
Notifications
You must be signed in to change notification settings - Fork 274
Avoid redundant computations in get_user_specified_clinit #5078
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
romainbrenguier
merged 9 commits into
diffblue:develop
from
romainbrenguier:refactor/user-specified-clinit
Sep 6, 2019
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
85c2f0d
Move real_clinit_name declaration up
romainbrenguier 6a61209
Make get_user_specified_clinit_body take jsont arg
romainbrenguier c0b681a
Ensure JSON file is JSON object just after parsing
romainbrenguier 8479641
Make get_user_specified_clinit_body json arg non optional
romainbrenguier 3ed8e34
Remove unused message handler
romainbrenguier 2d2ebca
Add an equal_range utility function
romainbrenguier dd45287
Extract a class_to_declared_symbols method
romainbrenguier 67a02e6
Make class_to_declared_symbols take multimap argument
romainbrenguier 30bc2b6
Declare a lazy_class_to_declared_symbols_mapt class
romainbrenguier 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,6 +121,31 @@ enum lazy_methods_modet | |
LAZY_METHODS_MODE_EXTERNAL_DRIVER | ||
}; | ||
|
||
/// Map classes to the symbols they declare but is only computed once it is | ||
/// needed and the map is then kept. | ||
/// Note that it only includes function and field symbols (and not for example, | ||
/// local variables), these are produced in the convert-class phase. | ||
/// Calling `get` before the symbol table is properly filled with these symbols, | ||
/// would make later calls return an outdated map. The | ||
/// lazy_class_to_declared_symbols_mapt would then need to be reinitialized. | ||
/// Similarly if some transformation creates or deletes function or field | ||
/// symbols in the symbol table, then the map would get out of date and would | ||
/// need to be reinitialized. | ||
class lazy_class_to_declared_symbols_mapt | ||
{ | ||
public: | ||
lazy_class_to_declared_symbols_mapt() = default; | ||
|
||
std::unordered_multimap<irep_idt, symbolt> & | ||
get(const symbol_tablet &symbol_table); | ||
|
||
void reinitialize(); | ||
|
||
private: | ||
bool initialized = false; | ||
std::unordered_multimap<irep_idt, symbolt> map; | ||
}; | ||
|
||
#define JAVA_CLASS_MODEL_SUFFIX "@class_model" | ||
|
||
class java_bytecode_languaget:public languaget | ||
|
@@ -205,15 +230,20 @@ class java_bytecode_languaget:public languaget | |
protected: | ||
void convert_single_method( | ||
const irep_idt &function_id, | ||
symbol_table_baset &symbol_table) | ||
symbol_table_baset &symbol_table, | ||
lazy_class_to_declared_symbols_mapt &class_to_declared_symbols) | ||
{ | ||
convert_single_method( | ||
function_id, symbol_table, optionalt<ci_lazy_methods_neededt>()); | ||
function_id, | ||
symbol_table, | ||
optionalt<ci_lazy_methods_neededt>(), | ||
class_to_declared_symbols); | ||
} | ||
bool convert_single_method( | ||
const irep_idt &function_id, | ||
symbol_table_baset &symbol_table, | ||
optionalt<ci_lazy_methods_neededt> needed_lazy_methods); | ||
optionalt<ci_lazy_methods_neededt> needed_lazy_methods, | ||
lazy_class_to_declared_symbols_mapt &class_to_declared_symbols); | ||
|
||
bool do_ci_lazy_method_conversion(symbol_tablet &); | ||
const select_pointer_typet &get_pointer_type_selector() const; | ||
|
@@ -236,10 +266,10 @@ class java_bytecode_languaget:public languaget | |
java_string_library_preprocesst string_preprocess; | ||
std::string java_cp_include_files; | ||
bool nondet_static; | ||
/// Path to a JSON file which contains initial values of static fields (right | ||
/// JSON which contains initial values of static fields (right | ||
/// after the static initializer of the class was run). This is read from the | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 |
||
/// --static-values command-line option. | ||
std::string static_values_file; | ||
/// file specified by the --static-values command-line option. | ||
optionalt<json_objectt> static_values_json; | ||
|
||
// list of classes to force load even without reference from the entry point | ||
std::vector<irep_idt> java_load_classes; | ||
|
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
Oops, something went wrong.
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.
Aha, this does get done. Suggest squash into earlier commit that changes the type.