diff --git a/mps/code/poolawl.c b/mps/code/poolawl.c index 6332a91b7cd..edcae788e3c 100644 --- a/mps/code/poolawl.c +++ b/mps/code/poolawl.c @@ -558,6 +558,7 @@ static Res AWLInit(Pool pool, ArgList args) AVERT(Format, format); pool->format = format; + pool->alignment = format->alignment; AVER(FUNCHECK(findDependent)); awl->findDependent = findDependent; @@ -570,7 +571,7 @@ static Res AWLInit(Pool pool, ArgList args) if (res != ResOK) goto failGenInit; - awl->alignShift = SizeLog2(pool->alignment); + awl->alignShift = SizeLog2(PoolAlignment(pool)); awl->size = (Size)0; awl->succAccesses = 0; @@ -937,7 +938,7 @@ static Res awlScanSinglePass(Bool *anyScannedReturn, i = awlIndexOfAddr(base, awl, p); if (!BTGet(awlseg->alloc, i)) { - p = AddrAdd(p, pool->alignment); + p = AddrAdd(p, PoolAlignment(pool)); continue; } hp = AddrAdd(p, format->headerSize); @@ -954,7 +955,8 @@ static Res awlScanSinglePass(Bool *anyScannedReturn, } objectLimit = AddrSub(objectLimit, format->headerSize); AVER(p < objectLimit); - p = AddrAlignUp(objectLimit, pool->alignment); + AVER(AddrIsAligned(objectLimit, PoolAlignment(pool))); + p = objectLimit; } AVER(p == limit); @@ -1051,7 +1053,7 @@ static Res AWLFix(Pool pool, ScanState ss, Seg seg, Ref *refIO) switch(ss->rank) { case RankAMBIG: /* not a real pointer if not aligned or not allocated */ - if (!AddrIsAligned(base, pool->alignment) || !BTGet(awlseg->alloc, i)) + if (!AddrIsAligned(base, sizeof(void *)) || !BTGet(awlseg->alloc, i)) return ResOK; /* falls through */ case RankEXACT: @@ -1125,7 +1127,7 @@ static void AWLReclaim(Pool pool, Trace trace, Seg seg) } q = format->skip(AddrAdd(p, format->headerSize)); q = AddrSub(q, format->headerSize); - q = AddrAlignUp(q, pool->alignment); + AVER(AddrIsAligned(q, PoolAlignment(pool))); j = awlIndexOfAddr(base, awl, q); AVER(j <= awlseg->grains); if(BTGet(awlseg->mark, i)) { @@ -1243,13 +1245,13 @@ static void AWLWalk(Pool pool, Seg seg, FormattedObjectsStepMethod f, i = awlIndexOfAddr(base, awl, object); if (!BTGet(awlseg->alloc, i)) { /* This grain is free */ - object = AddrAdd(object, pool->alignment); + object = AddrAdd(object, PoolAlignment(pool)); continue; } object = AddrAdd(object, format->headerSize); next = format->skip(object); next = AddrSub(next, format->headerSize); - next = AddrAlignUp(next, pool->alignment); + AVER(AddrIsAligned(next, PoolAlignment(pool))); if (BTGet(awlseg->mark, i) && BTGet(awlseg->scanned, i)) (*f)(object, pool->format, pool, p, s); object = next; diff --git a/mps/manual/source/pool/awl.rst b/mps/manual/source/pool/awl.rst index 4128339227a..79df0258804 100644 --- a/mps/manual/source/pool/awl.rst +++ b/mps/manual/source/pool/awl.rst @@ -282,11 +282,10 @@ the format of objects allocated in it: that it does not look like an aligned pointer. "Aligned pointer" means a word whose numeric value (that is, its - value when treated as an unsigned integer) is a multiple of the - architecture's :term:`natural alignment` (see - :c:macro:`MPS_PF_ALIGN`). If you're using a 32-bit architecture, - that means that an aligned pointer is a multiple of 4 and its bottom - two bits are both zero. + value when treated as an unsigned integer) is a multiple of the size + of a pointer. For you're using a 32-bit architecture, that means + that an aligned pointer is a multiple of 4 and its bottom two bits + are both zero. The bottom line is that references from an object in an AWL pool must be untagged and aligned, and integers must be tagged with a diff --git a/mps/manual/source/release.rst b/mps/manual/source/release.rst index 294b6545b91..83e23aea3c3 100644 --- a/mps/manual/source/release.rst +++ b/mps/manual/source/release.rst @@ -27,6 +27,16 @@ New features calling :c:func:`mps_pool_create_k`. +Other changes +............. + +#. The alignment of :ref:`pool-awl` pools is now configurable via the + object format, as documented, and is no longer always + :c:macro:`MPS_PF_ALIGN`. See job003745_. + + .. _job003745: https://www.ravenbrook.com/project/mps/issue/job003745/ + + .. _release-notes-1.113: Release 1.113.0