Skip to content

Live range fix #213

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
merged 4 commits into from
Aug 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
19 changes: 19 additions & 0 deletions regression/cbmc-java/LocalVarTable2/LocalVarTable2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Must compile this with -g (produces LocalVarTable) to exhibit bug.

public class LocalVarTable2 {

public static Object f() {
for(int i = 0; i < 10; ++i) { System.out.printf("Count %d\n", i); }
try {
return new Object();
}
finally {
System.out.println("Finally executed\n");
}
}

public static void main(String[] args) {
f();
}

}
7 changes: 7 additions & 0 deletions regression/cbmc-java/LocalVarTable2/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CORE
LocalVarTable2.class
--show-goto-functions
^EXIT=0$
^SIGNAL=0$
--
return_value.*(void \*)i
47 changes: 18 additions & 29 deletions src/java_bytecode/java_bytecode_convert_method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,35 +99,22 @@ class java_bytecode_convert_methodt:public messaget
variablet &find_variable_for_slot(unsigned number_int, size_t address,
variablest &var_list, instruction_sizet inst_size)
{
size_t var_list_length = var_list.size();
if(var_list_length > 1)
{
for(variablet &var : var_list)
{
size_t start_pc = var.start_pc;
size_t length = var.length;
if (address + (size_t) inst_size >= start_pc && address < start_pc + length)
return var;
}
// add unnamed local variable to end of list at this index
// with scope from 0 to INT_MAX
// as it is at the end of the vector, it will only be taken into account
// if no other variable is valid
size_t list_length = var_list.size();
var_list.resize(list_length + 1);
var_list[list_length].start_pc = 0;
var_list[list_length].length = std::numeric_limits<size_t>::max();
return var_list[list_length];
}
else if(var_list_length == 1)
return var_list[0];
else
{
// return reference to unnamed local variable
// if no local variable is defined for this index
var_list.resize(1);
return var_list[0];
}
for(variablet &var : var_list)
{
size_t start_pc = var.start_pc;
size_t length = var.length;
if (address + (size_t) inst_size >= start_pc && address < start_pc + length)
return var;
}
// add unnamed local variable to end of list at this index
// with scope from 0 to INT_MAX
// as it is at the end of the vector, it will only be taken into account
// if no other variable is valid
size_t list_length = var_list.size();
var_list.resize(list_length + 1);
var_list[list_length].start_pc = 0;
var_list[list_length].length = std::numeric_limits<size_t>::max();
return var_list[list_length];
}

// JVM local variables
Expand Down Expand Up @@ -375,6 +362,8 @@ void java_bytecode_convert_methodt::convert(
// add as a JVM variable
std::size_t slots=get_variable_slots(parameters[i]);
variables[param_index][0].symbol_expr=parameter_symbol.symbol_expr();
variables[param_index][0].start_pc=0;
variables[param_index][0].length = std::numeric_limits<size_t>::max();
param_index+=slots;
}

Expand Down