-
Notifications
You must be signed in to change notification settings - Fork 273
Lazy function loading #1563
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
mgudemann
merged 21 commits into
diffblue:develop
from
NathanJPhillips:feature/lazy-loading
Jan 3, 2018
Merged
Lazy function loading #1563
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
c078858
Introduce lazy_goto_modelt
NathanJPhillips 05a8da2
Make goto_convert_functions not add directly to function map
NathanJPhillips 0c05be6
Allow convert_lazy_method on functions that don't have a lazy body
NathanJPhillips 7e1ecc9
Allow post-processing functions to run on a function-by-function basis
NathanJPhillips a659bc0
Add lazy_goto_functions_mapt
NathanJPhillips aa5440b
Moved call to final to lazy_goto_modelt::finalize
NathanJPhillips 5f06e36
Recreate initialize in final
NathanJPhillips 2ba1364
Update load_all_functions
NathanJPhillips e3e44c8
Do type-checking as a function pass
NathanJPhillips 87c6b28
Don't erase symbol in java_bytecode_convert_methodt::convert
NathanJPhillips c938b08
Encapsulate maps in language_filest
NathanJPhillips 7e52e22
Always allow the main function not to have a body
NathanJPhillips 3779782
Always convert the main function from bytecode into the symbol_table
NathanJPhillips 166563f
Do lowering of java_new as a function-level pass
NathanJPhillips cb09d8e
Fix new tests to use lazy loading
NathanJPhillips f759f25
Fix new test to run remove_java_new pass
NathanJPhillips 441d269
Reset counter used by get_fresh_aux_symbol in unit tests
NathanJPhillips ef02f4d
Update test to handle changed symbol creation order
NathanJPhillips b0cd57b
Encapsulate lazy_goto_modelt::goto_functions
NathanJPhillips f96efb4
Change template parameter name to not clash with existing type
NathanJPhillips a2cf16d
Store symbol type instead of followed type when clean casting
NathanJPhillips 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ Author: Daniel Kroening, [email protected] | |
#include <goto-programs/link_to_library.h> | ||
#include <goto-programs/goto_inline.h> | ||
#include <goto-programs/xml_goto_trace.h> | ||
#include <goto-programs/remove_java_new.h> | ||
|
||
#include <goto-instrument/dump_c.h> | ||
|
||
|
@@ -207,6 +208,8 @@ bool clobber_parse_optionst::process_goto_program( | |
goto_modelt &goto_model) | ||
{ | ||
{ | ||
remove_java_new(goto_model, get_message_handler()); | ||
|
||
// do partial inlining | ||
status() << "Partial Inlining" << eom; | ||
goto_partial_inline(goto_model, get_message_handler()); | ||
|
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 |
---|---|---|
|
@@ -37,6 +37,7 @@ Author: Daniel Kroening, [email protected] | |
#include <goto-programs/read_goto_binary.h> | ||
#include <goto-programs/goto_inline.h> | ||
#include <goto-programs/link_to_library.h> | ||
#include <goto-programs/remove_java_new.h> | ||
|
||
#include <analyses/is_threaded.h> | ||
#include <analyses/goto_check.h> | ||
|
@@ -735,6 +736,8 @@ bool goto_analyzer_parse_optionst::process_goto_program( | |
link_to_library(goto_model, ui_message_handler); | ||
#endif | ||
|
||
remove_java_new(goto_model, get_message_handler()); | ||
|
||
// remove function pointers | ||
status() << "Removing function pointers and virtual functions" << eom; | ||
remove_function_pointers( | ||
|
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
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 |
---|---|---|
|
@@ -33,6 +33,7 @@ Author: Daniel Kroening, [email protected] | |
#include <ansi-c/string_constant.h> | ||
|
||
#include "format_strings.h" | ||
#include "class_identifier.h" | ||
|
||
void goto_convertt::do_prob_uniform( | ||
const exprt &lhs, | ||
|
@@ -539,68 +540,6 @@ void goto_convertt::do_cpp_new( | |
dest.destructive_append(tmp_initializer); | ||
} | ||
|
||
void set_class_identifier( | ||
struct_exprt &expr, | ||
const namespacet &ns, | ||
const symbol_typet &class_type) | ||
{ | ||
const struct_typet &struct_type= | ||
to_struct_type(ns.follow(expr.type())); | ||
const struct_typet::componentst &components=struct_type.components(); | ||
|
||
if(components.empty()) | ||
return; | ||
assert(!expr.operands().empty()); | ||
|
||
if(components.front().get_name()=="@class_identifier") | ||
{ | ||
assert(expr.op0().id()==ID_constant); | ||
expr.op0()=constant_exprt(class_type.get_identifier(), string_typet()); | ||
} | ||
else | ||
{ | ||
assert(expr.op0().id()==ID_struct); | ||
set_class_identifier(to_struct_expr(expr.op0()), ns, class_type); | ||
} | ||
} | ||
|
||
void goto_convertt::do_java_new( | ||
const exprt &lhs, | ||
const side_effect_exprt &rhs, | ||
goto_programt &dest) | ||
{ | ||
PRECONDITION(!lhs.is_nil()); | ||
PRECONDITION(rhs.operands().empty()); | ||
PRECONDITION(rhs.type().id() == ID_pointer); | ||
source_locationt location=rhs.source_location(); | ||
typet object_type=rhs.type().subtype(); | ||
|
||
// build size expression | ||
exprt object_size=size_of_expr(object_type, ns); | ||
CHECK_RETURN(object_size.is_not_nil()); | ||
|
||
// we produce a malloc side-effect, which stays | ||
side_effect_exprt malloc_expr(ID_allocate); | ||
malloc_expr.copy_to_operands(object_size); | ||
// could use true and get rid of the code below | ||
malloc_expr.copy_to_operands(false_exprt()); | ||
malloc_expr.type()=rhs.type(); | ||
|
||
goto_programt::targett t_n=dest.add_instruction(ASSIGN); | ||
t_n->code=code_assignt(lhs, malloc_expr); | ||
t_n->source_location=location; | ||
|
||
// zero-initialize the object | ||
dereference_exprt deref(lhs, object_type); | ||
exprt zero_object= | ||
zero_initializer(object_type, location, ns, get_message_handler()); | ||
set_class_identifier( | ||
to_struct_expr(zero_object), ns, to_symbol_type(object_type)); | ||
goto_programt::targett t_i=dest.add_instruction(ASSIGN); | ||
t_i->code=code_assignt(deref, zero_object); | ||
t_i->source_location=location; | ||
} | ||
|
||
void goto_convertt::do_java_new_array( | ||
const exprt &lhs, | ||
const side_effect_exprt &rhs, | ||
|
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 |
---|---|---|
|
@@ -15,10 +15,16 @@ Author: Chris Smowton, [email protected] | |
class exprt; | ||
class namespacet; | ||
class symbol_typet; | ||
class struct_exprt; | ||
|
||
exprt get_class_identifier_field( | ||
const exprt &this_expr, | ||
const symbol_typet &suggested_type, | ||
const namespacet &ns); | ||
|
||
void set_class_identifier( | ||
struct_exprt &expr, | ||
const namespacet &ns, | ||
const symbol_typet &class_type); | ||
|
||
#endif |
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
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
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.
This isn't in the right commit, which will make
git bisect
harder.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.
Well caught. This was originally the commit where the cpp file was introduced but I pushed it back to an earlier commit without updating the Makefile. Mea culpa.
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.
(Just for the record: this has been fixed.)