1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-03-30 02:33:03 -07:00

Speed up fix

Copied from Perforce
 Change: 21534
 ServerID: perforce.ravenbrook.com
This commit is contained in:
Pekka Pirinen 2000-09-22 20:09:56 +01:00
parent d1a0881cd4
commit 6a5eb19000

View file

@ -1,6 +1,6 @@
/* impl.c.poolamc: AUTOMATIC MOSTLY-COPYING MEMORY POOL CLASS
*
* $HopeName: !poolamc.c(trunk.38) $
* $HopeName: MMsrc!poolamc.c(MMconfigura_eval_fast.1) $
* Copyright (C) 2000 Harlequin Limited. All rights reserved.
*
* .sources: design.mps.poolamc.
@ -9,7 +9,7 @@
#include "mpscamc.h"
#include "mpm.h"
SRCID(poolamc, "$HopeName: !poolamc.c(trunk.38) $");
SRCID(poolamc, "$HopeName: MMsrc!poolamc.c(MMconfigura_eval_fast.1) $");
/* Binary i/f used by ASG (drj 1998-06-11) */
@ -1482,6 +1482,7 @@ Res AMCFix(Pool pool, ScanState ss, Seg seg, Ref *refIO)
RefSet summary; /* summary of object being relocated */
RefSet toSummary; /* summary of object's destination */
Seg toSeg; /* segment to which object is being relocated */
Bool shieldUp; /* whether we have exposed seg */
/* design.mps.trace.fix.noaver */
AVERT_CRITICAL(Pool, pool);
@ -1523,19 +1524,14 @@ Res AMCFix(Pool pool, ScanState ss, Seg seg, Ref *refIO)
ref = *refIO;
AVER_CRITICAL(SegBase(seg) <= ref);
AVER_CRITICAL(ref < SegLimit(seg));
arena = pool->arena;
if(SegNailed(seg) != TraceSetEMPTY) {
/* If segment is nailed then may have grey and white */
/* objects on same segment, hence segment may be protected */
/* hence we need to expose it to examine the broken heart. */
/* @@@@ This assumes a particular style of barrier. */
/* .access.read: Make sure seg isn't behind a read barrier. */
shieldUp = FALSE;
if (SegPM(seg) & AccessREAD) {
ShieldExpose(arena, seg);
} else {
AVER_CRITICAL((SegPM(seg) & AccessREAD) == AccessSetEMPTY);
shieldUp = TRUE;
}
/* .fix.ismoved: test for a broken heart */
newRef = (*format->isMoved)(ref);
if(newRef == (Addr)0) {
@ -1569,10 +1565,8 @@ Res AMCFix(Pool pool, ScanState ss, Seg seg, Ref *refIO)
AVER_CRITICAL(buffer != NULL);
length = AddrOffset(ref, (*format->skip)(ref));
++ss->forwardedCount;
STATISTIC_STAT(++ss->forwardedCount);
ss->forwardedSize += length;
do {
res = BUFFER_RESERVE(&newRef, buffer, length, FALSE);
if(res != ResOK)
@ -1585,8 +1579,8 @@ Res AMCFix(Pool pool, ScanState ss, Seg seg, Ref *refIO)
/* union the greyness and the summaries together. */
grey = TraceSetUnion(ss->traces, SegGrey(seg));
toGrey = SegGrey(toSeg);
if(TraceSetDiff(grey, toGrey) != TraceSetEMPTY &&
SegRankSet(seg) != RankSetEMPTY) {
if (TraceSetDiff(grey, toGrey) != TraceSetEMPTY) {
AVER_CRITICAL(SegRankSet(seg) != RankSetEMPTY);
SegSetGrey(toSeg, TraceSetUnion(toGrey, grey));
}
summary = SegSummary(seg);
@ -1602,17 +1596,17 @@ Res AMCFix(Pool pool, ScanState ss, Seg seg, Ref *refIO)
} while(!BUFFER_COMMIT(buffer, newRef, length));
ss->copiedSize += length;
/* @@@@ Must expose the old segment because it might be */
/* write protected. However, in the read barrier phase */
/* nothing white is accessible, so this could be optimized */
/* away. */
ShieldExpose(arena, seg);
(*format->move)(ref, newRef); /* install broken heart */
ShieldCover(arena, seg);
/* We know seg is readable, because we made sure in .access.read. */
/* Now make sure there's no write barrier. */
if (!shieldUp && (SegPM(seg) & AccessWRITE)) {
ShieldExpose(arena, seg);
shieldUp = TRUE;
}
(*format->move)(ref, newRef);
} else {
/* reference to broken heart (which should be snapped out -- */
/* consider adding to (non-existant) snap-out cache here) */
++ss->snapCount;
STATISTIC_STAT(++ss->snapCount);
}
/* .fix.update: update the reference to whatever the above code */
@ -1622,9 +1616,8 @@ updateReference:
res = ResOK;
returnRes:
if(SegNailed(seg) != TraceSetEMPTY) {
if (shieldUp)
ShieldCover(arena, seg);
}
return res;
}
@ -1651,6 +1644,7 @@ static Res AMCHeaderFix(Pool pool, ScanState ss, Seg seg, Ref *refIO)
RefSet summary; /* summary of object being relocated */
RefSet toSummary; /* summary of object's destination */
Seg toSeg; /* segment to which object is being relocated */
Bool shieldUp; /* whether we have exposed seg */
/* design.mps.trace.fix.noaver */
AVERT_CRITICAL(Pool, pool);
@ -1692,19 +1686,14 @@ static Res AMCHeaderFix(Pool pool, ScanState ss, Seg seg, Ref *refIO)
ref = *refIO;
AVER_CRITICAL(AddrAdd(SegBase(seg), pool->format->headerSize) <= ref);
AVER_CRITICAL(ref < SegLimit(seg)); /* see .ref-limit */
arena = pool->arena;
if(SegNailed(seg) != TraceSetEMPTY) {
/* If segment is nailed then may have grey and white */
/* objects on same segment, hence segment may be protected */
/* hence we need to expose it to examine the broken heart. */
/* @@@@ This assumes a particular style of barrier. */
/* .access.read.header: Make sure seg isn't behind a read barrier. */
shieldUp = FALSE;
if (SegPM(seg) & AccessREAD) {
ShieldExpose(arena, seg);
} else {
AVER_CRITICAL((SegPM(seg) & AccessREAD) == AccessSetEMPTY);
shieldUp = TRUE;
}
/* .fix.ismoved: test for a broken heart */
newRef = (*format->isMoved)(ref);
if(newRef == (Addr)0) {
@ -1738,10 +1727,8 @@ static Res AMCHeaderFix(Pool pool, ScanState ss, Seg seg, Ref *refIO)
AVER_CRITICAL(buffer != NULL);
length = AddrOffset(ref, (*format->skip)(ref));
++ss->forwardedCount;
STATISTIC_STAT(++ss->forwardedCount);
ss->forwardedSize += length;
do {
Size headerSize = format->headerSize;
@ -1757,8 +1744,8 @@ static Res AMCHeaderFix(Pool pool, ScanState ss, Seg seg, Ref *refIO)
/* union the greyness and the summaries together. */
grey = TraceSetUnion(ss->traces, SegGrey(seg));
toGrey = SegGrey(toSeg);
if(TraceSetDiff(grey, toGrey) != TraceSetEMPTY &&
SegRankSet(seg) != RankSetEMPTY) {
if (TraceSetDiff(grey, toGrey) != TraceSetEMPTY) {
AVER_CRITICAL(SegRankSet(seg) != RankSetEMPTY);
SegSetGrey(toSeg, TraceSetUnion(toGrey, grey));
}
summary = SegSummary(seg);
@ -1774,17 +1761,17 @@ static Res AMCHeaderFix(Pool pool, ScanState ss, Seg seg, Ref *refIO)
} while(!BUFFER_COMMIT(buffer, newBase, length));
ss->copiedSize += length;
/* @@@@ Must expose the old segment because it might be */
/* write protected. However, in the read barrier phase */
/* nothing white is accessible, so this could be optimized */
/* away. */
ShieldExpose(arena, seg);
(*format->move)(ref, newRef); /* install broken heart */
ShieldCover(arena, seg);
/* We know seg is readable, because we made sure in .access.read.header. */
/* Now make sure there's no write barrier. */
if (!shieldUp && (SegPM(seg) & AccessWRITE)) {
ShieldExpose(arena, seg);
shieldUp = TRUE;
}
(*format->move)(ref, newRef);
} else {
/* reference to broken heart (which should be snapped out -- */
/* consider adding to (non-existant) snap-out cache here) */
++ss->snapCount;
STATISTIC_STAT(++ss->snapCount);
}
/* .fix.update: update the reference to whatever the above code */
@ -1794,9 +1781,8 @@ updateReference:
res = ResOK;
returnRes:
if(SegNailed(seg) != TraceSetEMPTY) {
if (shieldUp)
ShieldCover(arena, seg);
}
return res;
}