32 cfg_base_nodet<T, java_bytecode_convert_methodt::method_offsett>>
56 (*this)[entry_map[
inst.first]].PC=
inst.first;
61 for(
auto succ :
inst.second.successors)
66 for(
const auto &
table_entry : method.exception_table)
71 "Exception table entry doesn't point to an instruction?");
85 entry_map.at(
findit->first),
145 return a.var.index<
b.var.index;
151 return a->var.start_pc<
b->var.start_pc;
158 std::set<local_variable_with_holest *> >
174 return findit->second.count(
b)>0;
188 std::set<local_variable_with_holest*> &result)
190 if(!result.insert(start).second)
214 if(
inst.args.size()==1)
217 const auto &arg=
inst.args[0];
225 "expected store instruction looks like store_0, store_1...");
229 "store_? instructions should end in a digit");
259 local_variable_table_with_holest::iterator
firstvar,
260 local_variable_table_with_holest::iterator
varlimit,
268 for(
auto idx = it->var.start_pc,
idxlim = it->var.start_pc + it->var.length;
304 local_variable_table_with_holest::iterator
firstvar,
305 local_variable_table_with_holest::iterator
varlimit,
319 "all entries are for the same local variable slot");
328 msg.debug() <<
"jcm: ppm: processing var idx " << it->var.index
329 <<
" name '" << it->var.name <<
"' start-pc "
330 << it->var.start_pc <<
" len " << it->var.length
335 const auto end_pc = it->var.start_pc + it->var.length;
339 "current bytecode shall not be the first");
346 "Instruction live range doesn't align to instruction boundary?");
385 "we shall not be on the first bytecode of the method");
392 msg.warning() <<
"Local variable table: ignoring flow from "
393 <<
"out of range for " << it->var.name <<
' '
402 msg.warning() <<
"Local variable table: didn't find initializing "
403 <<
"store for predecessor of bytecode at address "
405 <<
amapit->second.predecessors.size()
406 <<
" predecessors)" <<
msg.eom;
407 throw "local variable table: unexpected live ranges";
415 if(
pred_var->var.name!=it->var.name ||
416 pred_var->var.descriptor!=it->var.descriptor)
421 msg.warning() <<
"Local variable table: ignoring flow from "
422 <<
"clashing variable for "
423 << it->var.name <<
' ' <<
pred <<
" -> "
449 const std::set<local_variable_with_holest *> &
merge_vars,
455 std::numeric_limits<java_bytecode_convert_methodt::method_offsett>::max();
462 std::vector<java_bytecode_convert_methodt::method_offsett>
496 throw "variable live ranges with no common dominator?";
509 const std::set<local_variable_with_holest *> &
merge_vars,
541 const std::set<local_variable_with_holest *> &
merge_vars,
561 if(v->var.start_pc+v->var.length>
last_pc)
562 last_pc=v->var.start_pc+v->var.length;
598 local_variable_table_with_holest::iterator
firstvar,
599 local_variable_table_with_holest::iterator
varlimit,
668 local_variable_table_with_holest::iterator &
it1,
669 local_variable_table_with_holest::iterator &
it2,
670 local_variable_table_with_holest::iterator
itend)
679 auto index=
it2->var.index;
754 log.
debug() <<
"jcm: setup-local-vars: lvt size "
776 catch(
const char *message)
778 log.warning() <<
"Bytecode -> codet translation error: " << message
780 <<
"This is probably due to an unexpected LVT, "
781 <<
"falling back to translation without LVT" <<
messaget::eom;
802 log.debug() <<
"jcm: setup-local-vars: merged variable: idx " << v.var.index
803 <<
" name " << v.var.name <<
" v.var.descriptor '"
804 << v.var.descriptor <<
"' holes " << v.holes.size()
814 "A method name has the format class `.` method `:(`signature`)`.");
817 const typet t = v.var.signature.has_value()
819 v.var.descriptor, v.var.signature, class_name)
822 std::ostringstream
id_oss;
823 id_oss << method_id <<
"::" << v.var.start_pc <<
"::" << v.var.name;
831 variables[v.var.index].emplace_back(
832 result, v.var.start_pc, v.var.length,
false, std::move(v.holes));
836 new_symbol.base_name=v.var.name;
837 new_symbol.pretty_name=
id2string(identifier).substr(6, std::string::npos);
838 new_symbol.is_file_local=
true;
839 new_symbol.is_thread_local=
true;
840 new_symbol.is_lvalue=
true;
841 symbol_table.add(new_symbol);
858 size_t start_pc=var.start_pc;
859 size_t length=var.length;
860 if(address>=start_pc && address<(start_pc+length))
863 for(
auto &
hole : var.holes)
864 if(address>=
hole.start_pc && address<(
hole.start_pc+
hole.length))
struct bytecode_infot const bytecode_info[]
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
entryt & at(const goto_programt::const_targett &t)
entryt get_node_index(const goto_programt::const_targett &program_point) const
Get the graph node index for program_point.
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
A generic directed graph with a parametric node type.
node_indext add_node(arguments &&... values)
void add_edge(node_indext a, node_indext b)
method_offsett slots_for_parameters
Number of local variable slots used by the JVM to pass parameters upon invocation of the method under...
std::vector< variablet > variablest
void setup_local_variables(const methodt &m, const address_mapt &amap)
See find_initializers_for_slot above for more detail.
const variablet & find_variable_for_slot(size_t address, variablest &var_list)
See above.
void find_initializers(local_variable_table_with_holest &vars, const address_mapt &amap, const java_cfg_dominatorst &doms)
See find_initializers_for_slot above for more detail.
std::vector< local_variable_with_holest > local_variable_table_with_holest
void find_initializers_for_slot(local_variable_table_with_holest::iterator firstvar, local_variable_table_with_holest::iterator varlimit, const address_mapt &amap, const java_cfg_dominatorst &doms)
Given a sequence of users of the same local variable slot, this figures out which ones are related by...
bool is_parameter(const local_variablet &v)
Returns true iff the slot index of the local variable of a method (coming from the LVT) is a paramete...
std::map< method_offsett, converted_instructiont > address_mapt
Class that provides messages with a built-in verbosity 'level'.
message_handlert & get_message_handler()
mstreamt & status() const
Expression to hold a symbol (variable)
The type of an expression, extends irept.
const std::string & id2string(const irep_idt &d)
JAVA Bytecode Language Conversion.
static void maybe_add_hole(local_variable_with_holest &var, java_bytecode_convert_methodt::method_offsett from, java_bytecode_convert_methodt::method_offsett to)
See above.
std::map< local_variable_with_holest *, std::set< local_variable_with_holest * > > predecessor_mapt
static bool lt_index(const local_variable_with_holest &a, const local_variable_with_holest &b)
java_bytecode_convert_methodt::java_cfg_dominatorst java_cfg_dominatorst
static void populate_variable_address_map(local_variable_table_with_holest::iterator firstvar, local_variable_table_with_holest::iterator varlimit, std::vector< local_variable_with_holest * > &live_variable_at_address)
See above.
static bool is_store_to_slot(const java_bytecode_convert_methodt::instructiont &inst, unsigned slotidx)
See above.
static void populate_predecessor_map(local_variable_table_with_holest::iterator firstvar, local_variable_table_with_holest::iterator varlimit, const std::vector< local_variable_with_holest * > &live_variable_at_address, const address_mapt &amap, predecessor_mapt &predecessor_map, message_handlert &msg_handler)
Populates the predecessor_map with a graph from local variable table entries to their predecessors (t...
static void populate_live_range_holes(local_variable_with_holest &merge_into, const std::set< local_variable_with_holest * > &merge_vars, java_bytecode_convert_methodt::method_offsett expanded_live_range_start)
See above.
static bool lt_startpc(const local_variable_with_holest *a, const local_variable_with_holest *b)
java_bytecode_convert_methodt::address_mapt address_mapt
java_bytecode_convert_methodt::holet holet
static void cleanup_var_table(std::vector< local_variable_with_holest > &vars_with_holes)
See above.
static java_bytecode_convert_methodt::method_offsett get_common_dominator(const std::set< local_variable_with_holest * > &merge_vars, const java_cfg_dominatorst &dominator_analysis)
Used to find out where to put a variable declaration that subsumes several variable live ranges.
java_bytecode_convert_methodt::local_variable_with_holest local_variable_with_holest
static void walk_to_next_index(local_variable_table_with_holest::iterator &it1, local_variable_table_with_holest::iterator &it2, local_variable_table_with_holest::iterator itend)
Walk a vector, a contiguous block of entries with equal slot index at a time.
static void merge_variable_table_entries(local_variable_with_holest &merge_into, const std::set< local_variable_with_holest * > &merge_vars, const java_cfg_dominatorst &dominator_analysis, std::ostream &debug_out)
See above.
java_bytecode_convert_methodt::local_variable_table_with_holest local_variable_table_with_holest
static void gather_transitive_predecessors(local_variable_with_holest *start, const predecessor_mapt &predecessor_map, std::set< local_variable_with_holest * > &result)
See above.
std::optional< typet > java_type_from_string(const std::string &src, const std::string &class_name_prefix)
Transforms a string representation of a Java type into an internal type representation thereof.
std::optional< typet > java_type_from_string_with_exception(const std::string &descriptor, const std::optional< std::string > &signature, const std::string &class_name)
#define PRECONDITION(CONDITION)
#define INVARIANT(CONDITION, REASON)
This macro uses the wrapper function 'invariant_violated_string'.
const constant_exprt & to_constant_expr(const exprt &expr)
Cast an exprt to a constant_exprt.
unsigned safe_string2unsigned(const std::string &str, int base)
bool operator()(local_variable_with_holest *a, local_variable_with_holest *b) const
is_predecessor_oft(const predecessor_mapt &_order)
const predecessor_mapt & order
std::vector< holet > holes
std::pair< const methodt &, const address_mapt & > method_with_amap
local_variable_tablet local_variable_table
nodet & get_node(const java_bytecode_convert_methodt::method_offsett &instruction)
procedure_local_cfg_baset()
java_bytecode_convert_methodt::method_with_amapt method_with_amapt
java_bytecode_convert_methodt::method_offsett get_node_index(const java_bytecode_convert_methodt::method_offsett &instruction) const
const nodet & get_node(const java_bytecode_convert_methodt::method_offsett &instruction) const
std::map< java_bytecode_convert_methodt::method_offsett, java_bytecode_convert_methodt::method_offsett > entry_mapt
static bool nodes_empty(const method_with_amapt &args)
static java_bytecode_convert_methodt::method_offsett get_first_node(const method_with_amapt &args)
grapht< cfg_base_nodet< T, java_bytecode_convert_methodt::method_offsett > > base_grapht
void operator()(const method_with_amapt &args)
static java_bytecode_convert_methodt::method_offsett get_last_node(const method_with_amapt &args)