diff --git a/src/bootimage.cpp b/src/bootimage.cpp index 32bfe75e82..05f99c605e 100644 --- a/src/bootimage.cpp +++ b/src/bootimage.cpp @@ -496,8 +496,10 @@ makeCodeImage(Thread* t, Zone* zone, BootImage* image, uint8_t* code, } if (fieldFlags(t, field) & ACC_STATIC) { - while (targetStaticOffset % targetSize) { - ++ targetStaticOffset; + unsigned excess = (targetStaticOffset % targetSize) + % TargetBytesPerWord; + if (excess) { + targetStaticOffset += TargetBytesPerWord - excess; } buildStaticOffset = fieldOffset(t, field); diff --git a/src/machine.cpp b/src/machine.cpp index 92622cd5ca..838564b5ef 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -1145,8 +1145,9 @@ parseFieldTable(Thread* t, Stream& s, object class_, object pool) unsigned size = fieldSize(t, code); if (flags & ACC_STATIC) { - while (staticOffset % size) { - ++ staticOffset; + unsigned excess = (staticOffset % size) % BytesPerWord; + if (excess) { + staticOffset += BytesPerWord - excess; } fieldOffset(t, field) = staticOffset;