aboutsummaryrefslogtreecommitdiffstats
path: root/mps/code/trace.c
diff options
context:
space:
mode:
authorRichard Brooksby2012-09-07 23:48:14 +0100
committerRichard Brooksby2012-09-07 23:48:14 +0100
commit5a604a2f5197e7c769638fadb98aa41d88faef7f (patch)
tree8ba711da58dfd437f2cac5499dc01c31c07b8197 /mps/code/trace.c
parent6c887280e43265b347cdd9056c86271ad81e8c2a (diff)
downloademacs-5a604a2f5197e7c769638fadb98aa41d88faef7f.tar.gz
emacs-5a604a2f5197e7c769638fadb98aa41d88faef7f.zip
Fixing bugs introduced by type puns passed through scanning methods, discovered by offsetting mps_ss_s from the beginning of scanstatestruct.
Adding a pseudo-target "find-puns" which, on FreeBSD mostly, prints useful warnings about strict aliasing rule violations. Fixing more strict aliasing rule violations found by the above. Copied from Perforce Change: 179358 ServerID: perforce.ravenbrook.com
Diffstat (limited to 'mps/code/trace.c')
-rw-r--r--mps/code/trace.c41
1 files changed, 16 insertions, 25 deletions
diff --git a/mps/code/trace.c b/mps/code/trace.c
index 09fb803b2cc..ffe800e151e 100644
--- a/mps/code/trace.c
+++ b/mps/code/trace.c
@@ -1295,26 +1295,31 @@ void TraceSegAccess(Arena arena, Seg seg, AccessSet mode)
1295} 1295}
1296 1296
1297 1297
1298/* TraceFix2 -- second stage of fixing a reference 1298/* _mps_fix2 (a.k.a. "TraceFix") -- second stage of fixing a reference
1299 * 1299 *
1300 * TraceFix is on the [critical path](../design/critical-path.txt). A 1300 * _mps_fix2 is on the [critical path](../design/critical-path.txt). A
1301 * one-instruction difference in the early parts of this code will have a 1301 * one-instruction difference in the early parts of this code will have a
1302 * significant impact on overall run time. The priority is to eliminate 1302 * significant impact on overall run time. The priority is to eliminate
1303 * irrelevant references early and fast using the colour information stored 1303 * irrelevant references early and fast using the colour information stored
1304 * in the tract table. 1304 * in the tract table.
1305 *
1306 * The name "TraceFix" is pervasive in the MPS and its documents to describe
1307 * this function. Optimisation and strict aliasing rules have meant that we
1308 * need to use the external name for it here.
1305 */ 1309 */
1306 1310
1307static Res TraceFix2(ScanState ss, Ref *refIO) 1311mps_res_t _mps_fix2(mps_ss_t mps_ss, mps_addr_t *mps_ref_io)
1308{ 1312{
1313 ScanState ss = PARENT(ScanStateStruct, ss_s, mps_ss);
1309 Ref ref; 1314 Ref ref;
1310 Tract tract; 1315 Tract tract;
1311 1316
1312 /* Special AVER macros are used on the critical path. */ 1317 /* Special AVER macros are used on the critical path. */
1313 /* See <design/trace/#fix.noaver> */ 1318 /* See <design/trace/#fix.noaver> */
1314 AVERT_CRITICAL(ScanState, ss); 1319 AVERT_CRITICAL(ScanState, ss);
1315 AVER_CRITICAL(refIO != NULL); 1320 AVER_CRITICAL(mps_ref_io != NULL);
1316 1321
1317 ref = *refIO; 1322 ref = (Ref)*mps_ref_io;
1318 1323
1319 /* The zone test should already have been passed by MPS_FIX1 in mps.h. */ 1324 /* The zone test should already have been passed by MPS_FIX1 in mps.h. */
1320 AVER_CRITICAL(ZoneSetInter(ScanStateWhite(ss), 1325 AVER_CRITICAL(ZoneSetInter(ScanStateWhite(ss),
@@ -1322,7 +1327,7 @@ static Res TraceFix2(ScanState ss, Ref *refIO)
1322 ZoneSetEMPTY); 1327 ZoneSetEMPTY);
1323 1328
1324 STATISTIC(++ss->fixRefCount); 1329 STATISTIC(++ss->fixRefCount);
1325 EVENT4(TraceFix, ss, refIO, ref, ss->rank); 1330 EVENT4(TraceFix, ss, mps_ref_io, ref, ss->rank);
1326 1331
1327 TRACT_OF_ADDR(&tract, ss->arena, ref); 1332 TRACT_OF_ADDR(&tract, ss->arena, ref);
1328 if(tract) { 1333 if(tract) {
@@ -1336,7 +1341,7 @@ static Res TraceFix2(ScanState ss, Ref *refIO)
1336 EVENT1(TraceFixSeg, seg); 1341 EVENT1(TraceFixSeg, seg);
1337 EVENT0(TraceFixWhite); 1342 EVENT0(TraceFixWhite);
1338 pool = TractPool(tract); 1343 pool = TractPool(tract);
1339 res = (*ss->fix)(pool, ss, seg, refIO); 1344 res = (*ss->fix)(pool, ss, seg, &ref);
1340 if(res != ResOK) { 1345 if(res != ResOK) {
1341 /* PoolFixEmergency should never fail. */ 1346 /* PoolFixEmergency should never fail. */
1342 AVER_CRITICAL(ss->fix != PoolFixEmergency); 1347 AVER_CRITICAL(ss->fix != PoolFixEmergency);
@@ -1347,7 +1352,7 @@ static Res TraceFix2(ScanState ss, Ref *refIO)
1347 * C: the code (here) already assumes this: it returns without 1352 * C: the code (here) already assumes this: it returns without
1348 * updating ss->fixedSummary. RHSK 2007-03-21. 1353 * updating ss->fixedSummary. RHSK 2007-03-21.
1349 */ 1354 */
1350 AVER(*refIO == ref); 1355 AVER(ref == (Ref)*mps_ref_io);
1351 return res; 1356 return res;
1352 } 1357 }
1353 } else { 1358 } else {
@@ -1378,27 +1383,13 @@ static Res TraceFix2(ScanState ss, Ref *refIO)
1378 } 1383 }
1379 1384
1380 /* See <design/trace/#fix.fixed.all> */ 1385 /* See <design/trace/#fix.fixed.all> */
1381 ss->fixedSummary = RefSetAdd(ss->arena, ss->fixedSummary, *refIO); 1386 ss->fixedSummary = RefSetAdd(ss->arena, ss->fixedSummary, ref);
1382 1387
1388 *mps_ref_io = (mps_addr_t)ref;
1383 return ResOK; 1389 return ResOK;
1384} 1390}
1385 1391
1386 1392
1387/* mps_fix2 -- external interface to TraceFix
1388 *
1389 * We rely on compiler inlining to make this equivalent to TraceFix, because
1390 * the name "TraceFix" is pervasive in the MPS. That's also why this
1391 * function is in trace.c and not mpsi.c.
1392 */
1393
1394mps_res_t _mps_fix2(mps_ss_t mps_ss, mps_addr_t *mps_ref_io)
1395{
1396 ScanState ss = PARENT(ScanStateStruct, ss_s, mps_ss);
1397 Ref *refIO = (Ref *)mps_ref_io;
1398 return TraceFix2(ss, refIO);
1399}
1400
1401
1402/* traceScanSingleRefRes -- scan a single reference, with result code */ 1393/* traceScanSingleRefRes -- scan a single reference, with result code */
1403 1394
1404static Res traceScanSingleRefRes(TraceSet ts, Rank rank, Arena arena, 1395static Res traceScanSingleRefRes(TraceSet ts, Rank rank, Arena arena,