From abaf0b63da031c8ada9e965740e643d485ba0c69 Mon Sep 17 00:00:00 2001 From: David Jones Date: Thu, 19 Jul 2007 17:56:04 +0100 Subject: [PATCH] Mps: trace.c formatting changes. Copied from Perforce Change: 162951 ServerID: perforce.ravenbrook.com --- mps/code/trace.c | 176 +++++++++++++++++++++++------------------------ 1 file changed, 88 insertions(+), 88 deletions(-) diff --git a/mps/code/trace.c b/mps/code/trace.c index 432227170ba..69b7948af21 100644 --- a/mps/code/trace.c +++ b/mps/code/trace.c @@ -322,7 +322,7 @@ void ScanStateInit(ScanState ss, TraceSet ts, Arena arena, ss->fix = TraceFix; TRACE_SET_ITER(ti, trace, ts, arena) - if (trace->emergency) { + if(trace->emergency) { ss->fix = TraceFixEmergency; } TRACE_SET_ITER_END(ti, trace, ts, arena); @@ -497,25 +497,25 @@ static void traceUpdateCounts(Trace trace, ScanState ss, traceAccountingPhase phase) { switch(phase) { - case traceAccountingPhaseRootScan: - trace->rootScanSize += ss->scannedSize; - trace->rootCopiedSize += ss->copiedSize; - STATISTIC(++trace->rootScanCount); - break; - - case traceAccountingPhaseSegScan: - trace->segScanSize += ss->scannedSize; /* see .workclock */ - trace->segCopiedSize += ss->copiedSize; - STATISTIC(++trace->segScanCount); - break; - - case traceAccountingPhaseSingleScan: - STATISTIC(trace->singleScanSize += ss->scannedSize); - STATISTIC(trace->singleCopiedSize += ss->copiedSize); - break; - - default: - NOTREACHED; + case traceAccountingPhaseRootScan: { + trace->rootScanSize += ss->scannedSize; + trace->rootCopiedSize += ss->copiedSize; + STATISTIC(++trace->rootScanCount); + break; + } + case traceAccountingPhaseSegScan: { + trace->segScanSize += ss->scannedSize; /* see .workclock */ + trace->segCopiedSize += ss->copiedSize; + STATISTIC(++trace->segScanCount); + break; + } + case traceAccountingPhaseSingleScan: { + STATISTIC(trace->singleScanSize += ss->scannedSize); + STATISTIC(trace->singleCopiedSize += ss->copiedSize); + break; + } + default: + NOTREACHED; } STATISTIC(trace->fixRefCount += ss->fixRefCount); STATISTIC(trace->segRefCount += ss->segRefCount); @@ -598,15 +598,15 @@ Res TraceAddWhite(Trace trace, Seg seg) /* Give the pool the opportunity to turn the segment white. */ /* If it fails, unwind. */ res = PoolWhiten(pool, trace, seg); - if (res != ResOK) + if(res != ResOK) return res; /* Add the segment to the approximation of the white set the */ /* pool made it white. */ - if (TraceSetIsMember(SegWhite(seg), trace)) { + if(TraceSetIsMember(SegWhite(seg), trace)) { trace->white = ZoneSetUnion(trace->white, ZoneSetOfSeg(trace->arena, seg)); /* if the pool is a moving GC, then condemned objects may move */ - if (pool->class->attr & AttrMOVINGGC) { + if(pool->class->attr & AttrMOVINGGC) { trace->mayMove = ZoneSetUnion(trace->mayMove, ZoneSetOfSeg(trace->arena, seg)); } @@ -641,7 +641,7 @@ Res TraceCondemnZones(Trace trace, ZoneSet condemnedSet) arena = trace->arena; - if (SegFirst(&seg, arena)) { + if(SegFirst(&seg, arena)) { Addr base; do { base = SegBase(seg); @@ -655,10 +655,10 @@ Res TraceCondemnZones(Trace trace, ZoneSet condemnedSet) /* the requested zone set. Otherwise, we would bloat the */ /* foundation to no gain. Note that this doesn't exclude */ /* any segments from which the condemned set was derived, */ - if ((SegPool(seg)->class->attr & AttrGC) != 0 + if((SegPool(seg)->class->attr & AttrGC) != 0 && ZoneSetSuper(condemnedSet, ZoneSetOfSeg(arena, seg))) { res = TraceAddWhite(trace, seg); - if (res != ResOK) + if(res != ResOK) return res; } } while (SegNext(&seg, arena, base)); @@ -719,7 +719,7 @@ static void traceScanRoot(TraceSet ts, Rank rank, Arena arena, Root root) Res res; res = traceScanRootRes(ts, rank, arena, root); - if (res != ResOK) { + if(res != ResOK) { AVER(ResIsAllocFailure(res)); traceSetSignalEmergency(ts, arena); res = traceScanRootRes(ts, rank, arena, root); @@ -751,7 +751,7 @@ static Res rootFlip(Root root, void *p) AVER(RootRank(root) <= RankEXACT); /* see .root.rank */ - if (RootRank(root) == rf->rank) + if(RootRank(root) == rf->rank) traceScanRoot(rf->ts, rf->rank, rf->arena, root); return ResOK; @@ -781,7 +781,7 @@ static void traceFlip(Trace trace) /* Update location dependency structures. */ /* mayMove is a conservative approximation of the zones of objects */ /* which may move during this collection. */ - if (trace->mayMove != ZoneSetEMPTY) { + if(trace->mayMove != ZoneSetEMPTY) { LDAge(arena, trace->mayMove); } @@ -815,7 +815,7 @@ static void traceFlip(Trace trace) for(rank = 0; rank < RankLIMIT; ++rank) RING_FOR(node, ArenaGreyRing(arena, rank), nextNode) { Seg seg = SegOfGreyRing(node); - if (TraceSetInter(SegGrey(seg), arena->flippedTraces) == TraceSetEMPTY + if(TraceSetInter(SegGrey(seg), arena->flippedTraces) == TraceSetEMPTY && TraceSetIsMember(SegGrey(seg), trace)) ShieldRaise(arena, seg, AccessREAD); } @@ -938,7 +938,7 @@ void TraceDestroy(Trace trace) AVERT(Trace, trace); AVER(trace->state == TraceFINISHED); - if (trace->chain == NULL) { + if(trace->chain == NULL) { Ring chainNode, nextChainNode; /* Notify all the chains. */ @@ -998,7 +998,7 @@ static void tracePostMessage(Trace trace) arena = trace->arena; res = ControlAlloc(&p, arena, sizeof(TraceMessageStruct), FALSE); - if (res == ResOK) { + if(res == ResOK) { message = (TraceMessage)p; TraceMessageInit(arena, message); message->liveSize = trace->forwardedSize + trace->preservedInPlaceSize; @@ -1022,14 +1022,14 @@ static void traceReclaim(Trace trace) EVENT_P(TraceReclaim, trace); arena = trace->arena; - if (SegFirst(&seg, arena)) { + if(SegFirst(&seg, arena)) { Addr base; do { base = SegBase(seg); /* There shouldn't be any grey stuff left for this trace. */ AVER_CRITICAL(!TraceSetIsMember(SegGrey(seg), trace)); - if (TraceSetIsMember(SegWhite(seg), trace)) { + if(TraceSetIsMember(SegWhite(seg), trace)) { AVER_CRITICAL((SegPool(seg)->class->attr & AttrGC) != 0); STATISTIC(++trace->reclaimCount); PoolReclaim(SegPool(seg), trace, seg); @@ -1048,7 +1048,7 @@ static void traceReclaim(Trace trace) UNUSED(nonWhiteSeg); /* */ } } - } while (SegNext(&seg, arena, base)); + } while(SegNext(&seg, arena, base)); } trace->state = TraceFINISHED; @@ -1185,7 +1185,7 @@ static void traceFindGrey_diag(Bool found, Rank rank) segcount += 1; } else { /* Change of rank: add prev rank and segcount to report */ - if( (report_lim - report_array) + 2 > report_maxchars) { + if((report_lim - report_array) + 2 > report_maxchars) { /* no space to add 2 chars */ report_array[0] = '!'; } else { @@ -1272,12 +1272,12 @@ static Res traceScanSegRes(TraceSet ts, Rank rank, Arena arena, Seg seg) white = traceSetWhiteUnion(ts, arena); - /* only scan a segment if it refers to the white set */ - if (ZoneSetInter(white, SegSummary(seg)) == ZoneSetEMPTY) { + /* Only scan a segment if it refers to the white set. */ + if(ZoneSetInter(white, SegSummary(seg)) == ZoneSetEMPTY) { PoolBlacken(SegPool(seg), ts, seg); - /* setup result code to return later */ + /* Setup result code to return later. */ res = ResOK; - } else { /* scan it */ + } else { /* scan it */ ScanStateStruct ss; ScanStateInit(&ss, ts, arena, rank, white); @@ -1297,20 +1297,20 @@ static Res traceScanSegRes(TraceSet ts, Rank rank, Arena arena, Seg seg) TRACE_SET_ITER(ti, trace, ts, arena) whiteSegRefCount += trace->whiteSegRefCount; TRACE_SET_ITER_END(ti, trace, ts, arena); - if (whiteSegRefCount == 0) + if(whiteSegRefCount == 0) TRACE_SET_ITER(ti, trace, ts, arena) ++trace->pointlessScanCount; TRACE_SET_ITER_END(ti, trace, ts, arena); }); - /* following is true whether or not scan was total */ + /* Following is true whether or not scan was total. */ /* See . */ /* .verify.segsummary: were the seg contents, as found by this * scan, consistent with the recorded SegSummary? */ AVER(RefSetSub(ss.unfixedSummary, SegSummary(seg))); - if (res != ResOK || !wasTotal) { + if(res != ResOK || !wasTotal) { /* scan was partial, so... */ /* scanned summary should be ORed into segment summary. */ SegSetSummary(seg, RefSetUnion(SegSummary(seg), ScanStateSummary(&ss))); @@ -1323,7 +1323,7 @@ static Res traceScanSegRes(TraceSet ts, Rank rank, Arena arena, Seg seg) ScanStateFinish(&ss); } - if (res == ResOK) { + if(res == ResOK) { /* The segment is now black only if scan was successful. */ /* Remove the greyness from it. */ SegSetGrey(seg, TraceSetDiff(SegGrey(seg), ts)); @@ -1343,11 +1343,11 @@ static void traceScanSeg(TraceSet ts, Rank rank, Arena arena, Seg seg) Res res; res = traceScanSegRes(ts, rank, arena, seg); - if (res != ResOK) { + if(res != ResOK) { AVER(ResIsAllocFailure(res)); traceSetSignalEmergency(ts, arena); res = traceScanSegRes(ts, rank, arena, seg); - /* should be OK in emergency mode */ + /* Should be OK in emergency mode. */ } AVER(ResOK == res); @@ -1376,7 +1376,7 @@ void TraceSegAccess(Arena arena, Seg seg, AccessSet mode) EVENT_PPU(TraceAccess, arena, seg, mode); - if ((mode & SegSM(seg) & AccessREAD) != 0) { /* read barrier? */ + if((mode & SegSM(seg) & AccessREAD) != 0) { /* read barrier? */ /* Pick set of traces to scan for: */ TraceSet traces = arena->flippedTraces; @@ -1397,13 +1397,13 @@ void TraceSegAccess(Arena arena, Seg seg, AccessSet mode) ++trace->readBarrierHitCount; TRACE_SET_ITER_END(ti, trace, traces, arena); }); - } else { /* write barrier */ + } else { /* write barrier */ STATISTIC(++arena->writeBarrierHitCount); } /* The write barrier handling must come after the read barrier, */ /* because the latter may set the summary and raise the write barrier. */ - if ((mode & SegSM(seg) & AccessWRITE) != 0) /* write barrier? */ + if((mode & SegSM(seg) & AccessWRITE) != 0) /* write barrier? */ SegSetSummary(seg, RefSetUNIV); /* The segment must now be accessible. */ @@ -1429,10 +1429,10 @@ Res TraceFix(ScanState ss, Ref *refIO) EVENT_PPAU(TraceFix, ss, refIO, ref, ss->rank); TRACT_OF_ADDR(&tract, ss->arena, ref); - if (tract) { - if (TraceSetInter(TractWhite(tract), ss->traces) != TraceSetEMPTY) { + if(tract) { + if(TraceSetInter(TractWhite(tract), ss->traces) != TraceSetEMPTY) { Seg seg; - if (TRACT_SEG(&seg, tract)) { + if(TRACT_SEG(&seg, tract)) { Res res; STATISTIC(++ss->segRefCount); STATISTIC(++ss->whiteSegRefCount); @@ -1442,7 +1442,7 @@ Res TraceFix(ScanState ss, Ref *refIO) /* Could move the rank switch here from the class-specific */ /* fix methods. */ res = PoolFix(pool, ss, seg, refIO); - if (res != ResOK) { + if(res != ResOK) { /* Fix protocol (de facto): if Fix fails, ref must be unchanged */ /* Justification for this restriction: * A: it simplifies; @@ -1460,7 +1460,7 @@ Res TraceFix(ScanState ss, Ref *refIO) STATISTIC_STAT ({ Seg seg; - if (TRACT_SEG(&seg, tract)) { + if(TRACT_SEG(&seg, tract)) { ++ss->segRefCount; EVENT_P(TraceFixSeg, seg); } @@ -1496,10 +1496,10 @@ Res TraceFixEmergency(ScanState ss, Ref *refIO) EVENT_PPAU(TraceFix, ss, refIO, ref, ss->rank); TRACT_OF_ADDR(&tract, ss->arena, ref); - if (tract) { - if (TraceSetInter(TractWhite(tract), ss->traces) != TraceSetEMPTY) { + if(tract) { + if(TraceSetInter(TractWhite(tract), ss->traces) != TraceSetEMPTY) { Seg seg; - if (TRACT_SEG(&seg, tract)) { + if(TRACT_SEG(&seg, tract)) { STATISTIC(++ss->segRefCount); STATISTIC(++ss->whiteSegRefCount); EVENT_P(TraceFixSeg, seg); @@ -1513,7 +1513,7 @@ Res TraceFixEmergency(ScanState ss, Ref *refIO) STATISTIC_STAT ({ Seg seg; - if (TRACT_SEG(&seg, tract)) { + if(TRACT_SEG(&seg, tract)) { ++ss->segRefCount; EVENT_P(TraceFixSeg, seg); } @@ -1545,7 +1545,7 @@ static Res traceScanSingleRefRes(TraceSet ts, Rank rank, Arena arena, EVENT_UUPA(TraceScanSingleRef, ts, rank, arena, (Addr)refIO); white = traceSetWhiteUnion(ts, arena); - if (ZoneSetInter(SegSummary(seg), white) == ZoneSetEMPTY) { + if(ZoneSetInter(SegSummary(seg), white) == ZoneSetEMPTY) { return ResOK; } @@ -1586,10 +1586,10 @@ void TraceScanSingleRef(TraceSet ts, Rank rank, Arena arena, AVER(refIO != NULL); res = traceScanSingleRefRes(ts, rank, arena, seg, refIO); - if (res != ResOK) { + if(res != ResOK) { traceSetSignalEmergency(ts, arena); res = traceScanSingleRefRes(ts, rank, arena, seg, refIO); - /* ought to be OK in emergency mode now */ + /* Ought to be OK in emergency mode now. */ } AVER(ResOK == res); @@ -1618,12 +1618,12 @@ Res TraceScanArea(ScanState ss, Addr *base, Addr *limit) TRACE_SCAN_BEGIN(ss) { p = base; loop: - if (p >= limit) goto out; + if(p >= limit) goto out; ref = *p++; - if (!TRACE_FIX1(ss, ref)) + if(!TRACE_FIX1(ss, ref)) goto loop; res = TRACE_FIX2(ss, p-1); - if (res == ResOK) + if(res == ResOK) goto loop; return res; out: @@ -1666,12 +1666,12 @@ Res TraceScanAreaMasked(ScanState ss, Addr *base, Addr *limit, Word mask) TRACE_SCAN_BEGIN(ss) { p = base; loop: - if (p >= limit) goto out; + if(p >= limit) goto out; ref = *p++; - if (((Word)ref & mask) != 0) goto loop; - if (!TRACE_FIX1(ss, ref)) goto loop; + if(((Word)ref & mask) != 0) goto loop; + if(!TRACE_FIX1(ss, ref)) goto loop; res = TRACE_FIX2(ss, p-1); - if (res == ResOK) + if(res == ResOK) goto loop; return res; out: @@ -1699,7 +1699,7 @@ static Res traceCondemnAll(Trace trace) AVERT(Chain, chain); res = ChainCondemnAll(chain, trace); - if (res != ResOK) + if(res != ResOK) goto failBegin; haveWhiteSegs = TRUE; } @@ -1743,7 +1743,7 @@ static Res rootGrey(Root root, void *p) AVERT(Root, root); AVERT(Trace, trace); - if (ZoneSetInter(RootSummary(root), trace->white) != ZoneSetEMPTY) { + if(ZoneSetInter(RootSummary(root), trace->white) != ZoneSetEMPTY) { RootGrey(root, trace); } @@ -1788,7 +1788,7 @@ void TraceStart(Trace trace, double mortality, double finishingTime) /* of segments are scannable. Perhaps we should choose */ /* dynamically which method to use. */ - if (SegFirst(&seg, arena)) { + if(SegFirst(&seg, arena)) { Addr base; do { base = SegBase(seg); @@ -1798,7 +1798,7 @@ void TraceStart(Trace trace, double mortality, double finishingTime) /* A segment can only be grey if it contains some references. */ /* This is indicated by the rankSet begin non-empty. Such */ /* segments may only belong to scannable pools. */ - if (SegRankSet(seg) != RankSetEMPTY) { + if(SegRankSet(seg) != RankSetEMPTY) { /* Segments with ranks may only belong to scannable pools. */ AVER((SegPool(seg)->class->attr & AttrSCAN) != 0); @@ -1806,17 +1806,17 @@ void TraceStart(Trace trace, double mortality, double finishingTime) /* to the white set. This is done by seeing if the summary */ /* of references in the segment intersects with the */ /* approximation to the white set. */ - if (ZoneSetInter(SegSummary(seg), trace->white) != ZoneSetEMPTY) { + if(ZoneSetInter(SegSummary(seg), trace->white) != ZoneSetEMPTY) { /* Note: can a white seg get greyed as well? At this point */ /* we still assume it may. (This assumption runs out in */ /* PoolTrivGrey). */ PoolGrey(SegPool(seg), trace, seg); - if (TraceSetIsMember(SegGrey(seg), trace)) { + if(TraceSetIsMember(SegGrey(seg), trace)) { trace->foundation += size; } } - if ((SegPool(seg)->class->attr & AttrGC) + if((SegPool(seg)->class->attr & AttrGC) && !TraceSetIsMember(SegWhite(seg), trace)) { trace->notCondemned += size; } @@ -1835,11 +1835,11 @@ void TraceStart(Trace trace, double mortality, double finishingTime) double nPolls = finishingTime / ArenaPollALLOCTIME; /* There must be at least one poll. */ - if (nPolls < 1.0) + if(nPolls < 1.0) nPolls = 1.0; /* We use casting to long to truncate nPolls down to the nearest */ /* integer, so try to make sure it fits. */ - if (nPolls >= (double)LONG_MAX) + if(nPolls >= (double)LONG_MAX) nPolls = (double)LONG_MAX; /* rate equals scanning work per number of polls available */ trace->rate = (trace->foundation + sSurvivors) / (long)nPolls + 1; @@ -1920,11 +1920,11 @@ static Res traceStartCollectAll(Trace *traceReturn, Arena arena, int why) res = TraceCreate(&trace, arena, why); AVER(res == ResOK); /* succeeds because no other trace is busy */ res = traceCondemnAll(trace); - if (res != ResOK) /* should try some other trace, really @@@@ */ + if(res != ResOK) /* should try some other trace, really @@@@ */ goto failCondemn; finishingTime = ArenaAvail(arena) - trace->condemned * (1.0 - TraceTopGenMortality); - if (finishingTime < 0) { + if(finishingTime < 0) { /* Run out of time, should really try a smaller collection. @@@@ */ finishingTime = 0.0; } @@ -1951,7 +1951,7 @@ Size TracePoll(Globals globals) arena = GlobalsArena(globals); scannedSize = (Size)0; - if (arena->busyTraces == TraceSetEMPTY) { + if(arena->busyTraces == TraceSetEMPTY) { /* If no traces are going on, see if we need to start one. */ Size sFoundation, sCondemned, sSurvivors, sConsTrace; double tTracePerScan; /* tTrace/cScan */ @@ -1970,9 +1970,9 @@ Size TracePoll(Globals globals) sConsTrace = (Size)(sSurvivors + tTracePerScan * TraceWorkFactor); dynamicDeferral = (double)ArenaAvail(arena) - (double)sConsTrace; - if (dynamicDeferral < 0.0) { /* start full GC */ + if(dynamicDeferral < 0.0) { /* start full GC */ res = traceStartCollectAll(&trace, arena, TraceStartWhyDYNAMICCRITERION); - if (res != ResOK) + if(res != ResOK) goto failStart; scannedSize = traceWorkClock(trace); } else { /* Find the nursery most over its capacity. */ @@ -1986,19 +1986,19 @@ Size TracePoll(Globals globals) AVERT(Chain, chain); time = ChainDeferral(chain); - if (time < firstTime) { + if(time < firstTime) { firstTime = time; firstChain = chain; } } /* If one was found, start collection on that chain. */ - if (firstTime < 0) { + if(firstTime < 0) { double mortality; res = TraceCreate(&trace, arena, TraceStartWhyCHAIN_GEN0CAP); AVER(res == ResOK); res = ChainCondemnAuto(&mortality, firstChain, trace); - if (res != ResOK) /* should try some other trace, really @@@@ */ + if(res != ResOK) /* should try some other trace, really @@@@ */ goto failCondemn; trace->chain = firstChain; ChainStartGC(firstChain, trace); @@ -2064,7 +2064,7 @@ void ArenaPark(Globals globals) globals->clamped = TRUE; - while (arena->busyTraces != TraceSetEMPTY) { + while(arena->busyTraces != TraceSetEMPTY) { /* Poll active traces to make progress. */ TRACE_SET_ITER(ti, trace, arena->busyTraces, arena) traceQuantum(trace); @@ -2241,7 +2241,7 @@ Res ArenaStartCollect(Globals globals, int why) ArenaPark(globals); res = traceStartCollectAll(&trace, arena, why); - if (res != ResOK) + if(res != ResOK) goto failStart; ArenaRelease(globals); return ResOK; @@ -2259,7 +2259,7 @@ Res ArenaCollect(Globals globals, int why) AVERT(Globals, globals); res = ArenaStartCollect(globals, why); - if (res != ResOK) + if(res != ResOK) return res; ArenaPark(globals);