fix broken field alignment in parseFieldTable which caused longs to overlap other fields on 32-bit systems in certain cases

This commit is contained in:
Joel Dice 2008-03-31 18:34:57 -06:00
parent 91494d9081
commit 907382bcee
2 changed files with 17 additions and 2 deletions

View File

@ -861,7 +861,7 @@ parseFieldTable(Thread* t, Stream& s, object class_, object pool)
if (flags & ACC_STATIC) {
unsigned size = fieldSize(t, code);
unsigned excess = staticOffset % size;
unsigned excess = (staticOffset % size) % BytesPerWord;
if (excess) {
staticOffset += BytesPerWord - excess;
}
@ -878,7 +878,7 @@ parseFieldTable(Thread* t, Stream& s, object class_, object pool)
abort(t); // todo: handle non-static field initializers
}
unsigned excess = memberOffset % fieldSize(t, code);
unsigned excess = (memberOffset % fieldSize(t, code)) % BytesPerWord;
if (excess) {
memberOffset += BytesPerWord - excess;
}

View File

@ -2,7 +2,22 @@ public class Misc {
private static int alpha;
private static int beta;
private static byte byte1, byte2, byte3;
private int gamma;
private int pajama;
private boolean boolean1;
private boolean boolean2;
private long time;
public Misc() {
expect(! boolean1);
expect(! boolean2);
time = 0xffffffffffffffffL;
expect(! boolean1);
expect(! boolean2);
}
private String foo(String s) {
return s;