-
Notifications
You must be signed in to change notification settings - Fork 273
Exception edges for live range analysis master #466
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
Changes from 3 commits
1a18018
eddb7a5
41f3d5e
92e1e4a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,18 +20,20 @@ Author: Chris Smowton, [email protected] | |
template<class T> | ||
struct procedure_local_cfg_baset< | ||
T, | ||
const java_bytecode_convert_methodt::address_mapt, | ||
java_bytecode_convert_methodt::method_with_amapt, | ||
unsigned> : | ||
public graph<cfg_base_nodet<T, unsigned> > | ||
{ | ||
typedef java_bytecode_convert_methodt::address_mapt address_mapt; | ||
typedef java_bytecode_convert_methodt::method_with_amapt method_with_amapt; | ||
typedef std::map<unsigned, unsigned> entry_mapt; | ||
entry_mapt entry_map; | ||
|
||
procedure_local_cfg_baset() {} | ||
|
||
void operator()(const address_mapt& amap) | ||
void operator()(const method_with_amapt& args) | ||
{ | ||
const auto &method=args.first; | ||
const auto& amap=args.second; | ||
for(const auto& inst : amap) | ||
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.
|
||
{ | ||
// Map instruction PCs onto node indices: | ||
|
@@ -44,19 +46,44 @@ struct procedure_local_cfg_baset< | |
for(auto succ : inst.second.successors) | ||
this->add_edge(entry_map.at(inst.first), entry_map.at(succ)); | ||
} | ||
// Add edges declared in the exception table, which don't figure | ||
// in the address map successors/predecessors as yet. | ||
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. What does this comment refer to, as it's at the end of a block? |
||
for(const auto& table_entry : method.exception_table) | ||
{ | ||
auto findit=amap.find(table_entry.start_pc); | ||
assert(findit!=amap.end() && | ||
"Exception table entry doesn't point to an instruction?"); | ||
for(; findit->first<table_entry.end_pc; ++findit) | ||
{ | ||
// For now just assume any non-branch | ||
// instruction could potentially throw. | ||
auto succit=findit; | ||
++succit; | ||
if(succit==amap.end()) | ||
continue; | ||
const auto& thisinst=findit->second; | ||
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. Nit picking: "&" goes with "thisinst" |
||
if(thisinst.successors.size()==1 && | ||
*thisinst.successors.begin()==succit->first) | ||
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. Use |
||
{ | ||
this->add_edge( | ||
entry_map.at(findit->first), | ||
entry_map.at(table_entry.handler_pc)); | ||
} | ||
} | ||
} | ||
} | ||
|
||
unsigned get_first_node(const address_mapt& amap) const | ||
unsigned get_first_node(const method_with_amapt& args) const | ||
{ | ||
return amap.begin()->first; | ||
return args.second.begin()->first; | ||
} | ||
unsigned get_last_node(const address_mapt& amap) const | ||
unsigned get_last_node(const method_with_amapt& args) const | ||
{ | ||
return (--amap.end())->first; | ||
return (--args.second.end())->first; | ||
} | ||
unsigned nodes_empty(const address_mapt& amap) const | ||
unsigned nodes_empty(const method_with_amapt& args) const | ||
{ | ||
return amap.empty(); | ||
return args.second.empty(); | ||
} | ||
}; | ||
|
||
|
@@ -744,7 +771,8 @@ void java_bytecode_convert_methodt::setup_local_variables( | |
{ | ||
// Compute CFG dominator tree | ||
java_cfg_dominatorst dominator_analysis; | ||
dominator_analysis(amap); | ||
method_with_amapt dominator_args(m,amap); | ||
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. Space after "," |
||
dominator_analysis(dominator_args); | ||
|
||
// Find out which local variable table entries should be merged: | ||
// Wrap each entry so we have somewhere to record live ranges with holes: | ||
|
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.
const auto &amap