aboutsummaryrefslogtreecommitdiffstats
path: root/mps/code/trace.c
diff options
context:
space:
mode:
authorRichard Brooksby2012-09-07 12:58:57 +0100
committerRichard Brooksby2012-09-07 12:58:57 +0100
commit78d5f049f0e60bd0c903bc331c253f681d082cea (patch)
tree2313698d481513796220f50377bdd911fff16bad /mps/code/trace.c
parente17fee98ea221678f40bae915dd32c91ccc71922 (diff)
downloademacs-78d5f049f0e60bd0c903bc331c253f681d082cea.tar.gz
emacs-78d5f049f0e60bd0c903bc331c253f681d082cea.zip
Eliminating type puns on scan states, location dependencies, and allocation points through the mps interface.
Now that we're recommending inlining with client code and optimising with -O2 or -O3, we can't afford any bug introduced by the strict aliasing rule. Copied from Perforce Change: 179322 ServerID: perforce.ravenbrook.com
Diffstat (limited to 'mps/code/trace.c')
-rw-r--r--mps/code/trace.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/mps/code/trace.c b/mps/code/trace.c
index 9771797337d..eb497cd2314 100644
--- a/mps/code/trace.c
+++ b/mps/code/trace.c
@@ -40,12 +40,12 @@ Bool ScanStateCheck(ScanState ss)
40 CHECKS(ScanState, ss); 40 CHECKS(ScanState, ss);
41 CHECKL(FUNCHECK(ss->fix)); 41 CHECKL(FUNCHECK(ss->fix));
42 /* Can't check ss->fixClosure. */ 42 /* Can't check ss->fixClosure. */
43 CHECKL(ss->zoneShift == ss->arena->zoneShift); 43 CHECKL(ScanStateZoneShift(ss) == ss->arena->zoneShift);
44 white = ZoneSetEMPTY; 44 white = ZoneSetEMPTY;
45 TRACE_SET_ITER(ti, trace, ss->traces, ss->arena) 45 TRACE_SET_ITER(ti, trace, ss->traces, ss->arena)
46 white = ZoneSetUnion(white, ss->arena->trace[ti].white); 46 white = ZoneSetUnion(white, ss->arena->trace[ti].white);
47 TRACE_SET_ITER_END(ti, trace, ss->traces, ss->arena); 47 TRACE_SET_ITER_END(ti, trace, ss->traces, ss->arena);
48 CHECKL(ss->white == white); 48 CHECKL(ScanStateWhite(ss) == white);
49 CHECKU(Arena, ss->arena); 49 CHECKU(Arena, ss->arena);
50 /* Summaries could be anything, and can't be checked. */ 50 /* Summaries could be anything, and can't be checked. */
51 CHECKL(TraceSetCheck(ss->traces)); 51 CHECKL(TraceSetCheck(ss->traces));
@@ -94,12 +94,12 @@ void ScanStateInit(ScanState ss, TraceSet ts, Arena arena,
94 94
95 ss->rank = rank; 95 ss->rank = rank;
96 ss->traces = ts; 96 ss->traces = ts;
97 ss->zoneShift = arena->zoneShift; 97 ScanStateSetZoneShift(ss, arena->zoneShift);
98 ss->unfixedSummary = RefSetEMPTY; 98 ScanStateSetUnfixedSummary(ss, RefSetEMPTY);
99 ss->fixedSummary = RefSetEMPTY; 99 ss->fixedSummary = RefSetEMPTY;
100 ss->arena = arena; 100 ss->arena = arena;
101 ss->wasMarked = TRUE; 101 ss->wasMarked = TRUE;
102 ss->white = white; 102 ScanStateSetWhite(ss, white);
103 STATISTIC(ss->fixRefCount = (Count)0); 103 STATISTIC(ss->fixRefCount = (Count)0);
104 STATISTIC(ss->segRefCount = (Count)0); 104 STATISTIC(ss->segRefCount = (Count)0);
105 STATISTIC(ss->whiteSegRefCount = (Count)0); 105 STATISTIC(ss->whiteSegRefCount = (Count)0);
@@ -1108,7 +1108,7 @@ void ScanStateSetSummary(ScanState ss, RefSet summary)
1108 AVERT(ScanState, ss); 1108 AVERT(ScanState, ss);
1109 /* Can't check summary, as it can be anything. */ 1109 /* Can't check summary, as it can be anything. */
1110 1110
1111 ss->unfixedSummary = RefSetEMPTY; 1111 ScanStateSetUnfixedSummary(ss, RefSetEMPTY);
1112 ss->fixedSummary = summary; 1112 ss->fixedSummary = summary;
1113 AVER(ScanStateSummary(ss) == summary); 1113 AVER(ScanStateSummary(ss) == summary);
1114} 1114}
@@ -1127,7 +1127,8 @@ RefSet ScanStateSummary(ScanState ss)
1127 AVERT(ScanState, ss); 1127 AVERT(ScanState, ss);
1128 1128
1129 return RefSetUnion(ss->fixedSummary, 1129 return RefSetUnion(ss->fixedSummary,
1130 RefSetDiff(ss->unfixedSummary, ss->white)); 1130 RefSetDiff(ScanStateUnfixedSummary(ss),
1131 ScanStateWhite(ss)));
1131} 1132}
1132 1133
1133 1134
@@ -1156,16 +1157,17 @@ static Res traceScanSegRes(TraceSet ts, Rank rank, Arena arena, Seg seg)
1156 /* Setup result code to return later. */ 1157 /* Setup result code to return later. */
1157 res = ResOK; 1158 res = ResOK;
1158 } else { /* scan it */ 1159 } else { /* scan it */
1159 ScanStateStruct ss; 1160 ScanStateStruct ssStruct;
1160 ScanStateInit(&ss, ts, arena, rank, white); 1161 ScanState ss = &ssStruct;
1162 ScanStateInit(ss, ts, arena, rank, white);
1161 1163
1162 /* Expose the segment to make sure we can scan it. */ 1164 /* Expose the segment to make sure we can scan it. */
1163 ShieldExpose(arena, seg); 1165 ShieldExpose(arena, seg);
1164 res = PoolScan(&wasTotal, &ss, SegPool(seg), seg); 1166 res = PoolScan(&wasTotal, ss, SegPool(seg), seg);
1165 /* Cover, regardless of result */ 1167 /* Cover, regardless of result */
1166 ShieldCover(arena, seg); 1168 ShieldCover(arena, seg);
1167 1169
1168 traceSetUpdateCounts(ts, arena, &ss, traceAccountingPhaseSegScan); 1170 traceSetUpdateCounts(ts, arena, ss, traceAccountingPhaseSegScan);
1169 /* Count segments scanned pointlessly */ 1171 /* Count segments scanned pointlessly */
1170 STATISTIC_STAT 1172 STATISTIC_STAT
1171 ({ 1173 ({
@@ -1186,19 +1188,19 @@ static Res traceScanSegRes(TraceSet ts, Rank rank, Arena arena, Seg seg)
1186 /* .verify.segsummary: were the seg contents, as found by this 1188 /* .verify.segsummary: were the seg contents, as found by this
1187 * scan, consistent with the recorded SegSummary? 1189 * scan, consistent with the recorded SegSummary?
1188 */ 1190 */
1189 AVER(RefSetSub(ss.unfixedSummary, SegSummary(seg))); 1191 AVER(RefSetSub(ScanStateUnfixedSummary(ss), SegSummary(seg)));
1190 1192
1191 if(res != ResOK || !wasTotal) { 1193 if(res != ResOK || !wasTotal) {
1192 /* scan was partial, so... */ 1194 /* scan was partial, so... */
1193 /* scanned summary should be ORed into segment summary. */ 1195 /* scanned summary should be ORed into segment summary. */
1194 SegSetSummary(seg, RefSetUnion(SegSummary(seg), ScanStateSummary(&ss))); 1196 SegSetSummary(seg, RefSetUnion(SegSummary(seg), ScanStateSummary(ss)));
1195 } else { 1197 } else {
1196 /* all objects on segment have been scanned, so... */ 1198 /* all objects on segment have been scanned, so... */
1197 /* scanned summary should replace the segment summary. */ 1199 /* scanned summary should replace the segment summary. */
1198 SegSetSummary(seg, ScanStateSummary(&ss)); 1200 SegSetSummary(seg, ScanStateSummary(ss));
1199 } 1201 }
1200 1202
1201 ScanStateFinish(&ss); 1203 ScanStateFinish(ss);
1202 } 1204 }
1203 1205
1204 if(res == ResOK) { 1206 if(res == ResOK) {
@@ -1314,7 +1316,7 @@ static Res TraceFix2(ScanState ss, Ref *refIO)
1314 ref = *refIO; 1316 ref = *refIO;
1315 1317
1316 /* The zone test should already have been passed by MPS_FIX1 in mps.h. */ 1318 /* The zone test should already have been passed by MPS_FIX1 in mps.h. */
1317 AVER_CRITICAL(ZoneSetInter(ss->white, 1319 AVER_CRITICAL(ZoneSetInter(ScanStateWhite(ss),
1318 ZoneSetAdd(ss->arena, ZoneSetEMPTY, ref)) != 1320 ZoneSetAdd(ss->arena, ZoneSetEMPTY, ref)) !=
1319 ZoneSetEMPTY); 1321 ZoneSetEMPTY);
1320 1322
@@ -1388,7 +1390,7 @@ static Res TraceFix2(ScanState ss, Ref *refIO)
1388 * function is in trace.c and not mpsi.c. 1390 * function is in trace.c and not mpsi.c.
1389 */ 1391 */
1390 1392
1391mps_res_t mps_fix2(mps_ss_t mps_ss, mps_addr_t *mps_ref_io) 1393mps_res_t _mps_fix2(mps_ss_t mps_ss, mps_addr_t *mps_ref_io)
1392{ 1394{
1393 ScanState ss = (ScanState)mps_ss; 1395 ScanState ss = (ScanState)mps_ss;
1394 Ref *refIO = (Ref *)mps_ref_io; 1396 Ref *refIO = (Ref *)mps_ref_io;