Skip to content

Commit 2cc583f

Browse files
author
Daniel Kroening
authored
Merge pull request #213 from smowton/live_range_fix
Live range fix
2 parents 7f8e65f + bef5f77 commit 2cc583f

File tree

4 files changed

+44
-29
lines changed

4 files changed

+44
-29
lines changed
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Must compile this with -g (produces LocalVarTable) to exhibit bug.
2+
3+
public class LocalVarTable2 {
4+
5+
public static Object f() {
6+
for(int i = 0; i < 10; ++i) { System.out.printf("Count %d\n", i); }
7+
try {
8+
return new Object();
9+
}
10+
finally {
11+
System.out.println("Finally executed\n");
12+
}
13+
}
14+
15+
public static void main(String[] args) {
16+
f();
17+
}
18+
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
LocalVarTable2.class
3+
--show-goto-functions
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
return_value.*(void \*)i

src/java_bytecode/java_bytecode_convert_method.cpp

+18-29
Original file line numberDiff line numberDiff line change
@@ -99,35 +99,22 @@ class java_bytecode_convert_methodt:public messaget
9999
variablet &find_variable_for_slot(unsigned number_int, size_t address,
100100
variablest &var_list, instruction_sizet inst_size)
101101
{
102-
size_t var_list_length = var_list.size();
103-
if(var_list_length > 1)
104-
{
105-
for(variablet &var : var_list)
106-
{
107-
size_t start_pc = var.start_pc;
108-
size_t length = var.length;
109-
if (address + (size_t) inst_size >= start_pc && address < start_pc + length)
110-
return var;
111-
}
112-
// add unnamed local variable to end of list at this index
113-
// with scope from 0 to INT_MAX
114-
// as it is at the end of the vector, it will only be taken into account
115-
// if no other variable is valid
116-
size_t list_length = var_list.size();
117-
var_list.resize(list_length + 1);
118-
var_list[list_length].start_pc = 0;
119-
var_list[list_length].length = std::numeric_limits<size_t>::max();
120-
return var_list[list_length];
121-
}
122-
else if(var_list_length == 1)
123-
return var_list[0];
124-
else
125-
{
126-
// return reference to unnamed local variable
127-
// if no local variable is defined for this index
128-
var_list.resize(1);
129-
return var_list[0];
130-
}
102+
for(variablet &var : var_list)
103+
{
104+
size_t start_pc = var.start_pc;
105+
size_t length = var.length;
106+
if (address + (size_t) inst_size >= start_pc && address < start_pc + length)
107+
return var;
108+
}
109+
// add unnamed local variable to end of list at this index
110+
// with scope from 0 to INT_MAX
111+
// as it is at the end of the vector, it will only be taken into account
112+
// if no other variable is valid
113+
size_t list_length = var_list.size();
114+
var_list.resize(list_length + 1);
115+
var_list[list_length].start_pc = 0;
116+
var_list[list_length].length = std::numeric_limits<size_t>::max();
117+
return var_list[list_length];
131118
}
132119

133120
// JVM local variables
@@ -375,6 +362,8 @@ void java_bytecode_convert_methodt::convert(
375362
// add as a JVM variable
376363
std::size_t slots=get_variable_slots(parameters[i]);
377364
variables[param_index][0].symbol_expr=parameter_symbol.symbol_expr();
365+
variables[param_index][0].start_pc=0;
366+
variables[param_index][0].length = std::numeric_limits<size_t>::max();
378367
param_index+=slots;
379368
}
380369

0 commit comments

Comments
 (0)