diff --git a/src/bootimage.cpp b/src/bootimage.cpp index 3d75f4401c..dd408705e2 100644 --- a/src/bootimage.cpp +++ b/src/bootimage.cpp @@ -502,10 +502,8 @@ makeCodeImage(Thread* t, Zone* zone, BootImage* image, uint8_t* code, } if (fieldFlags(t, field) & ACC_STATIC) { - unsigned excess = (targetStaticOffset % targetSize) - % TargetBytesPerWord; - if (excess) { - targetStaticOffset += TargetBytesPerWord - excess; + while (targetStaticOffset % targetSize) { + ++ targetStaticOffset; } buildStaticOffset = fieldOffset(t, field); diff --git a/src/machine.cpp b/src/machine.cpp index e4dcf2ad2c..182308f8d4 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -1164,9 +1164,8 @@ parseFieldTable(Thread* t, Stream& s, object class_, object pool) unsigned size = fieldSize(t, code); if (flags & ACC_STATIC) { - unsigned excess = (staticOffset % size) % BytesPerWord; - if (excess) { - staticOffset += BytesPerWord - excess; + while (staticOffset % size) { + ++ staticOffset; } fieldOffset(t, field) = staticOffset; @@ -1205,9 +1204,8 @@ parseFieldTable(Thread* t, Stream& s, object class_, object pool) for (unsigned i = 0, offset = 0; i < staticCount; ++i) { unsigned size = fieldSize(t, RUNTIME_ARRAY_BODY(staticTypes)[i]); - unsigned excess = offset % size; - if (excess) { - offset += BytesPerWord - excess; + while (offset % size) { + ++ offset; } unsigned value = intArrayBody(t, staticValueTable, i);