From 546e0821252be8e342fd5cd39b41aa1077b310c2 Mon Sep 17 00:00:00 2001 From: Richard Brooksby Date: Thu, 21 Apr 2016 08:35:51 +0100 Subject: [PATCH] Removing bogus arenatrivdescribe and turning arenadescribe the right way in. Copied from Perforce Change: 191480 ServerID: perforce.ravenbrook.com --- mps/code/arena.c | 59 ++++++++-------------------------------------- mps/code/arenavm.c | 10 ++------ mps/code/global.c | 20 +++++++++------- 3 files changed, 24 insertions(+), 65 deletions(-) diff --git a/mps/code/arena.c b/mps/code/arena.c index a2c7a731c73..3fc69afc30f 100644 --- a/mps/code/arena.c +++ b/mps/code/arena.c @@ -44,32 +44,7 @@ static void arenaFreePage(Arena arena, Addr base, Pool pool); static void arenaFreeLandFinish(Arena arena); static Res ArenaAbsInit(Arena arena, Size grainSize, ArgList args); static void ArenaAbsFinish(Arena arena); - - -/* ArenaTrivDescribe -- produce trivial description of an arena */ - -static Res ArenaTrivDescribe(Arena arena, mps_lib_FILE *stream, Count depth) -{ - if (!TESTT(Arena, arena)) - return ResFAIL; - if (stream == NULL) - return ResFAIL; - - /* .describe.triv.never-called-from-subclass-method: - * This Triv method seems to assume that it will never get called - * from a subclass-method invoking ARENA_SUPERCLASS()->describe. - * It assumes that it only gets called if the describe method has - * not been subclassed. (That's the only reason for printing the - * "No class-specific description available" message). - * This is bogus, but that's the status quo. RHSK 2007-04-27. - */ - /* .describe.triv.dont-upcall: Therefore (for now) the last - * subclass describe method should avoid invoking - * ARENA_SUPERCLASS()->describe. RHSK 2007-04-27. - */ - return WriteF(stream, depth, - " No class-specific description available.\n", NULL); -} +static Res ArenaAbsDescribe(Arena arena, mps_lib_FILE *stream, Count depth); static void ArenaNoFree(Addr base, Size size, Pool pool) @@ -145,7 +120,7 @@ DEFINE_CLASS(Arena, AbstractArena, klass) klass->chunkInit = ArenaNoChunkInit; klass->chunkFinish = ArenaNoChunkFinish; klass->compact = ArenaTrivCompact; - klass->describe = ArenaTrivDescribe; + klass->describe = ArenaAbsDescribe; klass->pagesMarkAllocated = ArenaNoPagesMarkAllocated; klass->sig = ArenaClassSig; } @@ -535,21 +510,16 @@ void ControlFinish(Arena arena) /* ArenaDescribe -- describe the arena */ -Res ArenaDescribe(Arena arena, mps_lib_FILE *stream, Count depth) +static Res ArenaAbsDescribe(Arena arena, mps_lib_FILE *stream, Count depth) { Res res; - ArenaClass klass; if (!TESTC(AbstractArena, arena)) return ResPARAM; if (stream == NULL) return ResPARAM; - klass = ClassOfPoly(Arena, arena); - res = WriteF(stream, depth, "Arena $P {\n", (WriteFP)arena, - " class $P (\"$S\")\n", - (WriteFP)klass, (WriteFS)ClassName(klass), - NULL); + res = InstDescribe(CouldBeA(Inst, arena), stream, depth); if (res != ResOK) return res; @@ -586,27 +556,18 @@ Res ArenaDescribe(Arena arena, mps_lib_FILE *stream, Count depth) if (res != ResOK) return res; - res = Method(Arena, arena, describe)(arena, stream, depth); + res = GlobalsDescribe(ArenaGlobals(arena), stream, depth + 2); if (res != ResOK) return res; - res = WriteF(stream, depth + 2, "Globals {\n", NULL); - if (res != ResOK) - return res; - res = GlobalsDescribe(ArenaGlobals(arena), stream, depth + 4); - if (res != ResOK) - return res; - res = WriteF(stream, depth + 2, "} Globals\n", NULL); - if (res != ResOK) - return res; - - res = WriteF(stream, depth, - "} Arena $P ($U)\n", (WriteFP)arena, - (WriteFU)arena->serial, - NULL); return res; } +Res ArenaDescribe(Arena arena, mps_lib_FILE *stream, Count depth) +{ + return Method(Arena, arena, describe)(arena, stream, depth); +} + /* arenaDescribeTractsInChunk -- describe the tracts in a chunk */ diff --git a/mps/code/arenavm.c b/mps/code/arenavm.c index edd52d2d004..84096fb517f 100644 --- a/mps/code/arenavm.c +++ b/mps/code/arenavm.c @@ -197,15 +197,9 @@ static Res VMArenaDescribe(Arena arena, mps_lib_FILE *stream, Count depth) if (stream == NULL) return ResPARAM; - /* Describe the superclass fields first via next-method call */ - /* ...but the next method is ArenaTrivDescribe, so don't call it; - * see impl.c.arena#describe.triv.dont-upcall. - * - res = NextMethod(Arena, VMArena, describe)(arena, stream); + res = NextMethod(Arena, VMArena, describe)(arena, stream, depth); if (res != ResOK) return res; - * - */ res = WriteF(stream, depth, " spareSize: $U\n", (WriteFU)vmArena->spareSize, @@ -213,7 +207,7 @@ static Res VMArenaDescribe(Arena arena, mps_lib_FILE *stream, Count depth) if(res != ResOK) return res; - /* (incomplete: some fields are not Described) */ + /* TODO: incomplete -- some fields are not Described */ return ResOK; } diff --git a/mps/code/global.c b/mps/code/global.c index 58f1b3ed435..fa2eb684c5b 100644 --- a/mps/code/global.c +++ b/mps/code/global.c @@ -947,8 +947,12 @@ Res GlobalsDescribe(Globals arenaGlobals, mps_lib_FILE *stream, Count depth) if (stream == NULL) return ResFAIL; + res = WriteF(stream, depth, "Globals\n", NULL); + if (res != ResOK) + return res; + arena = GlobalsArena(arenaGlobals); - res = WriteF(stream, depth, + res = WriteF(stream, depth + 2, "mpsVersion $S\n", (WriteFS)arenaGlobals->mpsVersionString, "lock $P\n", (WriteFP)arenaGlobals->lock, "pollThreshold $U kB\n", @@ -979,45 +983,45 @@ Res GlobalsDescribe(Globals arenaGlobals, mps_lib_FILE *stream, Count depth) if (res != ResOK) return res; - res = ShieldDescribe(ArenaShield(arena), stream, depth); + res = ShieldDescribe(ArenaShield(arena), stream, depth + 2); if (res != ResOK) return res; - res = RootsDescribe(arenaGlobals, stream, depth); + res = RootsDescribe(arenaGlobals, stream, depth + 2); if (res != ResOK) return res; RING_FOR(node, &arenaGlobals->poolRing, nextNode) { Pool pool = RING_ELT(Pool, arenaRing, node); - res = PoolDescribe(pool, stream, depth); + res = PoolDescribe(pool, stream, depth + 2); if (res != ResOK) return res; } RING_FOR(node, &arena->formatRing, nextNode) { Format format = RING_ELT(Format, arenaRing, node); - res = FormatDescribe(format, stream, depth); + res = FormatDescribe(format, stream, depth + 2); if (res != ResOK) return res; } RING_FOR(node, &arena->threadRing, nextNode) { Thread thread = ThreadRingThread(node); - res = ThreadDescribe(thread, stream, depth); + res = ThreadDescribe(thread, stream, depth + 2); if (res != ResOK) return res; } RING_FOR(node, &arena->chainRing, nextNode) { Chain chain = RING_ELT(Chain, chainRing, node); - res = ChainDescribe(chain, stream, depth); + res = ChainDescribe(chain, stream, depth + 2); if (res != ResOK) return res; } TRACE_SET_ITER(ti, trace, TraceSetUNIV, arena) if (TraceSetIsMember(arena->busyTraces, trace)) { - res = TraceDescribe(trace, stream, depth); + res = TraceDescribe(trace, stream, depth + 2); if (res != ResOK) return res; }