mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-04-21 21:41:40 -07:00
Making describe a method on inst and implementing generic describe for segments.
Copied from Perforce Change: 191601 ServerID: perforce.ravenbrook.com
This commit is contained in:
parent
5b13852f44
commit
9a38cd69db
8 changed files with 31 additions and 25 deletions
|
|
@ -669,7 +669,7 @@ extern void SegSetRankSet(Seg seg, RankSet rankSet);
|
|||
extern void SegSetRankAndSummary(Seg seg, RankSet rankSet, RefSet summary);
|
||||
extern Res SegMerge(Seg *mergedSegReturn, Seg segLo, Seg segHi);
|
||||
extern Res SegSplit(Seg *segLoReturn, Seg *segHiReturn, Seg seg, Addr at);
|
||||
extern Res SegAbsDescribe(Seg seg, mps_lib_FILE *stream, Count depth);
|
||||
extern Res SegAbsDescribe(Inst seg, mps_lib_FILE *stream, Count depth);
|
||||
extern Res SegDescribe(Seg seg, mps_lib_FILE *stream, Count depth);
|
||||
extern void SegSetSummary(Seg seg, RefSet summary);
|
||||
extern Buffer SegBuffer(Seg seg);
|
||||
|
|
|
|||
|
|
@ -218,7 +218,7 @@ typedef struct mps_message_s {
|
|||
#define SegClassSig ((Sig)0x5195E9C7) /* SIGnature SEG CLass */
|
||||
|
||||
typedef struct SegClassStruct {
|
||||
InstClassStruct protocol;
|
||||
InstClassStruct instClassStruct;
|
||||
size_t size; /* size of outer structure */
|
||||
SegInitMethod init; /* initialize the segment */
|
||||
SegFinishMethod finish; /* finish the segment */
|
||||
|
|
@ -229,7 +229,6 @@ typedef struct SegClassStruct {
|
|||
SegSetWhiteMethod setWhite; /* change whiteness of segment */
|
||||
SegSetRankSetMethod setRankSet; /* change rank set of segment */
|
||||
SegSetRankSummaryMethod setRankSummary; /* change rank set & summary */
|
||||
SegDescribeMethod describe; /* describe the contents of the seg */
|
||||
SegMergeMethod merge; /* merge two adjacent segments */
|
||||
SegSplitMethod split; /* split a segment into two */
|
||||
Sig sig; /* .class.end-sig */
|
||||
|
|
|
|||
|
|
@ -162,7 +162,6 @@ typedef void (*SegSetRankSummaryMethod)(Seg seg, RankSet rankSet,
|
|||
typedef void (*SegSetSummaryMethod)(Seg seg, RefSet summary);
|
||||
typedef Buffer (*SegBufferMethod)(Seg seg);
|
||||
typedef void (*SegSetBufferMethod)(Seg seg, Buffer buffer);
|
||||
typedef Res (*SegDescribeMethod)(Seg seg, mps_lib_FILE *stream, Count depth);
|
||||
typedef Res (*SegMergeMethod)(Seg seg, Seg segHi,
|
||||
Addr base, Addr mid, Addr limit);
|
||||
typedef Res (*SegSplitMethod)(Seg seg, Seg segHi,
|
||||
|
|
|
|||
|
|
@ -234,9 +234,10 @@ static void AMCSegSketch(Seg seg, char *pbSketch, size_t cbSketch)
|
|||
*
|
||||
* See <design/poolamc/#seg-describe>.
|
||||
*/
|
||||
static Res AMCSegDescribe(Seg seg, mps_lib_FILE *stream, Count depth)
|
||||
static Res AMCSegDescribe(Inst inst, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
amcSeg amcseg = CouldBeA(amcSeg, seg);
|
||||
amcSeg amcseg = CouldBeA(amcSeg, inst);
|
||||
Seg seg = CouldBeA(Seg, amcseg);
|
||||
Res res;
|
||||
Pool pool;
|
||||
Addr i, p, base, limit, init;
|
||||
|
|
@ -250,7 +251,7 @@ static Res AMCSegDescribe(Seg seg, mps_lib_FILE *stream, Count depth)
|
|||
return ResPARAM;
|
||||
|
||||
/* Describe the superclass fields first via next-method call */
|
||||
res = NextMethod(Seg, amcSeg, describe)(seg, stream, depth);
|
||||
res = NextMethod(Inst, amcSeg, describe)(inst, stream, depth);
|
||||
if (res != ResOK)
|
||||
return res;
|
||||
|
||||
|
|
@ -331,9 +332,9 @@ DEFINE_CLASS(Seg, amcSeg, klass)
|
|||
{
|
||||
INHERIT_CLASS(klass, amcSeg, GCSeg);
|
||||
SegClassMixInNoSplitMerge(klass); /* no support for this (yet) */
|
||||
klass->instClassStruct.describe = AMCSegDescribe;
|
||||
klass->size = sizeof(amcSegStruct);
|
||||
klass->init = AMCSegInit;
|
||||
klass->describe = AMCSegDescribe;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -2003,7 +2004,7 @@ static Res AMCDescribe(Pool pool, mps_lib_FILE *stream, Count depth)
|
|||
/* SegDescribes */
|
||||
RING_FOR(node, &pool->segRing, nextNode) {
|
||||
Seg seg = RING_ELT(Seg, poolRing, node);
|
||||
res = AMCSegDescribe(seg, stream, depth + 2);
|
||||
res = SegDescribe(seg, stream, depth + 2);
|
||||
if(res != ResOK)
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -523,9 +523,10 @@ failCreateTablesLo:
|
|||
} \
|
||||
END
|
||||
|
||||
static Res AMSSegDescribe(Seg seg, mps_lib_FILE *stream, Count depth)
|
||||
static Res AMSSegDescribe(Inst inst, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
AMSSeg amsseg = CouldBeA(AMSSeg, seg);
|
||||
AMSSeg amsseg = CouldBeA(AMSSeg, inst);
|
||||
Seg seg = CouldBeA(Seg, amsseg);
|
||||
Res res;
|
||||
Buffer buffer; /* the segment's buffer, if it has one */
|
||||
Index i;
|
||||
|
|
@ -536,7 +537,7 @@ static Res AMSSegDescribe(Seg seg, mps_lib_FILE *stream, Count depth)
|
|||
return ResPARAM;
|
||||
|
||||
/* Describe the superclass fields first via next-method call */
|
||||
res = NextMethod(Seg, AMSSeg, describe)(seg, stream, depth);
|
||||
res = NextMethod(Inst, AMSSeg, describe)(inst, stream, depth);
|
||||
if (res != ResOK)
|
||||
return res;
|
||||
|
||||
|
|
@ -618,12 +619,12 @@ static Res AMSSegDescribe(Seg seg, mps_lib_FILE *stream, Count depth)
|
|||
DEFINE_CLASS(Seg, AMSSeg, klass)
|
||||
{
|
||||
INHERIT_CLASS(klass, AMSSeg, GCSeg);
|
||||
klass->instClassStruct.describe = AMSSegDescribe;
|
||||
klass->size = sizeof(AMSSegStruct);
|
||||
klass->init = AMSSegInit;
|
||||
klass->finish = AMSSegFinish;
|
||||
klass->merge = AMSSegMerge;
|
||||
klass->split = AMSSegSplit;
|
||||
klass->describe = AMSSegDescribe;
|
||||
AVERT(SegClass, klass);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -47,6 +47,8 @@ static void InstClassInitInternal(InstClass klass)
|
|||
klass->level = 0;
|
||||
klass->display[klass->level] = CLASS_ID(Inst);
|
||||
|
||||
klass->describe = InstDescribe;
|
||||
|
||||
/* We can't call CLASS(InstClass) here because it causes a loop back
|
||||
to here, so we have to tie this knot specially. */
|
||||
klass->instStruct.klass = &CLASS_STATIC(InstClass);
|
||||
|
|
@ -70,6 +72,7 @@ Bool InstClassCheck(InstClass klass)
|
|||
for (i = klass->level + 1; i < ClassDEPTH; ++i) {
|
||||
CHECKL(klass->display[i] == NULL);
|
||||
}
|
||||
CHECKL(FUNCHECK(klass->describe));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -101,7 +104,8 @@ static InstClassStruct invalidClassStruct = {
|
|||
/* .name = */ "Invalid",
|
||||
/* .superclass = */ &invalidClassStruct,
|
||||
/* .level = */ 0,
|
||||
/* .display = */ {(ClassId)&invalidClassStruct}
|
||||
/* .display = */ {(ClassId)&invalidClassStruct},
|
||||
/* .describe = */ NULL
|
||||
};
|
||||
|
||||
void InstFinish(Inst inst)
|
||||
|
|
|
|||
|
|
@ -177,6 +177,7 @@ typedef struct InstStruct {
|
|||
|
||||
typedef const char *ClassName;
|
||||
typedef unsigned char ClassLevel;
|
||||
typedef Res (*DescribeMethod)(Inst inst, mps_lib_FILE *stream, Count depth);
|
||||
#define ClassDEPTH 8 /* maximum depth of class hierarchy */
|
||||
|
||||
#define InstClassSig ((Sig)0x519B1452) /* SIGnature Protocol INST */
|
||||
|
|
@ -188,6 +189,7 @@ typedef struct InstClassStruct {
|
|||
InstClass superclass; /* pointer to direct superclass */
|
||||
ClassLevel level; /* distance from root of class hierarchy */
|
||||
ClassId display[ClassDEPTH]; /* classes at this level and above */
|
||||
DescribeMethod describe; /* write a debugging description */
|
||||
} InstClassStruct;
|
||||
|
||||
enum {ClassLevelNoSuper = -1};
|
||||
|
|
|
|||
|
|
@ -375,8 +375,9 @@ Addr SegBufferScanLimit(Seg seg)
|
|||
|
||||
/* SegDescribe -- describe a segment */
|
||||
|
||||
Res SegAbsDescribe(Seg seg, mps_lib_FILE *stream, Count depth)
|
||||
Res SegAbsDescribe(Inst inst, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
Seg seg = CouldBeA(Seg, inst);
|
||||
Res res;
|
||||
Pool pool;
|
||||
|
||||
|
|
@ -385,7 +386,7 @@ Res SegAbsDescribe(Seg seg, mps_lib_FILE *stream, Count depth)
|
|||
if (stream == NULL)
|
||||
return ResPARAM;
|
||||
|
||||
res = InstDescribe(CouldBeA(Inst, seg), stream, depth);
|
||||
res = NextMethod(Inst, Seg, describe)(inst, stream, depth);
|
||||
if (res != ResOK)
|
||||
return res;
|
||||
|
||||
|
|
@ -425,7 +426,7 @@ Res SegAbsDescribe(Seg seg, mps_lib_FILE *stream, Count depth)
|
|||
|
||||
Res SegDescribe(Seg seg, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
return Method(Seg, seg, describe)(seg, stream, depth);
|
||||
return Method(Inst, seg, describe)(MustBeA(Inst, seg), stream, depth);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1514,9 +1515,9 @@ failSuper:
|
|||
|
||||
/* gcSegDescribe -- GCSeg description method */
|
||||
|
||||
static Res gcSegDescribe(Seg seg, mps_lib_FILE *stream, Count depth)
|
||||
static Res gcSegDescribe(Inst inst, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
GCSeg gcseg = CouldBeA(GCSeg, seg);
|
||||
GCSeg gcseg = CouldBeA(GCSeg, inst);
|
||||
Res res;
|
||||
|
||||
if (!TESTC(GCSeg, gcseg))
|
||||
|
|
@ -1525,7 +1526,7 @@ static Res gcSegDescribe(Seg seg, mps_lib_FILE *stream, Count depth)
|
|||
return ResPARAM;
|
||||
|
||||
/* Describe the superclass fields first via next-method call */
|
||||
res = NextMethod(Seg, GCSeg, describe)(seg, stream, depth);
|
||||
res = NextMethod(Inst, GCSeg, describe)(inst, stream, depth);
|
||||
if (res != ResOK)
|
||||
return res;
|
||||
|
||||
|
|
@ -1551,7 +1552,7 @@ static Res gcSegDescribe(Seg seg, mps_lib_FILE *stream, Count depth)
|
|||
|
||||
Bool SegClassCheck(SegClass klass)
|
||||
{
|
||||
CHECKD(InstClass, &klass->protocol);
|
||||
CHECKD(InstClass, &klass->instClassStruct);
|
||||
CHECKL(klass->size >= sizeof(SegStruct));
|
||||
CHECKL(FUNCHECK(klass->init));
|
||||
CHECKL(FUNCHECK(klass->finish));
|
||||
|
|
@ -1561,7 +1562,6 @@ Bool SegClassCheck(SegClass klass)
|
|||
CHECKL(FUNCHECK(klass->setRankSummary));
|
||||
CHECKL(FUNCHECK(klass->merge));
|
||||
CHECKL(FUNCHECK(klass->split));
|
||||
CHECKL(FUNCHECK(klass->describe));
|
||||
CHECKS(SegClass, klass);
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -1576,7 +1576,8 @@ DEFINE_CLASS(Inst, SegClass, klass)
|
|||
|
||||
DEFINE_CLASS(Seg, Seg, klass)
|
||||
{
|
||||
INHERIT_CLASS(&klass->protocol, Seg, Inst);
|
||||
INHERIT_CLASS(&klass->instClassStruct, Seg, Inst);
|
||||
klass->instClassStruct.describe = SegAbsDescribe;
|
||||
klass->size = sizeof(SegStruct);
|
||||
klass->init = SegAbsInit;
|
||||
klass->finish = SegAbsFinish;
|
||||
|
|
@ -1589,7 +1590,6 @@ DEFINE_CLASS(Seg, Seg, klass)
|
|||
klass->setRankSummary = segNoSetRankSummary;
|
||||
klass->merge = segTrivMerge;
|
||||
klass->split = segTrivSplit;
|
||||
klass->describe = SegAbsDescribe;
|
||||
klass->sig = SegClassSig;
|
||||
AVERT(SegClass, klass);
|
||||
}
|
||||
|
|
@ -1602,6 +1602,7 @@ typedef SegClassStruct GCSegClassStruct;
|
|||
DEFINE_CLASS(Seg, GCSeg, klass)
|
||||
{
|
||||
INHERIT_CLASS(klass, GCSeg, Seg);
|
||||
klass->instClassStruct.describe = gcSegDescribe;
|
||||
klass->size = sizeof(GCSegStruct);
|
||||
klass->init = gcSegInit;
|
||||
klass->finish = gcSegFinish;
|
||||
|
|
@ -1614,7 +1615,6 @@ DEFINE_CLASS(Seg, GCSeg, klass)
|
|||
klass->setRankSummary = gcSegSetRankSummary;
|
||||
klass->merge = gcSegMerge;
|
||||
klass->split = gcSegSplit;
|
||||
klass->describe = gcSegDescribe;
|
||||
AVERT(SegClass, klass);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue