Skip to content

Commit e64d9c9

Browse files
author
Daniel Kroening
authored
Merge pull request #1276 from smowton/smowton/fix/java_pointer_width
Force Java pointers to always occupy one stack slot
2 parents 31e7382 + 9d74906 commit e64d9c9

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/java_bytecode/java_utils.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,21 @@ bool java_is_array_type(const typet &type)
2828

2929
unsigned java_local_variable_slots(const typet &t)
3030
{
31+
32+
// Even on a 64-bit platform, Java pointers occupy one slot:
33+
if(t.id()==ID_pointer)
34+
return 1;
35+
3136
unsigned bitwidth;
3237

3338
bitwidth=t.get_unsigned_int(ID_width);
3439
INVARIANT(
35-
bitwidth==0 ||
3640
bitwidth==8 ||
3741
bitwidth==16 ||
3842
bitwidth==32 ||
3943
bitwidth==64,
4044
"all types constructed in java_types.cpp encode JVM types "
4145
"with these bit widths");
42-
INVARIANT(
43-
bitwidth!=0 || t.id()==ID_pointer,
44-
"if bitwidth is 0, then this a reference to a class, which is 1 slot");
4546

4647
return bitwidth==64 ? 2 : 1;
4748
}

0 commit comments

Comments
 (0)