aboutsummaryrefslogtreecommitdiffstats
path: root/mps/code
diff options
context:
space:
mode:
authorRichard Kistruck2009-08-20 17:44:16 +0100
committerRichard Kistruck2009-08-20 17:44:16 +0100
commitbf80a3a11def6ba68d8f248b389ba84e4e32ced3 (patch)
tree3c38bcbc23f517245cecee1b33ffd773def51ddd /mps/code
parent1c3940b99a3cb7be36324c0c0d9915670171c731 (diff)
downloademacs-bf80a3a11def6ba68d8f248b389ba84e4e32ced3.tar.gz
emacs-bf80a3a11def6ba68d8f248b389ba84e4e32ced3.zip
Mps br/padding: new pooltraceendmethod: do end-of-trace work
Tracer calls PoolTraceEnd() when the trace is TraceFINISHED. AbstractPoolClass uses PoolTrivTraceEnd -- a NOOP. [mpm.h, mpmst.h, mpmtypes.h, pool.c, poolabs.c] AMC overrides with AMCTraceEnd, to emit diagnostic on how well the trace went! [poolamc.c] Copied from Perforce Change: 168478 ServerID: perforce.ravenbrook.com
Diffstat (limited to 'mps/code')
-rw-r--r--mps/code/diag.c1
-rw-r--r--mps/code/mpm.h2
-rw-r--r--mps/code/mpmst.h1
-rw-r--r--mps/code/mpmtypes.h1
-rw-r--r--mps/code/pool.c17
-rw-r--r--mps/code/poolabs.c8
-rw-r--r--mps/code/poolamc.c19
-rw-r--r--mps/code/trace.c8
8 files changed, 57 insertions, 0 deletions
diff --git a/mps/code/diag.c b/mps/code/diag.c
index 45d473ddf09..9ee4deb0ada 100644
--- a/mps/code/diag.c
+++ b/mps/code/diag.c
@@ -46,6 +46,7 @@ struct RuleStruct RulesGlobal[] = {
46 { "+", "TraceStart", "*", " PoolSum-" }, 46 { "+", "TraceStart", "*", " PoolSum-" },
47 { "+", "TraceStart", "*", "MutatorSize " }, /* fillMutatorSize, emptyMutatorSize, fillInternalSize, emptyInternalSize */ 47 { "+", "TraceStart", "*", "MutatorSize " }, /* fillMutatorSize, emptyMutatorSize, fillInternalSize, emptyInternalSize */
48 { "+", "TraceStart", "*", " segs" }, /* amcGen 0..N segs 3, totalSize 49152, newSize 0 */ 48 { "+", "TraceStart", "*", " segs" }, /* amcGen 0..N segs 3, totalSize 49152, newSize 0 */
49 { "+", "AMCTraceEnd", "*", "*" },
49 /* ----v---- always on please (RHSK) ----v---- */ 50 /* ----v---- always on please (RHSK) ----v---- */
50 { "+", "traceSetSignalEmergency", "*", "*" }, 51 { "+", "traceSetSignalEmergency", "*", "*" },
51 { NULL, "", "", "" } 52 { NULL, "", "", "" }
diff --git a/mps/code/mpm.h b/mps/code/mpm.h
index 1ca74e6ffd7..b4189afadcd 100644
--- a/mps/code/mpm.h
+++ b/mps/code/mpm.h
@@ -211,6 +211,7 @@ extern Res (PoolFix)(Pool pool, ScanState ss, Seg seg, Addr *refIO);
211 ((*(pool)->fix)(pool, ss, seg, refIO)) 211 ((*(pool)->fix)(pool, ss, seg, refIO))
212extern void PoolFixEmergency(Pool pool, ScanState ss, Seg seg, Addr *refIO); 212extern void PoolFixEmergency(Pool pool, ScanState ss, Seg seg, Addr *refIO);
213extern void PoolReclaim(Pool pool, Trace trace, Seg seg); 213extern void PoolReclaim(Pool pool, Trace trace, Seg seg);
214extern void PoolTraceEnd(Pool pool, Trace trace);
214extern void PoolWalk(Pool pool, Seg seg, FormattedObjectsStepMethod f, 215extern void PoolWalk(Pool pool, Seg seg, FormattedObjectsStepMethod f,
215 void *v, unsigned long s); 216 void *v, unsigned long s);
216extern void PoolFreeWalk(Pool pool, FreeBlockStepMethod f, void *p); 217extern void PoolFreeWalk(Pool pool, FreeBlockStepMethod f, void *p);
@@ -250,6 +251,7 @@ extern void PoolTrivBlacken(Pool pool, TraceSet traceSet, Seg seg);
250extern Res PoolNoScan(Bool *totalReturn, ScanState ss, Pool pool, Seg seg); 251extern Res PoolNoScan(Bool *totalReturn, ScanState ss, Pool pool, Seg seg);
251extern Res PoolNoFix(Pool pool, ScanState ss, Seg seg, Ref *refIO); 252extern Res PoolNoFix(Pool pool, ScanState ss, Seg seg, Ref *refIO);
252extern void PoolNoReclaim(Pool pool, Trace trace, Seg seg); 253extern void PoolNoReclaim(Pool pool, Trace trace, Seg seg);
254extern void PoolTrivTraceEnd(Pool pool, Trace trace);
253extern void PoolNoRampBegin(Pool pool, Buffer buf, Bool collectAll); 255extern void PoolNoRampBegin(Pool pool, Buffer buf, Bool collectAll);
254extern void PoolTrivRampBegin(Pool pool, Buffer buf, Bool collectAll); 256extern void PoolTrivRampBegin(Pool pool, Buffer buf, Bool collectAll);
255extern void PoolNoRampEnd(Pool pool, Buffer buf); 257extern void PoolNoRampEnd(Pool pool, Buffer buf);
diff --git a/mps/code/mpmst.h b/mps/code/mpmst.h
index e0a76f9bf0c..eeafab47fdc 100644
--- a/mps/code/mpmst.h
+++ b/mps/code/mpmst.h
@@ -66,6 +66,7 @@ typedef struct PoolClassStruct {
66 PoolFixMethod fix; /* referent reachable during tracing */ 66 PoolFixMethod fix; /* referent reachable during tracing */
67 PoolFixEmergencyMethod fixEmergency; /* as fix, no failure allowed */ 67 PoolFixEmergencyMethod fixEmergency; /* as fix, no failure allowed */
68 PoolReclaimMethod reclaim; /* reclaim dead objects after tracing */ 68 PoolReclaimMethod reclaim; /* reclaim dead objects after tracing */
69 PoolTraceEndMethod traceEnd; /* do end-of-trace work */
69 PoolRampBeginMethod rampBegin;/* begin a ramp pattern */ 70 PoolRampBeginMethod rampBegin;/* begin a ramp pattern */
70 PoolRampEndMethod rampEnd; /* end a ramp pattern */ 71 PoolRampEndMethod rampEnd; /* end a ramp pattern */
71 PoolFramePushMethod framePush; /* push an allocation frame */ 72 PoolFramePushMethod framePush; /* push an allocation frame */
diff --git a/mps/code/mpmtypes.h b/mps/code/mpmtypes.h
index bd232110349..fd27f8c2a80 100644
--- a/mps/code/mpmtypes.h
+++ b/mps/code/mpmtypes.h
@@ -198,6 +198,7 @@ typedef Res (*PoolFixMethod)(Pool pool, ScanState ss, Seg seg,
198typedef Res (*PoolFixEmergencyMethod)(Pool pool, ScanState ss, 198typedef Res (*PoolFixEmergencyMethod)(Pool pool, ScanState ss,
199 Seg seg, Ref *refIO); 199 Seg seg, Ref *refIO);
200typedef void (*PoolReclaimMethod)(Pool pool, Trace trace, Seg seg); 200typedef void (*PoolReclaimMethod)(Pool pool, Trace trace, Seg seg);
201typedef void (*PoolTraceEndMethod)(Pool pool, Trace trace);
201typedef void (*PoolRampBeginMethod)(Pool pool, Buffer buf, Bool collectAll); 202typedef void (*PoolRampBeginMethod)(Pool pool, Buffer buf, Bool collectAll);
202typedef void (*PoolRampEndMethod)(Pool pool, Buffer buf); 203typedef void (*PoolRampEndMethod)(Pool pool, Buffer buf);
203typedef Res (*PoolFramePushMethod)(AllocFrame *frameReturn, 204typedef Res (*PoolFramePushMethod)(AllocFrame *frameReturn,
diff --git a/mps/code/pool.c b/mps/code/pool.c
index 05045b3f309..e92106128c3 100644
--- a/mps/code/pool.c
+++ b/mps/code/pool.c
@@ -461,6 +461,23 @@ void PoolReclaim(Pool pool, Trace trace, Seg seg)
461} 461}
462 462
463 463
464/* PoolTraceEnd -- do end-of-trace work
465 *
466 * This method is for a pool class to do final end-of-trace work,
467 * after all reclaiming is complete. For example, emitting
468 * diagnostics about what happened during the trace.
469 */
470
471void PoolTraceEnd(Pool pool, Trace trace)
472{
473 AVERT(Pool, pool);
474 AVERT(Trace, trace);
475 AVER(pool->arena == trace->arena);
476
477 (*pool->class->traceEnd)(pool, trace);
478}
479
480
464/* PoolWalk -- walk objects in this segment */ 481/* PoolWalk -- walk objects in this segment */
465 482
466void PoolWalk(Pool pool, Seg seg, FormattedObjectsStepMethod f, 483void PoolWalk(Pool pool, Seg seg, FormattedObjectsStepMethod f,
diff --git a/mps/code/poolabs.c b/mps/code/poolabs.c
index 3e52dc63c14..324975cb7c0 100644
--- a/mps/code/poolabs.c
+++ b/mps/code/poolabs.c
@@ -136,6 +136,7 @@ DEFINE_CLASS(AbstractPoolClass, class)
136 class->fix = PoolNoFix; 136 class->fix = PoolNoFix;
137 class->fixEmergency = PoolNoFix; 137 class->fixEmergency = PoolNoFix;
138 class->reclaim = PoolNoReclaim; 138 class->reclaim = PoolNoReclaim;
139 class->traceEnd = PoolTrivTraceEnd;
139 class->rampBegin = PoolNoRampBegin; 140 class->rampBegin = PoolNoRampBegin;
140 class->rampEnd = PoolNoRampEnd; 141 class->rampEnd = PoolNoRampEnd;
141 class->framePush = PoolNoFramePush; 142 class->framePush = PoolNoFramePush;
@@ -529,6 +530,13 @@ void PoolNoReclaim(Pool pool, Trace trace, Seg seg)
529 NOTREACHED; 530 NOTREACHED;
530} 531}
531 532
533void PoolTrivTraceEnd(Pool pool, Trace trace)
534{
535 AVERT(Pool, pool);
536 AVERT(Trace, trace);
537 NOOP;
538}
539
532 540
533void PoolNoRampBegin(Pool pool, Buffer buf, Bool collectAll) 541void PoolNoRampBegin(Pool pool, Buffer buf, Bool collectAll)
534{ 542{
diff --git a/mps/code/poolamc.c b/mps/code/poolamc.c
index 02984e08c12..6c3a3da4d99 100644
--- a/mps/code/poolamc.c
+++ b/mps/code/poolamc.c
@@ -2232,6 +2232,24 @@ static void AMCReclaim(Pool pool, Trace trace, Seg seg)
2232} 2232}
2233 2233
2234 2234
2235/* AMCTraceEnd -- emit end-of-trace diagnostics
2236 *
2237 */
2238static void AMCTraceEnd(Pool pool, Trace trace)
2239{
2240 AMC amc;
2241
2242 AVERT(Pool, pool);
2243 amc = Pool2AMC(pool);
2244 AVERT(AMC, amc);
2245 AVERT(Trace, trace);
2246
2247 DIAG_SINGLEF(( "AMCTraceEnd",
2248 " pool: $P\n", pool,
2249 NULL ));
2250}
2251
2252
2235/* AMCWalk -- Apply function to (black) objects in segment */ 2253/* AMCWalk -- Apply function to (black) objects in segment */
2236 2254
2237static void AMCWalk(Pool pool, Seg seg, FormattedObjectsStepMethod f, 2255static void AMCWalk(Pool pool, Seg seg, FormattedObjectsStepMethod f,
@@ -2424,6 +2442,7 @@ DEFINE_POOL_CLASS(AMCPoolClass, this)
2424 this->fix = AMCFix; 2442 this->fix = AMCFix;
2425 this->fixEmergency = AMCFixEmergency; 2443 this->fixEmergency = AMCFixEmergency;
2426 this->reclaim = AMCReclaim; 2444 this->reclaim = AMCReclaim;
2445 this->traceEnd = AMCTraceEnd;
2427 this->rampBegin = AMCRampBegin; 2446 this->rampBegin = AMCRampBegin;
2428 this->rampEnd = AMCRampEnd; 2447 this->rampEnd = AMCRampEnd;
2429 this->walk = AMCWalk; 2448 this->walk = AMCWalk;
diff --git a/mps/code/trace.c b/mps/code/trace.c
index 1082eaefe78..ff13b6180a9 100644
--- a/mps/code/trace.c
+++ b/mps/code/trace.c
@@ -770,6 +770,7 @@ static void traceReclaim(Trace trace)
770{ 770{
771 Arena arena; 771 Arena arena;
772 Seg seg; 772 Seg seg;
773 Ring node, nextNode;
773 774
774 AVER(trace->state == TraceRECLAIM); 775 AVER(trace->state == TraceRECLAIM);
775 776
@@ -805,6 +806,13 @@ static void traceReclaim(Trace trace)
805 } 806 }
806 807
807 trace->state = TraceFINISHED; 808 trace->state = TraceFINISHED;
809
810 /* Call each pool's TraceEnd method -- do end-of-trace work */
811 RING_FOR(node, &ArenaGlobals(arena)->poolRing, nextNode) {
812 Pool pool = RING_ELT(Pool, arenaRing, node);
813 PoolTraceEnd(pool, trace);
814 }
815
808 TracePostMessage(trace); /* trace end */ 816 TracePostMessage(trace); /* trace end */
809 /* Immediately pre-allocate messages for next time; failure is okay */ 817 /* Immediately pre-allocate messages for next time; failure is okay */
810 (void)TraceIdMessagesCreate(arena, trace->ti); 818 (void)TraceIdMessagesCreate(arena, trace->ti);