From 7739f79926304c17eb6e06a35063ea2a8a06acff Mon Sep 17 00:00:00 2001
From: David Jones
Date: Fri, 20 Jul 2007 11:09:49 +0100
Subject: Mps: why code in diagnostic, "correct" newsize diagnostics.
Copied from Perforce
Change: 162956
ServerID: perforce.ravenbrook.com
---
mps/code/chain.h | 6 ++++++
mps/code/mpmst.h | 1 +
mps/code/trace.c | 42 +++++++++++++++++++++++++++++++++++++-----
3 files changed, 44 insertions(+), 5 deletions(-)
(limited to 'mps/code')
diff --git a/mps/code/chain.h b/mps/code/chain.h
index d37a46ccde4..785c25e2349 100644
--- a/mps/code/chain.h
+++ b/mps/code/chain.h
@@ -51,6 +51,12 @@ typedef struct PoolGenStruct {
RingStruct genRing;
Size totalSize; /* total size of segs in gen in this pool */
Size newSize; /* size allocated since last GC */
+ /* newSize when TraceCreate is called. This is for diagnostic */
+ /* purposes only. It's used in a DIAG message emitted in TraceStart; */
+ /* at that time, newSize has already been diminished by Whiten so we */
+ /* can't use that value. This will not work well with multiple */
+ /* traces. */
+ Size newSizeAtCreate;
} PoolGenStruct;
diff --git a/mps/code/mpmst.h b/mps/code/mpmst.h
index 35ff8ac6d9b..739c95a449d 100644
--- a/mps/code/mpmst.h
+++ b/mps/code/mpmst.h
@@ -511,6 +511,7 @@ typedef struct TraceStruct {
Sig sig; /* */
TraceId ti; /* index into TraceSets */
Arena arena; /* owning arena */
+ int why; /* why the trace began */
ZoneSet white; /* zones in the white set */
ZoneSet mayMove; /* zones containing possibly moving objs */
TraceState state; /* current state of trace */
diff --git a/mps/code/trace.c b/mps/code/trace.c
index 9e1dd3a56c2..aaa730b325f 100644
--- a/mps/code/trace.c
+++ b/mps/code/trace.c
@@ -836,6 +836,33 @@ static void traceFlip(Trace trace)
return;
}
+/* traceCopySizes -- preserve size information for later use
+ *
+ * A PoolGen's newSize is important information that we want to emit in
+ * a diagnostic message at TraceStart. In order to do that we must copy
+ * the information before Whiten changes it. This function does that.
+ */
+
+static void traceCopySizes(Trace trace)
+{
+ Ring node, nextNode;
+ int i;
+ Arena arena = trace->arena;
+
+ RING_FOR(node, &arena->chainRing, nextNode) {
+ Chain chain = RING_ELT(Chain, chainRing, node);
+
+ for(i = 0; i < chain->genCount; ++i) {
+ Ring n, nn;
+ GenDesc desc = &chain->gens[i];
+ RING_FOR(n, &desc->locusRing, nn) {
+ PoolGen gen = RING_ELT(PoolGen, genRing, n);
+ gen->newSizeAtCreate = gen->newSize;
+ }
+ }
+ }
+ return;
+}
/* TraceCreate -- create a Trace object
*
@@ -871,6 +898,10 @@ found:
AVER(trace->sig == SigInvalid); /* */
trace->arena = arena;
+ trace->why = why;
+ TraceStartMessageInit(arena, &trace->startMessage);
+ traceStartWhyToString(trace->startMessage.why,
+ sizeof trace->startMessage.why, why);
trace->white = ZoneSetEMPTY;
trace->mayMove = ZoneSetEMPTY;
trace->ti = ti;
@@ -906,9 +937,6 @@ found:
trace->preservedInPlaceSize = (Size)0; /* see .message.data */
STATISTIC(trace->reclaimCount = (Count)0);
STATISTIC(trace->reclaimSize = (Size)0);
- TraceStartMessageInit(arena, &trace->startMessage);
- traceStartWhyToString(trace->startMessage.why,
- sizeof trace->startMessage.why, why);
trace->sig = TraceSig;
arena->busyTraces = TraceSetAdd(arena->busyTraces, trace);
AVERT(Trace, trace);
@@ -919,6 +947,8 @@ found:
/* @@@@ This is a short-term fix for request.dylan.160098. */
ShieldSuspend(arena);
+ traceCopySizes(trace);
+
*traceReturn = trace;
return ResOK;
}
@@ -1825,7 +1855,8 @@ void TraceStart(Trace trace, double mortality, double finishingTime)
}
DIAG_WRITEF(( DIAG_STREAM,
- "MPS: TraceStart\n",
+ "MPS: TraceStart, because code $U: $S\n",
+ trace->why, trace->startMessage.why,
NULL ));
{ /* @@ */
/* Iterate over all chains, all GenDescs within a chain, and all */
@@ -1850,7 +1881,8 @@ void TraceStart(Trace trace, double mortality, double finishingTime)
PoolGen gen = RING_ELT(PoolGen, genRing, n);
DIAG_WRITEF(( DIAG_STREAM,
"MPS: PoolGen $U", gen->nr,
- " totalSize $U newSize $U\n", gen->totalSize, gen->newSize,
+ " totalSize $U", gen->totalSize,
+ " newSize $U\n", gen->newSizeAtCreate,
NULL ));
}
}
--
cgit v1.2.1