Skip to content

Commit bf0332d

Browse files
smowtonDaniel Kroening
authored and
Daniel Kroening
committed
Make the method object, and thus the exception table, available to dominator analysis
1 parent 0f80ad4 commit bf0332d

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

src/java_bytecode/java_bytecode_convert_method_class.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ class java_bytecode_convert_methodt:public messaget
129129

130130
public:
131131
typedef std::map<unsigned, converted_instructiont> address_mapt;
132-
typedef cfg_dominators_templatet<const address_mapt, unsigned, false>
132+
typedef std::pair<const methodt&, const address_mapt&> method_with_amapt;
133+
typedef cfg_dominators_templatet<method_with_amapt, unsigned, false>
133134
java_cfg_dominatorst;
134135

135136
protected:

src/java_bytecode/java_local_variable_table.cpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,19 @@ Author: Chris Smowton, [email protected]
2020
template<class T>
2121
struct procedure_local_cfg_baset<
2222
T,
23-
const java_bytecode_convert_methodt::address_mapt,
23+
java_bytecode_convert_methodt::method_with_amapt,
2424
unsigned> :
2525
public graph<cfg_base_nodet<T, unsigned> >
2626
{
27-
typedef java_bytecode_convert_methodt::address_mapt address_mapt;
27+
typedef java_bytecode_convert_methodt::method_with_amapt method_with_amapt;
2828
typedef std::map<unsigned, unsigned> entry_mapt;
2929
entry_mapt entry_map;
3030

3131
procedure_local_cfg_baset() {}
3232

33-
void operator()(const address_mapt& amap)
33+
void operator()(const method_with_amapt& args)
3434
{
35+
const auto& amap=args.second;
3536
for(const auto& inst : amap)
3637
{
3738
// Map instruction PCs onto node indices:
@@ -44,19 +45,21 @@ struct procedure_local_cfg_baset<
4445
for(auto succ : inst.second.successors)
4546
this->add_edge(entry_map.at(inst.first), entry_map.at(succ));
4647
}
48+
// Add edges declared in the exception table, which don't figure
49+
// in the address map successors/predecessors as yet.
4750
}
4851

49-
unsigned get_first_node(const address_mapt& amap) const
52+
unsigned get_first_node(const method_with_amapt& args) const
5053
{
51-
return amap.begin()->first;
54+
return args.second.begin()->first;
5255
}
53-
unsigned get_last_node(const address_mapt& amap) const
56+
unsigned get_last_node(const method_with_amapt& args) const
5457
{
55-
return (--amap.end())->first;
58+
return (--args.second.end())->first;
5659
}
57-
unsigned nodes_empty(const address_mapt& amap) const
60+
unsigned nodes_empty(const method_with_amapt& args) const
5861
{
59-
return amap.empty();
62+
return args.second.empty();
6063
}
6164
};
6265

@@ -744,7 +747,8 @@ void java_bytecode_convert_methodt::setup_local_variables(
744747
{
745748
// Compute CFG dominator tree
746749
java_cfg_dominatorst dominator_analysis;
747-
dominator_analysis(amap);
750+
method_with_amapt dominator_args(m,amap);
751+
dominator_analysis(dominator_args);
748752

749753
// Find out which local variable table entries should be merged:
750754
// Wrap each entry so we have somewhere to record live ranges with holes:

0 commit comments

Comments
 (0)