Skip to content

Commit 4e85606

Browse files
author
Daniel Kroening
authored
Merge pull request #329 from smowton/fix_dup2
Fix dup2, pop2 et al operating on pointers
2 parents 828e1da + bcb106b commit 4e85606

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/java_bytecode/java_bytecode_convert_method.cpp

+12-5
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,13 @@ Function: java_bytecode_convert_methodt::convert_instructions
493493
494494
\*******************************************************************/
495495

496+
static unsigned get_bytecode_type_width(const typet& ty)
497+
{
498+
if(ty.id()==ID_pointer)
499+
return 32;
500+
return ty.get_unsigned_int(ID_width);
501+
}
502+
496503
codet java_bytecode_convert_methodt::convert_instructions(
497504
const instructionst &instructions,
498505
const code_typet &method_type)
@@ -1158,7 +1165,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
11581165
{
11591166
assert(!stack.empty() && results.empty());
11601167

1161-
if(stack.back().type().get_unsigned_int(ID_width)==32)
1168+
if(get_bytecode_type_width(stack.back().type())==32)
11621169
op=pop(2);
11631170
else
11641171
op=pop(1);
@@ -1170,7 +1177,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
11701177
{
11711178
assert(!stack.empty() && results.empty());
11721179

1173-
if(stack.back().type().get_unsigned_int(ID_width)==32)
1180+
if(get_bytecode_type_width(stack.back().type())==32)
11741181
op=pop(3);
11751182
else
11761183
op=pop(2);
@@ -1182,15 +1189,15 @@ codet java_bytecode_convert_methodt::convert_instructions(
11821189
{
11831190
assert(!stack.empty() && results.empty());
11841191

1185-
if(stack.back().type().get_unsigned_int(ID_width)==32)
1192+
if(get_bytecode_type_width(stack.back().type())==32)
11861193
op=pop(2);
11871194
else
11881195
op=pop(1);
11891196

11901197
assert(!stack.empty());
11911198
exprt::operandst op2;
11921199

1193-
if(stack.back().type().get_unsigned_int(ID_width)==32)
1200+
if(get_bytecode_type_width(stack.back().type())==32)
11941201
op2=pop(2);
11951202
else
11961203
op2=pop(1);
@@ -1387,7 +1394,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
13871394
// two-word item (i.e. a double or a long).
13881395
// http://cs.au.dk/~mis/dOvs/jvmspec/ref-pop2.html
13891396
if(statement=="pop2" &&
1390-
op[0].type().get_unsigned_int(ID_width)==32)
1397+
get_bytecode_type_width(op[0].type())==32)
13911398
pop(1);
13921399
}
13931400
else if(statement=="instanceof")

0 commit comments

Comments
 (0)