From fa29a3a5e0ea147ce83d0340430b359df9dfb2fe Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Wed, 8 Oct 2014 21:13:34 +0100 Subject: [PATCH] Amc now asserts that references (unless ambiguous) are aligned to the pool alignment. Copied from Perforce Change: 187162 ServerID: perforce.ravenbrook.com --- mps/code/poolamc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mps/code/poolamc.c b/mps/code/poolamc.c index c22d7732b18..4e9ed70396d 100644 --- a/mps/code/poolamc.c +++ b/mps/code/poolamc.c @@ -1700,6 +1700,7 @@ static Res AMCFix(Pool pool, ScanState ss, Seg seg, Ref *refIO) AVERT_CRITICAL(AMC, amc); format = pool->format; ref = *refIO; + AVER_CRITICAL(AddrIsAligned(ref, PoolAlignment(pool))); AVER_CRITICAL(SegBase(seg) <= ref); AVER_CRITICAL(ref < SegLimit(seg)); arena = pool->arena; @@ -1805,6 +1806,7 @@ static Res AMCHeaderFix(Pool pool, ScanState ss, Seg seg, Ref *refIO) Format format; /* cache of pool->format */ Size headerSize; /* cache of pool->format->headerSize */ Ref ref; /* reference to be fixed */ + Addr base; /* base address of reference */ Ref newRef; /* new location, if moved */ Addr newBase; /* base address of new copy */ Size length; /* length of object to be relocated */ @@ -1853,6 +1855,8 @@ static Res AMCHeaderFix(Pool pool, ScanState ss, Seg seg, Ref *refIO) headerSize = format->headerSize; ref = *refIO; AVER_CRITICAL(AddrAdd(SegBase(seg), headerSize) <= ref); + base = AddrSub(ref, headerSize); + AVER_CRITICAL(AddrIsAligned(base, PoolAlignment(pool))); AVER_CRITICAL(ref < SegLimit(seg)); /* see .ref-limit */ arena = pool->arena; @@ -1919,7 +1923,7 @@ static Res AMCHeaderFix(Pool pool, ScanState ss, Seg seg, Ref *refIO) SegSetGrey(toSeg, TraceSetUnion(SegGrey(toSeg), grey)); /* */ - (void)AddrCopy(newBase, AddrSub(ref, headerSize), length); /* .exposed.seg */ + (void)AddrCopy(newBase, base, length); /* .exposed.seg */ ShieldCover(arena, toSeg); } while (!BUFFER_COMMIT(buffer, newBase, length));