From 4e4d109787fdb9b38b48ed83eae7cf0d4bcb25c3 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Wed, 28 Sep 2011 11:12:21 -0600 Subject: [PATCH] fix regression in static field offset calculation One of the changes in commit 5b4f179 broke this calculation. --- src/bootimage.cpp | 6 ++++-- src/machine.cpp | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) 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;