1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-12 00:50:43 -08:00

Ensure that code of the form if (condition) statement; is split over two lines, so that it is possible to set a breakpoint on the statement in a debugger.

This change was agreed in 1997 (see <https://info.ravenbrook.com/project/mps/mail/1997/08/19/13-44/0.txt>), so it's about time it was implemented.

Copied from Perforce
 Change: 187071
 ServerID: perforce.ravenbrook.com
This commit is contained in:
Gareth Rees 2014-09-27 22:57:02 +01:00
parent 1499ab72af
commit c968255f1e
45 changed files with 542 additions and 280 deletions

View file

@ -161,8 +161,10 @@ Res ABQDescribe(ABQ abq, ABQDescribeElement describeElement, mps_lib_FILE *strea
Res res; Res res;
Index index; Index index;
if (!TESTT(ABQ, abq)) return ResFAIL; if (!TESTT(ABQ, abq))
if (stream == NULL) return ResFAIL; return ResFAIL;
if (stream == NULL)
return ResFAIL;
res = WriteF(stream, depth, res = WriteF(stream, depth,
"ABQ $P {\n", (WriteFP)abq, "ABQ $P {\n", (WriteFP)abq,

View file

@ -99,12 +99,14 @@ static void test_main(void *marker, int interior, int stack)
mps_root_t reg_root = NULL; mps_root_t reg_root = NULL;
res = mps_arena_create_k(&scheme_arena, mps_arena_class_vm(), mps_args_none); res = mps_arena_create_k(&scheme_arena, mps_arena_class_vm(), mps_args_none);
if (res != MPS_RES_OK) error("Couldn't create arena"); if (res != MPS_RES_OK)
error("Couldn't create arena");
res = mps_chain_create(&obj_chain, scheme_arena, res = mps_chain_create(&obj_chain, scheme_arena,
sizeof(obj_gen_params) / sizeof(*obj_gen_params), sizeof(obj_gen_params) / sizeof(*obj_gen_params),
obj_gen_params); obj_gen_params);
if (res != MPS_RES_OK) error("Couldn't create obj chain"); if (res != MPS_RES_OK)
error("Couldn't create obj chain");
scheme_fmt(&obj_fmt); scheme_fmt(&obj_fmt);
@ -117,15 +119,18 @@ static void test_main(void *marker, int interior, int stack)
} MPS_ARGS_END(args); } MPS_ARGS_END(args);
res = mps_ap_create_k(&obj_ap, obj_pool, mps_args_none); res = mps_ap_create_k(&obj_ap, obj_pool, mps_args_none);
if (res != MPS_RES_OK) error("Couldn't create obj allocation point"); if (res != MPS_RES_OK)
error("Couldn't create obj allocation point");
res = mps_thread_reg(&thread, scheme_arena); res = mps_thread_reg(&thread, scheme_arena);
if (res != MPS_RES_OK) error("Couldn't register thread"); if (res != MPS_RES_OK)
error("Couldn't register thread");
if (stack) { if (stack) {
res = mps_root_create_reg(&reg_root, scheme_arena, mps_rank_ambig(), 0, res = mps_root_create_reg(&reg_root, scheme_arena, mps_rank_ambig(), 0,
thread, mps_stack_scan_ambig, marker, 0); thread, mps_stack_scan_ambig, marker, 0);
if (res != MPS_RES_OK) error("Couldn't create root"); if (res != MPS_RES_OK)
error("Couldn't create root");
} }
test_air(interior, stack); test_air(interior, stack);

View file

@ -47,8 +47,10 @@ static void arenaFreePage(Arena arena, Addr base, Pool pool);
static Res ArenaTrivDescribe(Arena arena, mps_lib_FILE *stream, Count depth) static Res ArenaTrivDescribe(Arena arena, mps_lib_FILE *stream, Count depth)
{ {
if (!TESTT(Arena, arena)) return ResFAIL; if (!TESTT(Arena, arena))
if (stream == NULL) return ResFAIL; return ResFAIL;
if (stream == NULL)
return ResFAIL;
/* .describe.triv.never-called-from-subclass-method: /* .describe.triv.never-called-from-subclass-method:
* This Triv method seems to assume that it will never get called * This Triv method seems to assume that it will never get called
@ -454,20 +456,24 @@ Res ArenaDescribe(Arena arena, mps_lib_FILE *stream, Count depth)
Res res; Res res;
Size reserved; Size reserved;
if (!TESTT(Arena, arena)) return ResFAIL; if (!TESTT(Arena, arena))
if (stream == NULL) return ResFAIL; return ResFAIL;
if (stream == NULL)
return ResFAIL;
res = WriteF(stream, depth, "Arena $P {\n", (WriteFP)arena, res = WriteF(stream, depth, "Arena $P {\n", (WriteFP)arena,
" class $P (\"$S\")\n", " class $P (\"$S\")\n",
(WriteFP)arena->class, (WriteFS)arena->class->name, (WriteFP)arena->class, (WriteFS)arena->class->name,
NULL); NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
if (arena->poolReady) { if (arena->poolReady) {
res = WriteF(stream, depth + 2, res = WriteF(stream, depth + 2,
"controlPool $P\n", (WriteFP)&arena->controlPoolStruct, "controlPool $P\n", (WriteFP)&arena->controlPoolStruct,
NULL); NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
} }
/* Note: this Describe clause calls a function */ /* Note: this Describe clause calls a function */
@ -477,7 +483,8 @@ Res ArenaDescribe(Arena arena, mps_lib_FILE *stream, Count depth)
"total size of address-space reserved\n", "total size of address-space reserved\n",
(WriteFW)reserved, (WriteFW)reserved,
NULL); NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
res = WriteF(stream, depth + 2, res = WriteF(stream, depth + 2,
"committed $W <-- " "committed $W <-- "
@ -495,23 +502,29 @@ Res ArenaDescribe(Arena arena, mps_lib_FILE *stream, Count depth)
"freeZones $B\n", (WriteFB)arena->freeZones, "freeZones $B\n", (WriteFB)arena->freeZones,
"zoned $S\n", WriteFYesNo(arena->zoned), "zoned $S\n", WriteFYesNo(arena->zoned),
NULL); NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
res = WriteF(stream, depth + 2, res = WriteF(stream, depth + 2,
"droppedMessages $U$S\n", (WriteFU)arena->droppedMessages, "droppedMessages $U$S\n", (WriteFU)arena->droppedMessages,
(arena->droppedMessages == 0 ? "" : " -- MESSAGES DROPPED!"), (arena->droppedMessages == 0 ? "" : " -- MESSAGES DROPPED!"),
NULL); NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
res = (*arena->class->describe)(arena, stream, depth); res = (*arena->class->describe)(arena, stream, depth);
if (res != ResOK) return res; if (res != ResOK)
return res;
res = WriteF(stream, depth + 2, "Globals {\n", NULL); res = WriteF(stream, depth + 2, "Globals {\n", NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
res = GlobalsDescribe(ArenaGlobals(arena), stream, depth + 4); res = GlobalsDescribe(ArenaGlobals(arena), stream, depth + 4);
if (res != ResOK) return res; if (res != ResOK)
return res;
res = WriteF(stream, depth + 2, "} Globals\n", NULL); res = WriteF(stream, depth + 2, "} Globals\n", NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
res = WriteF(stream, depth, res = WriteF(stream, depth,
"} Arena $P ($U)\n", (WriteFP)arena, "} Arena $P ($U)\n", (WriteFP)arena,
@ -528,14 +541,17 @@ static Res arenaDescribeTractsInChunk(Chunk chunk, mps_lib_FILE *stream, Count d
Res res; Res res;
Index pi; Index pi;
if (!TESTT(Chunk, chunk)) return ResFAIL; if (!TESTT(Chunk, chunk))
if (stream == NULL) return ResFAIL; return ResFAIL;
if (stream == NULL)
return ResFAIL;
res = WriteF(stream, depth, "Chunk [$P, $P) ($U) {\n", res = WriteF(stream, depth, "Chunk [$P, $P) ($U) {\n",
(WriteFP)chunk->base, (WriteFP)chunk->limit, (WriteFP)chunk->base, (WriteFP)chunk->limit,
(WriteFU)chunk->serial, (WriteFU)chunk->serial,
NULL); NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
for (pi = chunk->allocBase; pi < chunk->pages; ++pi) { for (pi = chunk->allocBase; pi < chunk->pages; ++pi) {
if (BTGet(chunk->allocTable, pi)) { if (BTGet(chunk->allocTable, pi)) {
@ -544,7 +560,8 @@ static Res arenaDescribeTractsInChunk(Chunk chunk, mps_lib_FILE *stream, Count d
(WriteFP)TractBase(tract), (WriteFP)TractBase(tract),
(WriteFP)TractLimit(tract, ChunkArena(chunk)), (WriteFP)TractLimit(tract, ChunkArena(chunk)),
NULL); NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
if (TractHasPool(tract)) { if (TractHasPool(tract)) {
Pool pool = TractPool(tract); Pool pool = TractPool(tract);
res = WriteF(stream, 0, " $P $U ($S)", res = WriteF(stream, 0, " $P $U ($S)",
@ -552,10 +569,12 @@ static Res arenaDescribeTractsInChunk(Chunk chunk, mps_lib_FILE *stream, Count d
(WriteFU)(pool->serial), (WriteFU)(pool->serial),
(WriteFS)(pool->class->name), (WriteFS)(pool->class->name),
NULL); NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
} }
res = WriteF(stream, 0, "\n", NULL); res = WriteF(stream, 0, "\n", NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
} }
} }
@ -573,13 +592,16 @@ Res ArenaDescribeTracts(Arena arena, mps_lib_FILE *stream, Count depth)
Ring node, next; Ring node, next;
Res res; Res res;
if (!TESTT(Arena, arena)) return ResFAIL; if (!TESTT(Arena, arena))
if (stream == NULL) return ResFAIL; return ResFAIL;
if (stream == NULL)
return ResFAIL;
RING_FOR(node, &arena->chunkRing, next) { RING_FOR(node, &arena->chunkRing, next) {
Chunk chunk = RING_ELT(Chunk, chunkRing, node); Chunk chunk = RING_ELT(Chunk, chunkRing, node);
res = arenaDescribeTractsInChunk(chunk, stream, depth); res = arenaDescribeTractsInChunk(chunk, stream, depth);
if (res != ResOK) return res; if (res != ResOK)
return res;
} }
return ResOK; return ResOK;
@ -636,8 +658,10 @@ Res ControlDescribe(Arena arena, mps_lib_FILE *stream, Count depth)
{ {
Res res; Res res;
if (!TESTT(Arena, arena)) return ResFAIL; if (!TESTT(Arena, arena))
if (stream == NULL) return ResFAIL; return ResFAIL;
if (stream == NULL)
return ResFAIL;
res = PoolDescribe(ArenaControlPool(arena), stream, depth); res = PoolDescribe(ArenaControlPool(arena), stream, depth);

View file

@ -194,10 +194,13 @@ static Res VMArenaDescribe(Arena arena, mps_lib_FILE *stream, Count depth)
Res res; Res res;
VMArena vmArena; VMArena vmArena;
if (!TESTT(Arena, arena)) return ResFAIL; if (!TESTT(Arena, arena))
if (stream == NULL) return ResFAIL; return ResFAIL;
if (stream == NULL)
return ResFAIL;
vmArena = Arena2VMArena(arena); vmArena = Arena2VMArena(arena);
if (!TESTT(VMArena, vmArena)) return ResFAIL; if (!TESTT(VMArena, vmArena))
return ResFAIL;
/* Describe the superclass fields first via next-method call */ /* Describe the superclass fields first via next-method call */
/* ...but the next method is ArenaTrivDescribe, so don't call it; /* ...but the next method is ArenaTrivDescribe, so don't call it;
@ -205,7 +208,8 @@ static Res VMArenaDescribe(Arena arena, mps_lib_FILE *stream, Count depth)
* *
super = ARENA_SUPERCLASS(VMArenaClass); super = ARENA_SUPERCLASS(VMArenaClass);
res = super->describe(arena, stream); res = super->describe(arena, stream);
if (res != ResOK) return res; if (res != ResOK)
return res;
* *
*/ */

View file

@ -1028,7 +1028,8 @@ Count BTCountResRange(BT bt, Index base, Index limit)
AVER(base < limit); AVER(base < limit);
for (bit = base; bit < limit; ++bit) for (bit = base; bit < limit; ++bit)
if (!BTGet(bt, bit)) ++c; if (!BTGet(bt, bit))
++c;
return c; return c;
} }

View file

@ -150,8 +150,10 @@ Res BufferDescribe(Buffer buffer, mps_lib_FILE *stream, Count depth)
{ {
Res res; Res res;
if (!TESTT(Buffer, buffer)) return ResFAIL; if (!TESTT(Buffer, buffer))
if (stream == NULL) return ResFAIL; return ResFAIL;
if (stream == NULL)
return ResFAIL;
res = WriteF(stream, depth, res = WriteF(stream, depth,
"Buffer $P ($U) {\n", "Buffer $P ($U) {\n",
@ -178,10 +180,12 @@ Res BufferDescribe(Buffer buffer, mps_lib_FILE *stream, Count depth)
" alignment $W\n", (WriteFW)buffer->alignment, " alignment $W\n", (WriteFW)buffer->alignment,
" rampCount $U\n", (WriteFU)buffer->rampCount, " rampCount $U\n", (WriteFU)buffer->rampCount,
NULL); NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
res = buffer->class->describe(buffer, stream, depth + 2); res = buffer->class->describe(buffer, stream, depth + 2);
if (res != ResOK) return res; if (res != ResOK)
return res;
res = WriteF(stream, depth, "} Buffer $P ($U)\n", res = WriteF(stream, depth, "} Buffer $P ($U)\n",
(WriteFP)buffer, (WriteFU)buffer->serial, (WriteFP)buffer, (WriteFU)buffer->serial,
@ -1165,8 +1169,10 @@ static void bufferNoReassignSeg(Buffer buffer, Seg seg)
static Res bufferTrivDescribe(Buffer buffer, mps_lib_FILE *stream, Count depth) static Res bufferTrivDescribe(Buffer buffer, mps_lib_FILE *stream, Count depth)
{ {
if (!TESTT(Buffer, buffer)) return ResFAIL; if (!TESTT(Buffer, buffer))
if (stream == NULL) return ResFAIL; return ResFAIL;
if (stream == NULL)
return ResFAIL;
UNUSED(depth); UNUSED(depth);
/* dispatching function does it all */ /* dispatching function does it all */
return ResOK; return ResOK;
@ -1428,15 +1434,19 @@ static Res segBufDescribe(Buffer buffer, mps_lib_FILE *stream, Count depth)
BufferClass super; BufferClass super;
Res res; Res res;
if (!TESTT(Buffer, buffer)) return ResFAIL; if (!TESTT(Buffer, buffer))
if (stream == NULL) return ResFAIL; return ResFAIL;
if (stream == NULL)
return ResFAIL;
segbuf = BufferSegBuf(buffer); segbuf = BufferSegBuf(buffer);
if (!TESTT(SegBuf, segbuf)) return ResFAIL; if (!TESTT(SegBuf, segbuf))
return ResFAIL;
/* Describe the superclass fields first via next-method call */ /* Describe the superclass fields first via next-method call */
super = BUFFER_SUPERCLASS(SegBufClass); super = BUFFER_SUPERCLASS(SegBufClass);
res = super->describe(buffer, stream, depth); res = super->describe(buffer, stream, depth);
if (res != ResOK) return res; if (res != ResOK)
return res;
res = WriteF(stream, depth, res = WriteF(stream, depth,
"Seg $P\n", (WriteFP)segbuf->seg, "Seg $P\n", (WriteFP)segbuf->seg,

View file

@ -1147,7 +1147,8 @@ static Res cbsDescribe(Land land, mps_lib_FILE *stream, Count depth)
" ownPool: $U\n", (WriteFU)cbs->ownPool, " ownPool: $U\n", (WriteFU)cbs->ownPool,
" treeSize: $U\n", (WriteFU)cbs->treeSize, " treeSize: $U\n", (WriteFU)cbs->treeSize,
NULL); NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
METER_WRITE(cbs->treeSearch, stream, depth + 2); METER_WRITE(cbs->treeSearch, stream, depth + 2);
@ -1159,7 +1160,8 @@ static Res cbsDescribe(Land land, mps_lib_FILE *stream, Count depth)
describe = cbsSplayNodeDescribe; describe = cbsSplayNodeDescribe;
res = SplayTreeDescribe(cbsSplay(cbs), stream, depth + 2, describe); res = SplayTreeDescribe(cbsSplay(cbs), stream, depth + 2, describe);
if (res != ResOK) return res; if (res != ResOK)
return res;
res = WriteF(stream, depth, "} CBS $P\n", (WriteFP)cbs, NULL); res = WriteF(stream, depth, "} CBS $P\n", (WriteFP)cbs, NULL);

View file

@ -67,7 +67,8 @@ static size_t arena_grain_size = 1; /* arena grain size */
if (blocks[k].p == NULL) { \ if (blocks[k].p == NULL) { \
size_t s = rnd() % ((sizeof(void *) << (rnd() % sshift)) - 1); \ size_t s = rnd() % ((sizeof(void *) << (rnd() % sshift)) - 1); \
void *p = NULL; \ void *p = NULL; \
if (s > 0) alloc(p, s); \ if (s > 0) \
alloc(p, s); \
blocks[k].p = p; \ blocks[k].p = p; \
blocks[k].s = s; \ blocks[k].s = s; \
} else { \ } else { \

View file

@ -334,11 +334,14 @@ Res EventDescribe(Event event, mps_lib_FILE *stream, Count depth)
"Event $P {\n", (WriteFP)event, "Event $P {\n", (WriteFP)event,
" code $U\n", (WriteFU)event->any.code, " code $U\n", (WriteFU)event->any.code,
" clock ", NULL); " clock ", NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
res = EVENT_CLOCK_WRITE(stream, depth, event->any.clock); res = EVENT_CLOCK_WRITE(stream, depth, event->any.clock);
if (res != ResOK) return res; if (res != ResOK)
return res;
res = WriteF(stream, depth, "\n size $U\n", (WriteFU)event->any.size, NULL); res = WriteF(stream, depth, "\n size $U\n", (WriteFU)event->any.size, NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
switch (event->any.code) { switch (event->any.code) {
@ -352,14 +355,16 @@ Res EventDescribe(Event event, mps_lib_FILE *stream, Count depth)
" event \"$S\"", (WriteFS)#name, \ " event \"$S\"", (WriteFS)#name, \
EVENT_##name##_PARAMS(EVENT_DESC_PARAM, name) \ EVENT_##name##_PARAMS(EVENT_DESC_PARAM, name) \
NULL); \ NULL); \
if (res != ResOK) return res; \ if (res != ResOK)
return res; \
break; break;
EVENT_LIST(EVENT_DESC, X) EVENT_LIST(EVENT_DESC, X)
default: default:
res = WriteF(stream, depth, " event type unknown", NULL); res = WriteF(stream, depth, " event type unknown", NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
/* TODO: Hexdump unknown event contents. */ /* TODO: Hexdump unknown event contents. */
break; break;
} }
@ -375,8 +380,10 @@ Res EventWrite(Event event, mps_lib_FILE *stream)
{ {
Res res; Res res;
if (event == NULL) return ResFAIL; if (event == NULL)
if (stream == NULL) return ResFAIL; return ResFAIL;
if (stream == NULL)
return ResFAIL;
res = EVENT_CLOCK_WRITE(stream, 0, event->any.clock); res = EVENT_CLOCK_WRITE(stream, 0, event->any.clock);
if (res != ResOK) if (res != ResOK)
@ -392,14 +399,16 @@ Res EventWrite(Event event, mps_lib_FILE *stream)
res = WriteF(stream, 0, " $S", (WriteFS)#name, \ res = WriteF(stream, 0, " $S", (WriteFS)#name, \
EVENT_##name##_PARAMS(EVENT_WRITE_PARAM, name) \ EVENT_##name##_PARAMS(EVENT_WRITE_PARAM, name) \
NULL); \ NULL); \
if (res != ResOK) return res; \ if (res != ResOK) \
return res; \
break; break;
EVENT_LIST(EVENT_WRITE, X) EVENT_LIST(EVENT_WRITE, X)
default: default:
res = WriteF(stream, 0, " <unknown code $U>", res = WriteF(stream, 0, " <unknown code $U>",
(WriteFU)event->any.code, NULL); (WriteFU)event->any.code, NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
/* TODO: Hexdump unknown event contents. */ /* TODO: Hexdump unknown event contents. */
break; break;
} }

View file

@ -172,7 +172,8 @@ static void printParamS(const char *str)
putchar('"'); putchar('"');
for (i = 0; str[i] != '\0'; ++i) { for (i = 0; str[i] != '\0'; ++i) {
char c = str[i]; char c = str[i];
if (c == '"' || c == '\\') putchar('\\'); if (c == '"' || c == '\\')
putchar('\\');
putchar(c); putchar(c);
} }
putchar('"'); putchar('"');

View file

@ -620,11 +620,14 @@ Res EventRepInit(void)
totalEvents = 0; discardedEvents = 0; unknownEvents = 0; totalEvents = 0; discardedEvents = 0; unknownEvents = 0;
res = TableCreate(&arenaTable, (size_t)1); res = TableCreate(&arenaTable, (size_t)1);
if (res != ResOK) goto failArena; if (res != ResOK)
goto failArena;
res = TableCreate(&poolTable, (size_t)1<<4); res = TableCreate(&poolTable, (size_t)1<<4);
if (res != ResOK) goto failPool; if (res != ResOK)
goto failPool;
res = TableCreate(&apTable, (size_t)1<<6); res = TableCreate(&apTable, (size_t)1<<6);
if (res != ResOK) goto failAp; if (res != ResOK)
goto failAp;
return ResOK; return ResOK;

View file

@ -138,7 +138,8 @@ static void printStr(const char *str)
putchar('"'); putchar('"');
for (i = 0; str[i] != '\0'; ++i) { for (i = 0; str[i] != '\0'; ++i) {
char c = str[i]; char c = str[i];
if (c == '"' || c == '\\') putchar('\\'); if (c == '"' || c == '\\')
putchar('\\');
putchar(c); putchar(c);
} }
putchar('"'); putchar('"');

View file

@ -281,10 +281,13 @@ static Res failoverDescribe(Land land, mps_lib_FILE *stream, Count depth)
Failover fo; Failover fo;
Res res; Res res;
if (!TESTT(Land, land)) return ResFAIL; if (!TESTT(Land, land))
return ResFAIL;
fo = failoverOfLand(land); fo = failoverOfLand(land);
if (!TESTT(Failover, fo)) return ResFAIL; if (!TESTT(Failover, fo))
if (stream == NULL) return ResFAIL; return ResFAIL;
if (stream == NULL)
return ResFAIL;
res = WriteF(stream, depth, res = WriteF(stream, depth,
"Failover $P {\n", (WriteFP)fo, "Failover $P {\n", (WriteFP)fo,

View file

@ -210,7 +210,8 @@ Res FormatDescribe(Format format, mps_lib_FILE *stream, Count depth)
" headerSize $W\n", (WriteFW)format->headerSize, " headerSize $W\n", (WriteFW)format->headerSize,
"} Format $P ($U)\n", (WriteFP)format, (WriteFU)format->serial, "} Format $P ($U)\n", (WriteFP)format, (WriteFU)format->serial,
NULL); NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
return ResOK; return ResOK;
} }

View file

@ -747,9 +747,12 @@ static Bool freelistDescribeVisitor(Land land, Range range,
mps_lib_FILE *stream = closureP; mps_lib_FILE *stream = closureP;
Count depth = closureS; Count depth = closureS;
if (!TESTT(Land, land)) return FALSE; if (!TESTT(Land, land))
if (!RangeCheck(range)) return FALSE; return FALSE;
if (stream == NULL) return FALSE; if (!RangeCheck(range))
return FALSE;
if (stream == NULL)
return FALSE;
res = WriteF(stream, depth, res = WriteF(stream, depth,
"[$P,", (WriteFP)RangeBase(range), "[$P,", (WriteFP)RangeBase(range),
@ -767,10 +770,13 @@ static Res freelistDescribe(Land land, mps_lib_FILE *stream, Count depth)
Res res; Res res;
Bool b; Bool b;
if (!TESTT(Land, land)) return ResFAIL; if (!TESTT(Land, land))
return ResFAIL;
fl = freelistOfLand(land); fl = freelistOfLand(land);
if (!TESTT(Freelist, fl)) return ResFAIL; if (!TESTT(Freelist, fl))
if (stream == NULL) return ResFAIL; return ResFAIL;
if (stream == NULL)
return ResFAIL;
res = WriteF(stream, depth, res = WriteF(stream, depth,
"Freelist $P {\n", (WriteFP)fl, "Freelist $P {\n", (WriteFP)fl,
@ -778,7 +784,8 @@ static Res freelistDescribe(Land land, mps_lib_FILE *stream, Count depth)
NULL); NULL);
b = LandIterate(land, freelistDescribeVisitor, stream, depth + 2); b = LandIterate(land, freelistDescribeVisitor, stream, depth + 2);
if (!b) return ResFAIL; if (!b)
return ResFAIL;
res = WriteF(stream, depth, "} Freelist $P\n", (WriteFP)fl, NULL); res = WriteF(stream, depth, "} Freelist $P\n", (WriteFP)fl, NULL);
return res; return res;

View file

@ -83,7 +83,8 @@ static void aset(obj_t v, size_t i, obj_t val) {
static obj_t mktree(mps_ap_t ap, unsigned d, obj_t leaf) { static obj_t mktree(mps_ap_t ap, unsigned d, obj_t leaf) {
obj_t tree; obj_t tree;
size_t i; size_t i;
if (d <= 0) return leaf; if (d <= 0)
return leaf;
tree = mkvector(ap, width); tree = mkvector(ap, width);
for (i = 0; i < width; ++i) { for (i = 0; i < width; ++i) {
aset(tree, i, mktree(ap, d - 1, leaf)); aset(tree, i, mktree(ap, d - 1, leaf));

View file

@ -1017,8 +1017,10 @@ Res GlobalsDescribe(Globals arenaGlobals, mps_lib_FILE *stream, Count depth)
TraceId ti; TraceId ti;
Trace trace; Trace trace;
if (!TESTT(Globals, arenaGlobals)) return ResFAIL; if (!TESTT(Globals, arenaGlobals))
if (stream == NULL) return ResFAIL; return ResFAIL;
if (stream == NULL)
return ResFAIL;
arena = GlobalsArena(arenaGlobals); arena = GlobalsArena(arenaGlobals);
res = WriteF(stream, depth, res = WriteF(stream, depth,
@ -1050,13 +1052,15 @@ Res GlobalsDescribe(Globals arenaGlobals, mps_lib_FILE *stream, Count depth)
"history {\n", "history {\n",
" [note: indices are raw, not rotated]\n", " [note: indices are raw, not rotated]\n",
NULL); NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
for(i=0; i < LDHistoryLENGTH; ++ i) { for(i=0; i < LDHistoryLENGTH; ++ i) {
res = WriteF(stream, depth + 2, res = WriteF(stream, depth + 2,
"[$U] = $B\n", (WriteFU)i, (WriteFB)arena->history[i], "[$U] = $B\n", (WriteFU)i, (WriteFB)arena->history[i],
NULL); NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
} }
res = WriteF(stream, depth, res = WriteF(stream, depth,
@ -1066,39 +1070,46 @@ Res GlobalsDescribe(Globals arenaGlobals, mps_lib_FILE *stream, Count depth)
"shCacheI $U\n", (WriteFU)arena->shCacheI, "shCacheI $U\n", (WriteFU)arena->shCacheI,
/* @@@@ should SegDescribe the cached segs? */ /* @@@@ should SegDescribe the cached segs? */
NULL); NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
res = RootsDescribe(arenaGlobals, stream, depth); res = RootsDescribe(arenaGlobals, stream, depth);
if (res != ResOK) return res; if (res != ResOK)
return res;
RING_FOR(node, &arenaGlobals->poolRing, nextNode) { RING_FOR(node, &arenaGlobals->poolRing, nextNode) {
Pool pool = RING_ELT(Pool, arenaRing, node); Pool pool = RING_ELT(Pool, arenaRing, node);
res = PoolDescribe(pool, stream, depth); res = PoolDescribe(pool, stream, depth);
if (res != ResOK) return res; if (res != ResOK)
return res;
} }
RING_FOR(node, &arena->formatRing, nextNode) { RING_FOR(node, &arena->formatRing, nextNode) {
Format format = RING_ELT(Format, arenaRing, node); Format format = RING_ELT(Format, arenaRing, node);
res = FormatDescribe(format, stream, depth); res = FormatDescribe(format, stream, depth);
if (res != ResOK) return res; if (res != ResOK)
return res;
} }
RING_FOR(node, &arena->threadRing, nextNode) { RING_FOR(node, &arena->threadRing, nextNode) {
Thread thread = ThreadRingThread(node); Thread thread = ThreadRingThread(node);
res = ThreadDescribe(thread, stream, depth); res = ThreadDescribe(thread, stream, depth);
if (res != ResOK) return res; if (res != ResOK)
return res;
} }
RING_FOR(node, &arena->chainRing, nextNode) { RING_FOR(node, &arena->chainRing, nextNode) {
Chain chain = RING_ELT(Chain, chainRing, node); Chain chain = RING_ELT(Chain, chainRing, node);
res = ChainDescribe(chain, stream, depth); res = ChainDescribe(chain, stream, depth);
if (res != ResOK) return res; if (res != ResOK)
return res;
} }
TRACE_SET_ITER(ti, trace, TraceSetUNIV, arena) TRACE_SET_ITER(ti, trace, TraceSetUNIV, arena)
if (TraceSetIsMember(arena->busyTraces, trace)) { if (TraceSetIsMember(arena->busyTraces, trace)) {
res = TraceDescribe(trace, stream, depth); res = TraceDescribe(trace, stream, depth);
if (res != ResOK) return res; if (res != ResOK)
return res;
} }
TRACE_SET_ITER_END(ti, trace, TraceSetUNIV, arena); TRACE_SET_ITER_END(ti, trace, TraceSetUNIV, arena);

View file

@ -376,8 +376,10 @@ Res LandDescribe(Land land, mps_lib_FILE *stream, Count depth)
{ {
Res res; Res res;
if (!TESTT(Land, land)) return ResFAIL; if (!TESTT(Land, land))
if (stream == NULL) return ResFAIL; return ResFAIL;
if (stream == NULL)
return ResFAIL;
res = WriteF(stream, depth, res = WriteF(stream, depth,
"Land $P {\n", (WriteFP)land, "Land $P {\n", (WriteFP)land,

View file

@ -84,8 +84,10 @@ Res LocusPrefDescribe(LocusPref pref, mps_lib_FILE *stream, Count depth)
{ {
Res res; Res res;
if (!TESTT(LocusPref, pref)) return ResFAIL; if (!TESTT(LocusPref, pref))
if (stream == NULL) return ResFAIL; return ResFAIL;
if (stream == NULL)
return ResFAIL;
res = WriteF(stream, depth, res = WriteF(stream, depth,
"LocusPref $P {\n", (WriteFP)pref, "LocusPref $P {\n", (WriteFP)pref,
@ -152,8 +154,10 @@ Res GenDescDescribe(GenDesc gen, mps_lib_FILE *stream, Count depth)
Res res; Res res;
Ring node, nextNode; Ring node, nextNode;
if (!TESTT(GenDesc, gen)) return ResFAIL; if (!TESTT(GenDesc, gen))
if (stream == NULL) return ResFAIL; return ResFAIL;
if (stream == NULL)
return ResFAIL;
res = WriteF(stream, depth, res = WriteF(stream, depth,
"GenDesc $P {\n", (WriteFP)gen, "GenDesc $P {\n", (WriteFP)gen,
@ -161,12 +165,14 @@ Res GenDescDescribe(GenDesc gen, mps_lib_FILE *stream, Count depth)
" capacity $W\n", (WriteFW)gen->capacity, " capacity $W\n", (WriteFW)gen->capacity,
" mortality $D\n", (WriteFD)gen->mortality, " mortality $D\n", (WriteFD)gen->mortality,
NULL); NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
RING_FOR(node, &gen->locusRing, nextNode) { RING_FOR(node, &gen->locusRing, nextNode) {
PoolGen pgen = RING_ELT(PoolGen, genRing, node); PoolGen pgen = RING_ELT(PoolGen, genRing, node);
res = PoolGenDescribe(pgen, stream, depth + 2); res = PoolGenDescribe(pgen, stream, depth + 2);
if (res != ResOK) return res; if (res != ResOK)
return res;
} }
res = WriteF(stream, depth, "} GenDesc $P\n", (WriteFP)gen, NULL); res = WriteF(stream, depth, "} GenDesc $P\n", (WriteFP)gen, NULL);
@ -467,19 +473,23 @@ Res ChainDescribe(Chain chain, mps_lib_FILE *stream, Count depth)
Res res; Res res;
size_t i; size_t i;
if (!TESTT(Chain, chain)) return ResFAIL; if (!TESTT(Chain, chain))
if (stream == NULL) return ResFAIL; return ResFAIL;
if (stream == NULL)
return ResFAIL;
res = WriteF(stream, depth, res = WriteF(stream, depth,
"Chain $P {\n", (WriteFP)chain, "Chain $P {\n", (WriteFP)chain,
" arena $P\n", (WriteFP)chain->arena, " arena $P\n", (WriteFP)chain->arena,
" activeTraces $B\n", (WriteFB)chain->activeTraces, " activeTraces $B\n", (WriteFB)chain->activeTraces,
NULL); NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
for (i = 0; i < chain->genCount; ++i) { for (i = 0; i < chain->genCount; ++i) {
res = GenDescDescribe(&chain->gens[i], stream, depth + 2); res = GenDescDescribe(&chain->gens[i], stream, depth + 2);
if (res != ResOK) return res; if (res != ResOK)
return res;
} }
res = WriteF(stream, depth, res = WriteF(stream, depth,
@ -748,8 +758,10 @@ Res PoolGenDescribe(PoolGen pgen, mps_lib_FILE *stream, Count depth)
{ {
Res res; Res res;
if (!TESTT(PoolGen, pgen)) return ResFAIL; if (!TESTT(PoolGen, pgen))
if (stream == NULL) return ResFAIL; return ResFAIL;
if (stream == NULL)
return ResFAIL;
res = WriteF(stream, depth, res = WriteF(stream, depth,
"PoolGen $P {\n", (WriteFP)pgen, "PoolGen $P {\n", (WriteFP)pgen,

View file

@ -485,7 +485,8 @@ Res WriteF_firstformat_v(mps_lib_FILE *stream, Count depth,
} }
if (*format != '$') { if (*format != '$') {
r = mps_lib_fputc(*format, stream); /* Could be more efficient */ r = mps_lib_fputc(*format, stream); /* Could be more efficient */
if (r == mps_lib_EOF) return ResIO; if (r == mps_lib_EOF)
return ResIO;
if (*format == '\n') { if (*format == '\n') {
start_of_line = TRUE; start_of_line = TRUE;
} }
@ -498,14 +499,16 @@ Res WriteF_firstformat_v(mps_lib_FILE *stream, Count depth,
WriteFA addr = va_arg(args, WriteFA); WriteFA addr = va_arg(args, WriteFA);
res = WriteULongest(stream, (ULongest)addr, 16, res = WriteULongest(stream, (ULongest)addr, 16,
(sizeof(WriteFA) * CHAR_BIT + 3) / 4); (sizeof(WriteFA) * CHAR_BIT + 3) / 4);
if (res != ResOK) return res; if (res != ResOK)
return res;
} break; } break;
case 'P': { /* pointer, see .writef.p */ case 'P': { /* pointer, see .writef.p */
WriteFP p = va_arg(args, WriteFP); WriteFP p = va_arg(args, WriteFP);
res = WriteULongest(stream, (ULongest)p, 16, res = WriteULongest(stream, (ULongest)p, 16,
(sizeof(WriteFP) * CHAR_BIT + 3)/ 4); (sizeof(WriteFP) * CHAR_BIT + 3)/ 4);
if (res != ResOK) return res; if (res != ResOK)
return res;
} break; } break;
case 'F': { /* function */ case 'F': { /* function */
@ -517,56 +520,65 @@ Res WriteF_firstformat_v(mps_lib_FILE *stream, Count depth,
for(i=0; i < sizeof(WriteFF); i++) { for(i=0; i < sizeof(WriteFF); i++) {
res = WriteULongest(stream, (ULongest)(b[i]), 16, res = WriteULongest(stream, (ULongest)(b[i]), 16,
(CHAR_BIT + 3) / 4); (CHAR_BIT + 3) / 4);
if (res != ResOK) return res; if (res != ResOK)
return res;
} }
} break; } break;
case 'S': { /* string */ case 'S': { /* string */
WriteFS s = va_arg(args, WriteFS); WriteFS s = va_arg(args, WriteFS);
r = mps_lib_fputs((const char *)s, stream); r = mps_lib_fputs((const char *)s, stream);
if (r == mps_lib_EOF) return ResIO; if (r == mps_lib_EOF)
return ResIO;
} break; } break;
case 'C': { /* character */ case 'C': { /* character */
WriteFC c = va_arg(args, WriteFC); /* promoted */ WriteFC c = va_arg(args, WriteFC); /* promoted */
r = mps_lib_fputc((int)c, stream); r = mps_lib_fputc((int)c, stream);
if (r == mps_lib_EOF) return ResIO; if (r == mps_lib_EOF)
return ResIO;
} break; } break;
case 'W': { /* word */ case 'W': { /* word */
WriteFW w = va_arg(args, WriteFW); WriteFW w = va_arg(args, WriteFW);
res = WriteULongest(stream, (ULongest)w, 16, res = WriteULongest(stream, (ULongest)w, 16,
(sizeof(WriteFW) * CHAR_BIT + 3) / 4); (sizeof(WriteFW) * CHAR_BIT + 3) / 4);
if (res != ResOK) return res; if (res != ResOK)
return res;
} break; } break;
case 'U': { /* decimal, see .writef.p */ case 'U': { /* decimal, see .writef.p */
WriteFU u = va_arg(args, WriteFU); WriteFU u = va_arg(args, WriteFU);
res = WriteULongest(stream, (ULongest)u, 10, 0); res = WriteULongest(stream, (ULongest)u, 10, 0);
if (res != ResOK) return res; if (res != ResOK)
return res;
} break; } break;
case '3': { /* decimal for thousandths */ case '3': { /* decimal for thousandths */
WriteFU u = va_arg(args, WriteFU); WriteFU u = va_arg(args, WriteFU);
res = WriteULongest(stream, (ULongest)u, 10, 3); res = WriteULongest(stream, (ULongest)u, 10, 3);
if (res != ResOK) return res; if (res != ResOK)
return res;
} break; } break;
case 'B': { /* binary, see .writef.p */ case 'B': { /* binary, see .writef.p */
WriteFB b = va_arg(args, WriteFB); WriteFB b = va_arg(args, WriteFB);
res = WriteULongest(stream, (ULongest)b, 2, sizeof(WriteFB) * CHAR_BIT); res = WriteULongest(stream, (ULongest)b, 2, sizeof(WriteFB) * CHAR_BIT);
if (res != ResOK) return res; if (res != ResOK)
return res;
} break; } break;
case '$': { /* dollar char */ case '$': { /* dollar char */
r = mps_lib_fputc('$', stream); r = mps_lib_fputc('$', stream);
if (r == mps_lib_EOF) return ResIO; if (r == mps_lib_EOF)
return ResIO;
} break; } break;
case 'D': { /* double */ case 'D': { /* double */
WriteFD d = va_arg(args, WriteFD); WriteFD d = va_arg(args, WriteFD);
res = WriteDouble(stream, d); res = WriteDouble(stream, d);
if (res != ResOK) return res; if (res != ResOK)
return res;
} break; } break;
default: default:

View file

@ -95,7 +95,8 @@ static mps_res_t stress(mps_arena_t arena, mps_pool_debug_option_s *options,
for (i=testSetSIZE/2; i<testSetSIZE; ++i) { for (i=testSetSIZE/2; i<testSetSIZE; ++i) {
ss[i] = (*size)(i); ss[i] = (*size)(i);
res = mps_alloc((mps_addr_t *)&ps[i], pool, ss[i]); res = mps_alloc((mps_addr_t *)&ps[i], pool, ss[i]);
if (res != MPS_RES_OK) return res; if (res != MPS_RES_OK)
return res;
allocated += alignUp(ss[i], align) + debugOverhead; allocated += alignUp(ss[i], align) + debugOverhead;
} }
check_allocated_size(pool, allocated); check_allocated_size(pool, allocated);

View file

@ -193,7 +193,7 @@ mps_res_t mps_arena_commit_limit_set(mps_arena_t arena, size_t limit)
res = ArenaSetCommitLimit(arena, limit); res = ArenaSetCommitLimit(arena, limit);
ArenaLeave(arena); ArenaLeave(arena);
return res; return (mps_res_t)res;
} }
void mps_arena_spare_commit_limit_set(mps_arena_t arena, size_t limit) void mps_arena_spare_commit_limit_set(mps_arena_t arena, size_t limit)
@ -269,7 +269,7 @@ mps_res_t mps_arena_start_collect(mps_arena_t arena)
ArenaEnter(arena); ArenaEnter(arena);
res = ArenaStartCollect(ArenaGlobals(arena), TraceStartWhyCLIENTFULL_INCREMENTAL); res = ArenaStartCollect(ArenaGlobals(arena), TraceStartWhyCLIENTFULL_INCREMENTAL);
ArenaLeave(arena); ArenaLeave(arena);
return res; return (mps_res_t)res;
} }
mps_res_t mps_arena_collect(mps_arena_t arena) mps_res_t mps_arena_collect(mps_arena_t arena)
@ -278,7 +278,7 @@ mps_res_t mps_arena_collect(mps_arena_t arena)
ArenaEnter(arena); ArenaEnter(arena);
res = ArenaCollect(ArenaGlobals(arena), TraceStartWhyCLIENTFULL_BLOCK); res = ArenaCollect(ArenaGlobals(arena), TraceStartWhyCLIENTFULL_BLOCK);
ArenaLeave(arena); ArenaLeave(arena);
return res; return (mps_res_t)res;
} }
mps_bool_t mps_arena_step(mps_arena_t arena, mps_bool_t mps_arena_step(mps_arena_t arena,
@ -303,7 +303,7 @@ mps_res_t mps_arena_create(mps_arena_t *mps_arena_o,
va_start(varargs, mps_arena_class); va_start(varargs, mps_arena_class);
res = mps_arena_create_v(mps_arena_o, mps_arena_class, varargs); res = mps_arena_create_v(mps_arena_o, mps_arena_class, varargs);
va_end(varargs); va_end(varargs);
return res; return (mps_res_t)res;
} }
@ -337,7 +337,7 @@ mps_res_t mps_arena_create_k(mps_arena_t *mps_arena_o,
res = ArenaCreate(&arena, arena_class, mps_args); res = ArenaCreate(&arena, arena_class, mps_args);
if (res != ResOK) if (res != ResOK)
return res; return (mps_res_t)res;
ArenaLeave(arena); ArenaLeave(arena);
*mps_arena_o = (mps_arena_t)arena; *mps_arena_o = (mps_arena_t)arena;
@ -461,7 +461,8 @@ mps_res_t mps_fmt_create_k(mps_fmt_t *mps_fmt_o,
ArenaLeave(arena); ArenaLeave(arena);
if (res != ResOK) return res; if (res != ResOK)
return (mps_res_t)res;
*mps_fmt_o = (mps_fmt_t)format; *mps_fmt_o = (mps_fmt_t)format;
return MPS_RES_OK; return MPS_RES_OK;
} }
@ -499,7 +500,8 @@ mps_res_t mps_fmt_create_A(mps_fmt_t *mps_fmt_o,
ArenaLeave(arena); ArenaLeave(arena);
if (res != ResOK) return res; if (res != ResOK)
return (mps_res_t)res;
*mps_fmt_o = (mps_fmt_t)format; *mps_fmt_o = (mps_fmt_t)format;
return MPS_RES_OK; return MPS_RES_OK;
} }
@ -533,7 +535,8 @@ mps_res_t mps_fmt_create_B(mps_fmt_t *mps_fmt_o,
ArenaLeave(arena); ArenaLeave(arena);
if (res != ResOK) return res; if (res != ResOK)
return (mps_res_t)res;
*mps_fmt_o = (mps_fmt_t)format; *mps_fmt_o = (mps_fmt_t)format;
return MPS_RES_OK; return MPS_RES_OK;
} }
@ -567,7 +570,8 @@ mps_res_t mps_fmt_create_auto_header(mps_fmt_t *mps_fmt_o,
ArenaLeave(arena); ArenaLeave(arena);
if (res != ResOK) return res; if (res != ResOK)
return (mps_res_t)res;
*mps_fmt_o = (mps_fmt_t)format; *mps_fmt_o = (mps_fmt_t)format;
return MPS_RES_OK; return MPS_RES_OK;
} }
@ -599,7 +603,8 @@ mps_res_t mps_fmt_create_fixed(mps_fmt_t *mps_fmt_o,
ArenaLeave(arena); ArenaLeave(arena);
if (res != ResOK) return res; if (res != ResOK)
return (mps_res_t)res;
*mps_fmt_o = (mps_fmt_t)format; *mps_fmt_o = (mps_fmt_t)format;
return MPS_RES_OK; return MPS_RES_OK;
} }
@ -659,9 +664,10 @@ mps_res_t mps_pool_create_k(mps_pool_t *mps_pool_o, mps_arena_t arena,
ArenaLeave(arena); ArenaLeave(arena);
if (res != ResOK) return res; if (res != ResOK)
return (mps_res_t)res;
*mps_pool_o = (mps_pool_t)pool; *mps_pool_o = (mps_pool_t)pool;
return res; return MPS_RES_OK;
} }
void mps_pool_destroy(mps_pool_t pool) void mps_pool_destroy(mps_pool_t pool)
@ -739,7 +745,8 @@ mps_res_t mps_alloc(mps_addr_t *p_o, mps_pool_t pool, size_t size)
ArenaLeave(arena); ArenaLeave(arena);
if (res != ResOK) return res; if (res != ResOK)
return (mps_res_t)res;
*p_o = (mps_addr_t)p; *p_o = (mps_addr_t)p;
return MPS_RES_OK; return MPS_RES_OK;
} }
@ -836,7 +843,7 @@ mps_res_t mps_ap_create_k(mps_ap_t *mps_ap_o,
ArenaLeave(arena); ArenaLeave(arena);
if (res != ResOK) if (res != ResOK)
return res; return (mps_res_t)res;
*mps_ap_o = BufferAP(buf); *mps_ap_o = BufferAP(buf);
return MPS_RES_OK; return MPS_RES_OK;
@ -1041,7 +1048,8 @@ mps_res_t mps_ap_fill(mps_addr_t *p_o, mps_ap_t mps_ap, size_t size)
ArenaLeave(arena); ArenaLeave(arena);
if (res != ResOK) return res; if (res != ResOK)
return (mps_res_t)res;
*p_o = (mps_addr_t)p; *p_o = (mps_addr_t)p;
return MPS_RES_OK; return MPS_RES_OK;
} }
@ -1072,7 +1080,8 @@ mps_res_t mps_ap_fill_with_reservoir_permit(mps_addr_t *p_o, mps_ap_t mps_ap,
ArenaLeave(arena); ArenaLeave(arena);
if (res != ResOK) return res; if (res != ResOK)
return (mps_res_t)res;
*p_o = (mps_addr_t)p; *p_o = (mps_addr_t)p;
return MPS_RES_OK; return MPS_RES_OK;
} }
@ -1127,7 +1136,8 @@ mps_res_t mps_sac_create(mps_sac_t *mps_sac_o, mps_pool_t pool,
ArenaLeave(arena); ArenaLeave(arena);
if (res != ResOK) return (mps_res_t)res; if (res != ResOK)
return (mps_res_t)res;
*mps_sac_o = ExternalSACOfSAC(sac); *mps_sac_o = ExternalSACOfSAC(sac);
return (mps_res_t)res; return (mps_res_t)res;
} }
@ -1189,7 +1199,8 @@ mps_res_t mps_sac_fill(mps_addr_t *p_o, mps_sac_t mps_sac, size_t size,
ArenaLeave(arena); ArenaLeave(arena);
if (res != ResOK) return (mps_res_t)res; if (res != ResOK)
return (mps_res_t)res;
*p_o = (mps_addr_t)p; *p_o = (mps_addr_t)p;
return (mps_res_t)res; return (mps_res_t)res;
} }
@ -1225,7 +1236,7 @@ mps_res_t mps_sac_alloc(mps_addr_t *p_o, mps_sac_t mps_sac, size_t size,
AVER(size > 0); AVER(size > 0);
MPS_SAC_ALLOC_FAST(res, *p_o, mps_sac, size, (has_reservoir_permit != 0)); MPS_SAC_ALLOC_FAST(res, *p_o, mps_sac, size, (has_reservoir_permit != 0));
return res; return (mps_res_t)res;
} }
@ -1262,7 +1273,8 @@ mps_res_t mps_root_create(mps_root_t *mps_root_o, mps_arena_t arena,
ArenaLeave(arena); ArenaLeave(arena);
if (res != ResOK) return res; if (res != ResOK)
return (mps_res_t)res;
*mps_root_o = (mps_root_t)root; *mps_root_o = (mps_root_t)root;
return MPS_RES_OK; return MPS_RES_OK;
} }
@ -1291,7 +1303,8 @@ mps_res_t mps_root_create_table(mps_root_t *mps_root_o, mps_arena_t arena,
ArenaLeave(arena); ArenaLeave(arena);
if (res != ResOK) return res; if (res != ResOK)
return (mps_res_t)res;
*mps_root_o = (mps_root_t)root; *mps_root_o = (mps_root_t)root;
return MPS_RES_OK; return MPS_RES_OK;
} }
@ -1322,7 +1335,8 @@ mps_res_t mps_root_create_table_masked(mps_root_t *mps_root_o,
ArenaLeave(arena); ArenaLeave(arena);
if (res != ResOK) return res; if (res != ResOK)
return (mps_res_t)res;
*mps_root_o = (mps_root_t)root; *mps_root_o = (mps_root_t)root;
return MPS_RES_OK; return MPS_RES_OK;
} }
@ -1344,7 +1358,8 @@ mps_res_t mps_root_create_fmt(mps_root_t *mps_root_o, mps_arena_t arena,
res = RootCreateFmt(&root, arena, rank, mode, scan, (Addr)base, (Addr)limit); res = RootCreateFmt(&root, arena, rank, mode, scan, (Addr)base, (Addr)limit);
ArenaLeave(arena); ArenaLeave(arena);
if (res != ResOK) return res; if (res != ResOK)
return (mps_res_t)res;
*mps_root_o = (mps_root_t)root; *mps_root_o = (mps_root_t)root;
return MPS_RES_OK; return MPS_RES_OK;
} }
@ -1373,7 +1388,8 @@ mps_res_t mps_root_create_reg(mps_root_t *mps_root_o, mps_arena_t arena,
ArenaLeave(arena); ArenaLeave(arena);
if (res != ResOK) return res; if (res != ResOK)
return (mps_res_t)res;
*mps_root_o = (mps_root_t)root; *mps_root_o = (mps_root_t)root;
return MPS_RES_OK; return MPS_RES_OK;
} }
@ -1433,7 +1449,8 @@ mps_res_t mps_thread_reg(mps_thr_t *mps_thr_o, mps_arena_t arena)
ArenaLeave(arena); ArenaLeave(arena);
if (res != ResOK) return res; if (res != ResOK)
return (mps_res_t)res;
*mps_thr_o = (mps_thr_t)thread; *mps_thr_o = (mps_thr_t)thread;
return MPS_RES_OK; return MPS_RES_OK;
} }
@ -1534,7 +1551,7 @@ mps_res_t mps_finalize(mps_arena_t arena, mps_addr_t *refref)
res = ArenaFinalize(arena, object); res = ArenaFinalize(arena, object);
ArenaLeave(arena); ArenaLeave(arena);
return res; return (mps_res_t)res;
} }
@ -1551,7 +1568,7 @@ mps_res_t mps_definalize(mps_arena_t arena, mps_addr_t *refref)
res = ArenaDefinalize(arena, object); res = ArenaDefinalize(arena, object);
ArenaLeave(arena); ArenaLeave(arena);
return res; return (mps_res_t)res;
} }
@ -1857,7 +1874,7 @@ mps_res_t mps_ap_alloc_pattern_end(mps_ap_t mps_ap,
ArenaPoll(ArenaGlobals(arena)); /* .poll */ ArenaPoll(ArenaGlobals(arena)); /* .poll */
ArenaLeave(arena); ArenaLeave(arena);
return res; return (mps_res_t)res;
} }
@ -1942,7 +1959,7 @@ mps_res_t mps_chain_create(mps_chain_t *chain_o, mps_arena_t arena,
ArenaLeave(arena); ArenaLeave(arena);
if (res != ResOK) if (res != ResOK)
return res; return (mps_res_t)res;
*chain_o = (mps_chain_t)chain; *chain_o = (mps_chain_t)chain;
return MPS_RES_OK; return MPS_RES_OK;
} }

View file

@ -130,11 +130,13 @@ static mps_addr_t make(void)
do { do {
MPS_RESERVE_BLOCK(res, pMps, ap, sizeMps); MPS_RESERVE_BLOCK(res, pMps, ap, sizeMps);
if (res != MPS_RES_OK) die(res, "MPS_RESERVE_BLOCK"); if (res != MPS_RES_OK)
die(res, "MPS_RESERVE_BLOCK");
HeaderInit(pMps); HeaderInit(pMps);
pCli = PtrMps2Cli(pMps); pCli = PtrMps2Cli(pMps);
res = dylan_init(pCli, sizeCli, exactRoots, exactRootsCOUNT); res = dylan_init(pCli, sizeCli, exactRoots, exactRootsCOUNT);
if (res != MPS_RES_OK) die(res, "dylan_init"); if (res != MPS_RES_OK)
die(res, "dylan_init");
} while(!mps_commit(ap, pMps, sizeMps)); } while(!mps_commit(ap, pMps, sizeMps));
return pCli; return pCli;
@ -153,11 +155,13 @@ static mps_addr_t make_with_permit(void)
do { do {
MPS_RESERVE_WITH_RESERVOIR_PERMIT_BLOCK(res, pMps, ap, sizeMps); MPS_RESERVE_WITH_RESERVOIR_PERMIT_BLOCK(res, pMps, ap, sizeMps);
if (res != MPS_RES_OK) die(res, "MPS_RESERVE_WITH_RESERVOIR_PERMIT_BLOCK"); if (res != MPS_RES_OK)
die(res, "MPS_RESERVE_WITH_RESERVOIR_PERMIT_BLOCK");
HeaderInit(pMps); HeaderInit(pMps);
pCli = PtrMps2Cli(pMps); pCli = PtrMps2Cli(pMps);
res = dylan_init(pCli, sizeCli, exactRoots, exactRootsCOUNT); res = dylan_init(pCli, sizeCli, exactRoots, exactRootsCOUNT);
if (res != MPS_RES_OK) die(res, "dylan_init"); if (res != MPS_RES_OK)
die(res, "dylan_init");
} while(!mps_commit(ap, pMps, sizeMps)); } while(!mps_commit(ap, pMps, sizeMps));
return pCli; return pCli;
@ -176,11 +180,13 @@ static mps_addr_t make_no_inline(void)
do { do {
res = (mps_reserve)(&pMps, ap, sizeMps); res = (mps_reserve)(&pMps, ap, sizeMps);
if (res != MPS_RES_OK) die(res, "(mps_reserve)"); if (res != MPS_RES_OK)
die(res, "(mps_reserve)");
HeaderInit(pMps); HeaderInit(pMps);
pCli = PtrMps2Cli(pMps); pCli = PtrMps2Cli(pMps);
res = dylan_init(pCli, sizeCli, exactRoots, exactRootsCOUNT); res = dylan_init(pCli, sizeCli, exactRoots, exactRootsCOUNT);
if (res != MPS_RES_OK) die(res, "dylan_init"); if (res != MPS_RES_OK)
die(res, "dylan_init");
} while(!(mps_commit)(ap, pMps, sizeMps)); } while(!(mps_commit)(ap, pMps, sizeMps));
return pCli; return pCli;

View file

@ -95,7 +95,8 @@ static mps_res_t stress(mps_arena_t arena, mps_align_t align,
size_t ss[TEST_SET_SIZE]; size_t ss[TEST_SET_SIZE];
res = mps_pool_create_k(&pool, arena, pool_class, args); res = mps_pool_create_k(&pool, arena, pool_class, args);
if(res != MPS_RES_OK) return res; if (res != MPS_RES_OK)
return res;
die(mps_ap_create(&ap, pool, mps_rank_exact()), "BufferCreate"); die(mps_ap_create(&ap, pool, mps_rank_exact()), "BufferCreate");
@ -110,7 +111,8 @@ static mps_res_t stress(mps_arena_t arena, mps_align_t align,
*ps[i] = 1; /* Write something, so it gets swap. */ *ps[i] = 1; /* Write something, so it gets swap. */
if (verbose) { if (verbose) {
if(i && i%4==0) putchar('\n'); if (i && i%4==0)
putchar('\n');
printf("%"PRIwWORD PRIXLONGEST" %6"PRIXLONGEST" ", printf("%"PRIwWORD PRIXLONGEST" %6"PRIXLONGEST" ",
(ulongest_t)ps[i], (ulongest_t)ss[i]); (ulongest_t)ps[i], (ulongest_t)ss[i]);
} }
@ -151,7 +153,8 @@ static mps_res_t stress(mps_arena_t arena, mps_align_t align,
ss[i] = s; ss[i] = s;
if (verbose) { if (verbose) {
if(i && i%4==0) putchar('\n'); if (i && i%4==0)
putchar('\n');
printf("%"PRIwWORD PRIXLONGEST" %6"PRIXLONGEST" ", printf("%"PRIwWORD PRIXLONGEST" %6"PRIXLONGEST" ",
(ulongest_t)ps[i], (ulongest_t)ss[i]); (ulongest_t)ps[i], (ulongest_t)ss[i]);
} }

View file

@ -549,8 +549,10 @@ Res PoolDescribe(Pool pool, mps_lib_FILE *stream, Count depth)
Res res; Res res;
Ring node, nextNode; Ring node, nextNode;
if (!TESTT(Pool, pool)) return ResFAIL; if (!TESTT(Pool, pool))
if (stream == NULL) return ResFAIL; return ResFAIL;
if (stream == NULL)
return ResFAIL;
res = WriteF(stream, depth, res = WriteF(stream, depth,
"Pool $P ($U) {\n", (WriteFP)pool, (WriteFU)pool->serial, "Pool $P ($U) {\n", (WriteFP)pool, (WriteFU)pool->serial,
@ -560,10 +562,12 @@ Res PoolDescribe(Pool pool, mps_lib_FILE *stream, Count depth)
(WriteFP)pool->arena, (WriteFU)pool->arena->serial, (WriteFP)pool->arena, (WriteFU)pool->arena->serial,
" alignment $W\n", (WriteFW)pool->alignment, " alignment $W\n", (WriteFW)pool->alignment,
NULL); NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
if (NULL != pool->format) { if (NULL != pool->format) {
res = FormatDescribe(pool->format, stream, depth + 2); res = FormatDescribe(pool->format, stream, depth + 2);
if (res != ResOK) return res; if (res != ResOK)
return res;
} }
res = WriteF(stream, depth + 2, res = WriteF(stream, depth + 2,
"fillMutatorSize $UKb\n", "fillMutatorSize $UKb\n",
@ -575,21 +579,25 @@ Res PoolDescribe(Pool pool, mps_lib_FILE *stream, Count depth)
"emptyInternalSize $UKb\n", "emptyInternalSize $UKb\n",
(WriteFU)(pool->emptyInternalSize / 1024), (WriteFU)(pool->emptyInternalSize / 1024),
NULL); NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
res = (*pool->class->describe)(pool, stream, depth + 2); res = (*pool->class->describe)(pool, stream, depth + 2);
if (res != ResOK) return res; if (res != ResOK)
return res;
RING_FOR(node, &pool->bufferRing, nextNode) { RING_FOR(node, &pool->bufferRing, nextNode) {
Buffer buffer = RING_ELT(Buffer, poolRing, node); Buffer buffer = RING_ELT(Buffer, poolRing, node);
res = BufferDescribe(buffer, stream, depth + 2); res = BufferDescribe(buffer, stream, depth + 2);
if (res != ResOK) return res; if (res != ResOK)
return res;
} }
res = WriteF(stream, depth, res = WriteF(stream, depth,
"} Pool $P ($U)\n", (WriteFP)pool, (WriteFU)pool->serial, "} Pool $P ($U)\n", (WriteFP)pool, (WriteFU)pool->serial,
NULL); NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
return ResOK; return ResOK;
} }

View file

@ -263,7 +263,8 @@ Res PoolTrivBufferFill(Addr *baseReturn, Addr *limitReturn,
AVERT(Bool, withReservoirPermit); AVERT(Bool, withReservoirPermit);
res = PoolAlloc(&p, pool, size, withReservoirPermit); res = PoolAlloc(&p, pool, size, withReservoirPermit);
if(res != ResOK) return res; if (res != ResOK)
return res;
*baseReturn = p; *baseReturn = p;
*limitReturn = AddrAdd(p, size); *limitReturn = AddrAdd(p, size);

View file

@ -103,7 +103,8 @@ void AMSSegFreeWalk(AMSSeg amsseg, FreeBlockStepMethod f, void *p)
while (next < amsseg->grains) { while (next < amsseg->grains) {
Bool found = BTFindLongResRange(&base, &limit, amsseg->allocTable, Bool found = BTFindLongResRange(&base, &limit, amsseg->allocTable,
next, amsseg->grains, 1); next, amsseg->grains, 1);
if (!found) break; if (!found)
break;
(*f)(AMS_INDEX_ADDR(seg, base), AMS_INDEX_ADDR(seg, limit), pool, p); (*f)(AMS_INDEX_ADDR(seg, base), AMS_INDEX_ADDR(seg, limit), pool, p);
next = limit + 1; next = limit + 1;
} }
@ -539,15 +540,19 @@ static Res AMSSegDescribe(Seg seg, mps_lib_FILE *stream, Count depth)
Buffer buffer; /* the segment's buffer, if it has one */ Buffer buffer; /* the segment's buffer, if it has one */
Index i; Index i;
if (!TESTT(Seg, seg)) return ResFAIL; if (!TESTT(Seg, seg))
if (stream == NULL) return ResFAIL; return ResFAIL;
if (stream == NULL)
return ResFAIL;
amsseg = Seg2AMSSeg(seg); amsseg = Seg2AMSSeg(seg);
if (!TESTT(AMSSeg, amsseg)) return ResFAIL; if (!TESTT(AMSSeg, amsseg))
return ResFAIL;
/* Describe the superclass fields first via next-method call */ /* Describe the superclass fields first via next-method call */
super = SEG_SUPERCLASS(AMSSegClass); super = SEG_SUPERCLASS(AMSSegClass);
res = super->describe(seg, stream, depth); res = super->describe(seg, stream, depth);
if (res != ResOK) return res; if (res != ResOK)
return res;
buffer = SegBuffer(seg); buffer = SegBuffer(seg);
@ -558,7 +563,8 @@ static Res AMSSegDescribe(Seg seg, mps_lib_FILE *stream, Count depth)
" oldGrains $W\n", (WriteFW)amsseg->oldGrains, " oldGrains $W\n", (WriteFW)amsseg->oldGrains,
" newGrains $W\n", (WriteFW)amsseg->newGrains, " newGrains $W\n", (WriteFW)amsseg->newGrains,
NULL); NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
if (amsseg->allocTableInUse) if (amsseg->allocTableInUse)
res = WriteF(stream, depth, res = WriteF(stream, depth,
"alloctable $P\n", (WriteFP)amsseg->allocTable, "alloctable $P\n", (WriteFP)amsseg->allocTable,
@ -567,23 +573,27 @@ static Res AMSSegDescribe(Seg seg, mps_lib_FILE *stream, Count depth)
res = WriteF(stream, depth, res = WriteF(stream, depth,
"firstFree $W\n", (WriteFW)amsseg->firstFree, "firstFree $W\n", (WriteFW)amsseg->firstFree,
NULL); NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
res = WriteF(stream, depth, res = WriteF(stream, depth,
"tables: nongrey $P, nonwhite $P\n", "tables: nongrey $P, nonwhite $P\n",
(WriteFP)amsseg->nongreyTable, (WriteFP)amsseg->nongreyTable,
(WriteFP)amsseg->nonwhiteTable, (WriteFP)amsseg->nonwhiteTable,
"map:", "map:",
NULL); NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
for (i=0; i < amsseg->grains; ++i) { for (i=0; i < amsseg->grains; ++i) {
char c = 0; char c = 0;
if (i % 64 == 0) { if (i % 64 == 0) {
res = WriteF(stream, 0, "\n", NULL); res = WriteF(stream, 0, "\n", NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
res = WriteF(stream, depth, " ", NULL); res = WriteF(stream, depth, " ", NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
} }
WRITE_BUFFER_LIMIT(stream, seg, i, buffer, BufferBase, "["); WRITE_BUFFER_LIMIT(stream, seg, i, buffer, BufferBase, "[");
@ -1697,10 +1707,13 @@ static Res AMSDescribe(Pool pool, mps_lib_FILE *stream, Count depth)
Ring node, nextNode; Ring node, nextNode;
Res res; Res res;
if (!TESTT(Pool, pool)) return ResFAIL; if (!TESTT(Pool, pool))
return ResFAIL;
ams = PoolAMS(pool); ams = PoolAMS(pool);
if (!TESTT(AMS, ams)) return ResFAIL; if (!TESTT(AMS, ams))
if (stream == NULL) return ResFAIL; return ResFAIL;
if (stream == NULL)
return ResFAIL;
res = WriteF(stream, depth, res = WriteF(stream, depth,
"AMS $P {\n", (WriteFP)ams, "AMS $P {\n", (WriteFP)ams,
@ -1708,18 +1721,21 @@ static Res AMSDescribe(Pool pool, mps_lib_FILE *stream, Count depth)
(WriteFP)pool, (WriteFU)pool->serial, (WriteFP)pool, (WriteFU)pool->serial,
" grain shift $U\n", (WriteFU)ams->grainShift, " grain shift $U\n", (WriteFU)ams->grainShift,
NULL); NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
res = WriteF(stream, depth + 2, res = WriteF(stream, depth + 2,
"segments: * black + grey - white . alloc ! bad\n" "segments: * black + grey - white . alloc ! bad\n"
"buffers: [ base < scan limit | init > alloc ] limit\n", "buffers: [ base < scan limit | init > alloc ] limit\n",
NULL); NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
RING_FOR(node, &ams->segRing, nextNode) { RING_FOR(node, &ams->segRing, nextNode) {
AMSSeg amsseg = RING_ELT(AMSSeg, segRing, node); AMSSeg amsseg = RING_ELT(AMSSeg, segRing, node);
res = SegDescribe(AMSSeg2Seg(amsseg), stream, depth + 2); res = SegDescribe(AMSSeg2Seg(amsseg), stream, depth + 2);
if (res != ResOK) return res; if (res != ResOK)
return res;
} }
res = WriteF(stream, depth, "} AMS $P\n",(WriteFP)ams, NULL); res = WriteF(stream, depth, "} AMS $P\n",(WriteFP)ams, NULL);

View file

@ -351,7 +351,8 @@ static Res MFSDescribe(Pool pool, mps_lib_FILE *stream, Count depth)
"free $W\n", (WriteFW)mfs->free, "free $W\n", (WriteFW)mfs->free,
"tractList $P\n", (WriteFP)mfs->tractList, "tractList $P\n", (WriteFP)mfs->tractList,
NULL); NULL);
if(res != ResOK) return res; if (res != ResOK)
return res;
return ResOK; return ResOK;
} }

View file

@ -804,16 +804,21 @@ static Res MRGDescribe(Pool pool, mps_lib_FILE *stream, Count depth)
RefPart refPart; RefPart refPart;
Res res; Res res;
if (!TESTT(Pool, pool)) return ResFAIL; if (!TESTT(Pool, pool))
return ResFAIL;
mrg = PoolMRG(pool); mrg = PoolMRG(pool);
if (!TESTT(MRG, mrg)) return ResFAIL; if (!TESTT(MRG, mrg))
if (stream == NULL) return ResFAIL; return ResFAIL;
if (stream == NULL)
return ResFAIL;
arena = PoolArena(pool); arena = PoolArena(pool);
res = WriteF(stream, depth, "extendBy $W\n", (WriteFW)mrg->extendBy, NULL); res = WriteF(stream, depth, "extendBy $W\n", (WriteFW)mrg->extendBy, NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
res = WriteF(stream, depth, "Entry queue:\n", NULL); res = WriteF(stream, depth, "Entry queue:\n", NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
RING_FOR(node, &mrg->entryRing, nextNode) { RING_FOR(node, &mrg->entryRing, nextNode) {
Bool outsideShield = !arena->insideShield; Bool outsideShield = !arena->insideShield;
refPart = MRGRefPartOfLink(linkOfRing(node), arena); refPart = MRGRefPartOfLink(linkOfRing(node), arena);
@ -826,7 +831,8 @@ static Res MRGDescribe(Pool pool, mps_lib_FILE *stream, Count depth)
if (outsideShield) { if (outsideShield) {
ShieldLeave(arena); ShieldLeave(arena);
} }
if (res != ResOK) return res; if (res != ResOK)
return res;
} }
return ResOK; return ResOK;

View file

@ -455,7 +455,8 @@ static Res MVSpanFree(MVSpan span, Addr base, Addr limit, Pool blockPool)
/* block must be split into two parts. */ /* block must be split into two parts. */
res = PoolAlloc(&addr, blockPool, sizeof(MVBlockStruct), res = PoolAlloc(&addr, blockPool, sizeof(MVBlockStruct),
/* withReservoirPermit */ FALSE); /* withReservoirPermit */ FALSE);
if(res != ResOK) return res; if (res != ResOK)
return res;
new = (MVBlock)addr; new = (MVBlock)addr;
freeAreaSize = AddrOffset(base, limit); freeAreaSize = AddrOffset(base, limit);
@ -742,10 +743,13 @@ static Res MVDescribe(Pool pool, mps_lib_FILE *stream, Count depth)
char c; char c;
Ring spans, node = NULL, nextNode; /* gcc whinge stop */ Ring spans, node = NULL, nextNode; /* gcc whinge stop */
if(!TESTT(Pool, pool)) return ResFAIL; if (!TESTT(Pool, pool))
return ResFAIL;
mv = PoolMV(pool); mv = PoolMV(pool);
if(!TESTT(MV, mv)) return ResFAIL; if (!TESTT(MV, mv))
if(stream == NULL) return ResFAIL; return ResFAIL;
if (stream == NULL)
return ResFAIL;
res = WriteF(stream, depth, res = WriteF(stream, depth,
"blockPool $P ($U)\n", "blockPool $P ($U)\n",
@ -769,7 +773,8 @@ static Res MVDescribe(Pool pool, mps_lib_FILE *stream, Count depth)
MVBlock block; MVBlock block;
span = RING_ELT(MVSpan, spans, node); span = RING_ELT(MVSpan, spans, node);
res = WriteF(stream, depth, "MVSpan $P {\n", (WriteFP)span, NULL); res = WriteF(stream, depth, "MVSpan $P {\n", (WriteFP)span, NULL);
if(res != ResOK) return res; if (res != ResOK)
return res;
res = WriteF(stream, depth + 2, res = WriteF(stream, depth + 2,
"span $P\n", (WriteFP)span, "span $P\n", (WriteFP)span,
@ -778,19 +783,22 @@ static Res MVDescribe(Pool pool, mps_lib_FILE *stream, Count depth)
"blocks $U\n", (WriteFU)span->blockCount, "blocks $U\n", (WriteFU)span->blockCount,
"largest ", "largest ",
NULL); NULL);
if(res != ResOK) return res; if (res != ResOK)
return res;
if (span->largestKnown) /* .design.largest */ if (span->largestKnown) /* .design.largest */
res = WriteF(stream, 0, "$W\n", (WriteFW)span->largest, NULL); res = WriteF(stream, 0, "$W\n", (WriteFW)span->largest, NULL);
else else
res = WriteF(stream, 0, "unknown\n", NULL); res = WriteF(stream, 0, "unknown\n", NULL);
if(res != ResOK) return res; if (res != ResOK)
return res;
block = span->blocks; block = span->blocks;
for(i = span->base.base; i < span->limit.limit; i = AddrAdd(i, length)) { for(i = span->base.base; i < span->limit.limit; i = AddrAdd(i, length)) {
res = WriteF(stream, depth + 2, "$A ", (WriteFA)i, NULL); res = WriteF(stream, depth + 2, "$A ", (WriteFA)i, NULL);
if(res != ResOK) return res; if (res != ResOK)
return res;
for(j = i; for(j = i;
j < AddrAdd(i, length) && j < span->limit.limit; j < AddrAdd(i, length) && j < span->limit.limit;
@ -813,13 +821,16 @@ static Res MVDescribe(Pool pool, mps_lib_FILE *stream, Count depth)
else /* j > block->base && j < block->limit */ else /* j > block->base && j < block->limit */
c = '='; c = '=';
res = WriteF(stream, 0, "$C", (WriteFC)c, NULL); res = WriteF(stream, 0, "$C", (WriteFC)c, NULL);
if(res != ResOK) return res; if (res != ResOK)
return res;
} }
res = WriteF(stream, 0, "\n", NULL); res = WriteF(stream, 0, "\n", NULL);
if(res != ResOK) return res; if (res != ResOK)
return res;
} }
res = WriteF(stream, depth, "} MVSpan $P\n", (WriteFP)span, NULL); res = WriteF(stream, depth, "} MVSpan $P\n", (WriteFP)span, NULL);
if(res != ResOK) return res; if (res != ResOK)
return res;
} }
return ResOK; return ResOK;

View file

@ -1027,10 +1027,13 @@ static Res MVTDescribe(Pool pool, mps_lib_FILE *stream, Count depth)
Res res; Res res;
MVT mvt; MVT mvt;
if (!TESTT(Pool, pool)) return ResFAIL; if (!TESTT(Pool, pool))
return ResFAIL;
mvt = PoolMVT(pool); mvt = PoolMVT(pool);
if (!TESTT(MVT, mvt)) return ResFAIL; if (!TESTT(MVT, mvt))
if (stream == NULL) return ResFAIL; return ResFAIL;
if (stream == NULL)
return ResFAIL;
res = WriteF(stream, depth, res = WriteF(stream, depth,
"MVT $P {\n", (WriteFP)mvt, "MVT $P {\n", (WriteFP)mvt,
@ -1050,17 +1053,22 @@ static Res MVTDescribe(Pool pool, mps_lib_FILE *stream, Count depth)
" available: $U\n", (WriteFU)mvt->available, " available: $U\n", (WriteFU)mvt->available,
" unavailable: $U\n", (WriteFU)mvt->unavailable, " unavailable: $U\n", (WriteFU)mvt->unavailable,
NULL); NULL);
if(res != ResOK) return res; if (res != ResOK)
return res;
res = LandDescribe(MVTFreePrimary(mvt), stream, depth + 2); res = LandDescribe(MVTFreePrimary(mvt), stream, depth + 2);
if(res != ResOK) return res; if (res != ResOK)
return res;
res = LandDescribe(MVTFreeSecondary(mvt), stream, depth + 2); res = LandDescribe(MVTFreeSecondary(mvt), stream, depth + 2);
if(res != ResOK) return res; if (res != ResOK)
return res;
res = LandDescribe(MVTFreeLand(mvt), stream, depth + 2); res = LandDescribe(MVTFreeLand(mvt), stream, depth + 2);
if(res != ResOK) return res; if (res != ResOK)
return res;
res = ABQDescribe(MVTABQ(mvt), (ABQDescribeElement)RangeDescribe, stream, res = ABQDescribe(MVTABQ(mvt), (ABQDescribeElement)RangeDescribe, stream,
depth + 2); depth + 2);
if(res != ResOK) return res; if (res != ResOK)
return res;
METER_WRITE(mvt->segAllocs, stream, depth + 2); METER_WRITE(mvt->segAllocs, stream, depth + 2);
METER_WRITE(mvt->segFrees, stream, depth + 2); METER_WRITE(mvt->segFrees, stream, depth + 2);

View file

@ -673,10 +673,13 @@ static Res MVFFDescribe(Pool pool, mps_lib_FILE *stream, Count depth)
Res res; Res res;
MVFF mvff; MVFF mvff;
if (!TESTT(Pool, pool)) return ResFAIL; if (!TESTT(Pool, pool))
return ResFAIL;
mvff = PoolMVFF(pool); mvff = PoolMVFF(pool);
if (!TESTT(MVFF, mvff)) return ResFAIL; if (!TESTT(MVFF, mvff))
if (stream == NULL) return ResFAIL; return ResFAIL;
if (stream == NULL)
return ResFAIL;
res = WriteF(stream, depth, res = WriteF(stream, depth,
"MVFF $P {\n", (WriteFP)mvff, "MVFF $P {\n", (WriteFP)mvff,
@ -688,22 +691,27 @@ static Res MVFFDescribe(Pool pool, mps_lib_FILE *stream, Count depth)
" slotHigh $U\n", (WriteFU)mvff->slotHigh, " slotHigh $U\n", (WriteFU)mvff->slotHigh,
" spare $D\n", (WriteFD)mvff->spare, " spare $D\n", (WriteFD)mvff->spare,
NULL); NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
res = LocusPrefDescribe(MVFFLocusPref(mvff), stream, depth + 2); res = LocusPrefDescribe(MVFFLocusPref(mvff), stream, depth + 2);
if (res != ResOK) return res; if (res != ResOK)
return res;
/* Don't describe MVFFBlockPool(mvff) otherwise it'll appear twice /* Don't describe MVFFBlockPool(mvff) otherwise it'll appear twice
* in the output of GlobalDescribe. */ * in the output of GlobalDescribe. */
res = LandDescribe(MVFFTotalLand(mvff), stream, depth + 2); res = LandDescribe(MVFFTotalLand(mvff), stream, depth + 2);
if (res != ResOK) return res; if (res != ResOK)
return res;
res = LandDescribe(MVFFFreePrimary(mvff), stream, depth + 2); res = LandDescribe(MVFFFreePrimary(mvff), stream, depth + 2);
if (res != ResOK) return res; if (res != ResOK)
return res;
res = LandDescribe(MVFFFreeSecondary(mvff), stream, depth + 2); res = LandDescribe(MVFFFreeSecondary(mvff), stream, depth + 2);
if (res != ResOK) return res; if (res != ResOK)
return res;
res = WriteF(stream, depth, "} MVFF $P\n", (WriteFP)mvff, NULL); res = WriteF(stream, depth, "} MVFF $P\n", (WriteFP)mvff, NULL);
return res; return res;

View file

@ -1,5 +1,5 @@
/* replay.c: Allocation replayer /* replay.c: Allocation replayer
* Copyright (c) 2001 Ravenbrook Limited. See end of file for license. * Copyright (c) 2001-2014 Ravenbrook Limited. See end of file for license.
* *
* $Id$ * $Id$
*/ */
@ -127,8 +127,10 @@ static void readLog(EventProc proc)
Res res; Res res;
res = EventRead(&event, proc); res = EventRead(&event, proc);
if (res == ResFAIL) break; /* eof */ if (res == ResFAIL)
if (res != ResOK) error("Truncated log"); break; /* eof */
if (res != ResOK)
error("Truncated log");
eventTime = event->any.clock; eventTime = event->any.clock;
EventRecord(proc, event, eventTime); EventRecord(proc, event, eventTime);
EventReplay(event, eventTime); EventReplay(event, eventTime);
@ -186,7 +188,7 @@ int main(int argc, char *argv[])
/* C. COPYRIGHT AND LICENSE /* C. COPYRIGHT AND LICENSE
* *
* Copyright (C) 2001-2002 Ravenbrook Limited <http://www.ravenbrook.com/>. * Copyright (C) 2001-2014 Ravenbrook Limited <http://www.ravenbrook.com/>.
* All rights reserved. This is an open source license. Contact * All rights reserved. This is an open source license. Contact
* Ravenbrook for commercial licensing options. * Ravenbrook for commercial licensing options.
* *

View file

@ -584,8 +584,10 @@ Res RootDescribe(Root root, mps_lib_FILE *stream, Count depth)
{ {
Res res; Res res;
if (!TESTT(Root, root)) return ResFAIL; if (!TESTT(Root, root))
if (stream == NULL) return ResFAIL; return ResFAIL;
if (stream == NULL)
return ResFAIL;
res = WriteF(stream, depth, res = WriteF(stream, depth,
"Root $P ($U) {\n", (WriteFP)root, (WriteFU)root->serial, "Root $P ($U) {\n", (WriteFP)root, (WriteFU)root->serial,
@ -608,7 +610,8 @@ Res RootDescribe(Root root, mps_lib_FILE *stream, Count depth)
root->pm & AccessREAD ? " READ" : "", root->pm & AccessREAD ? " READ" : "",
root->pm & AccessWRITE ? " WRITE" : "", root->pm & AccessWRITE ? " WRITE" : "",
NULL); NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
switch(root->var) { switch(root->var) {
case RootTABLE: case RootTABLE:
@ -617,7 +620,8 @@ Res RootDescribe(Root root, mps_lib_FILE *stream, Count depth)
(WriteFA)root->the.table.base, (WriteFA)root->the.table.base,
(WriteFA)root->the.table.limit, (WriteFA)root->the.table.limit,
NULL); NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
break; break;
case RootTABLE_MASKED: case RootTABLE_MASKED:
@ -627,7 +631,8 @@ Res RootDescribe(Root root, mps_lib_FILE *stream, Count depth)
(WriteFA)root->the.tableMasked.limit, (WriteFA)root->the.tableMasked.limit,
(WriteFB)root->the.tableMasked.mask, (WriteFB)root->the.tableMasked.mask,
NULL); NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
break; break;
case RootFUN: case RootFUN:
@ -636,7 +641,8 @@ Res RootDescribe(Root root, mps_lib_FILE *stream, Count depth)
"environment p $P s $W\n", "environment p $P s $W\n",
(WriteFP)root->the.fun.p, (WriteFW)root->the.fun.s, (WriteFP)root->the.fun.p, (WriteFW)root->the.fun.s,
NULL); NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
break; break;
case RootREG: case RootREG:
@ -644,7 +650,8 @@ Res RootDescribe(Root root, mps_lib_FILE *stream, Count depth)
"thread $P\n", (WriteFP)root->the.reg.thread, "thread $P\n", (WriteFP)root->the.reg.thread,
"environment p $P", (WriteFP)root->the.reg.p, "environment p $P", (WriteFP)root->the.reg.p,
NULL); NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
break; break;
case RootFMT: case RootFMT:
@ -653,7 +660,8 @@ Res RootDescribe(Root root, mps_lib_FILE *stream, Count depth)
"format base $A limit $A\n", "format base $A limit $A\n",
(WriteFA)root->the.fmt.base, (WriteFA)root->the.fmt.limit, (WriteFA)root->the.fmt.base, (WriteFA)root->the.fmt.limit,
NULL); NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
break; break;
default: default:
@ -663,7 +671,8 @@ Res RootDescribe(Root root, mps_lib_FILE *stream, Count depth)
res = WriteF(stream, depth, res = WriteF(stream, depth,
"} Root $P ($U)\n", (WriteFP)root, (WriteFU)root->serial, "} Root $P ($U)\n", (WriteFP)root, (WriteFU)root->serial,
NULL); NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
return ResOK; return ResOK;
} }
@ -679,7 +688,8 @@ Res RootsDescribe(Globals arenaGlobals, mps_lib_FILE *stream, Count depth)
RING_FOR(node, &arenaGlobals->rootRing, next) { RING_FOR(node, &arenaGlobals->rootRing, next) {
Root root = RING_ELT(Root, arenaRing, node); Root root = RING_ELT(Root, arenaRing, node);
res = RootDescribe(root, stream, depth); res = RootDescribe(root, stream, depth);
if (res != ResOK) return res; if (res != ResOK)
return res;
} }
return res; return res;
} }

View file

@ -52,13 +52,15 @@ static Bool SACCheck(SAC sac)
for (j = sac->middleIndex + 1, i = 0; j < sac->classesCount; ++j, i += 2) { for (j = sac->middleIndex + 1, i = 0; j < sac->classesCount; ++j, i += 2) {
CHECKL(prevSize < esac->_freelists[i]._size); CHECKL(prevSize < esac->_freelists[i]._size);
b = sacFreeListBlockCheck(&(esac->_freelists[i])); b = sacFreeListBlockCheck(&(esac->_freelists[i]));
if (!b) return b; if (!b)
return b;
prevSize = esac->_freelists[i]._size; prevSize = esac->_freelists[i]._size;
} }
/* check overlarge class */ /* check overlarge class */
CHECKL(prevSize < esac->_freelists[i]._size); CHECKL(prevSize < esac->_freelists[i]._size);
b = sacFreeListBlockCheck(&(esac->_freelists[i])); b = sacFreeListBlockCheck(&(esac->_freelists[i]));
if (!b) return b; if (!b)
return b;
CHECKL(esac->_freelists[i]._size == SizeMAX); CHECKL(esac->_freelists[i]._size == SizeMAX);
CHECKL(esac->_freelists[i]._count == 0); CHECKL(esac->_freelists[i]._count == 0);
CHECKL(esac->_freelists[i]._count_max == 0); CHECKL(esac->_freelists[i]._count_max == 0);
@ -68,7 +70,8 @@ static Bool SACCheck(SAC sac)
for (j = sac->middleIndex, i = 1; j > 0; --j, i += 2) { for (j = sac->middleIndex, i = 1; j > 0; --j, i += 2) {
CHECKL(prevSize > esac->_freelists[i]._size); CHECKL(prevSize > esac->_freelists[i]._size);
b = sacFreeListBlockCheck(&(esac->_freelists[i])); b = sacFreeListBlockCheck(&(esac->_freelists[i]));
if (!b) return b; if (!b)
return b;
prevSize = esac->_freelists[i]._size; prevSize = esac->_freelists[i]._size;
} }
/* check smallest class */ /* check smallest class */
@ -136,7 +139,8 @@ Res SACCreate(SAC *sacReturn, Pool pool, Count classesCount,
/* Find middle one */ /* Find middle one */
totalFreq /= 2; totalFreq /= 2;
for (i = 0; i < classesCount; ++i) { for (i = 0; i < classesCount; ++i) {
if (totalFreq < classes[i].mps_frequency) break; if (totalFreq < classes[i].mps_frequency)
break;
totalFreq -= classes[i].mps_frequency; totalFreq -= classes[i].mps_frequency;
} }
if (totalFreq <= classes[i].mps_frequency / 2) if (totalFreq <= classes[i].mps_frequency / 2)

View file

@ -96,7 +96,8 @@ static mps_res_t stress(mps_arena_t arena, mps_align_t align,
ps[j] = ps[i]; ss[j] = ss[i]; ps[j] = ps[i]; ss[j] = ss[i];
ps[i] = tp; ss[i] = ts; ps[i] = tp; ss[i] = ts;
} }
if (k == (testLOOPS / 2)) mps_sac_flush(sac); if (k == (testLOOPS / 2))
mps_sac_flush(sac);
/* free half of the objects */ /* free half of the objects */
/* upper half, as when allocating them again we want smaller objects */ /* upper half, as when allocating them again we want smaller objects */
/* see randomSize() */ /* see randomSize() */
@ -121,7 +122,8 @@ static mps_res_t stress(mps_arena_t arena, mps_align_t align,
res = mps_sac_alloc((mps_addr_t *)&ps[i], sac, ss[i], FALSE); res = mps_sac_alloc((mps_addr_t *)&ps[i], sac, ss[i], FALSE);
break; break;
} }
if (res != MPS_RES_OK) return res; if (res != MPS_RES_OK)
return res;
} }
} }

View file

@ -362,8 +362,10 @@ Res SegDescribe(Seg seg, mps_lib_FILE *stream, Count depth)
Res res; Res res;
Pool pool; Pool pool;
if (!TESTT(Seg, seg)) return ResFAIL; if (!TESTT(Seg, seg))
if (stream == NULL) return ResFAIL; return ResFAIL;
if (stream == NULL)
return ResFAIL;
pool = SegPool(seg); pool = SegPool(seg);
@ -395,13 +397,16 @@ Res SegDescribe(Seg seg, mps_lib_FILE *stream, Count depth)
BS_IS_MEMBER(seg->rankSet, RankFINAL) ? " FINAL" : "", BS_IS_MEMBER(seg->rankSet, RankFINAL) ? " FINAL" : "",
BS_IS_MEMBER(seg->rankSet, RankWEAK) ? " WEAK" : "", BS_IS_MEMBER(seg->rankSet, RankWEAK) ? " WEAK" : "",
NULL); NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
res = seg->class->describe(seg, stream, depth + 2); res = seg->class->describe(seg, stream, depth + 2);
if (res != ResOK) return res; if (res != ResOK)
return res;
res = WriteF(stream, 0, "\n", NULL); res = WriteF(stream, 0, "\n", NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
res = WriteF(stream, depth, "} Segment $P\n", (WriteFP)seg, NULL); res = WriteF(stream, depth, "} Segment $P\n", (WriteFP)seg, NULL);
return res; return res;
@ -1016,8 +1021,10 @@ static Res segTrivDescribe(Seg seg, mps_lib_FILE *stream, Count depth)
{ {
Res res; Res res;
if (!TESTT(Seg, seg)) return ResFAIL; if (!TESTT(Seg, seg))
if (stream == NULL) return ResFAIL; return ResFAIL;
if (stream == NULL)
return ResFAIL;
res = WriteF(stream, depth, res = WriteF(stream, depth,
"shield depth $U\n", (WriteFU)seg->depth, "shield depth $U\n", (WriteFU)seg->depth,
@ -1576,27 +1583,33 @@ static Res gcSegDescribe(Seg seg, mps_lib_FILE *stream, Count depth)
SegClass super; SegClass super;
GCSeg gcseg; GCSeg gcseg;
if (!TESTT(Seg, seg)) return ResFAIL; if (!TESTT(Seg, seg))
if (stream == NULL) return ResFAIL; return ResFAIL;
if (stream == NULL)
return ResFAIL;
gcseg = SegGCSeg(seg); gcseg = SegGCSeg(seg);
if (!TESTT(GCSeg, gcseg)) return ResFAIL; if (!TESTT(GCSeg, gcseg))
return ResFAIL;
/* Describe the superclass fields first via next-method call */ /* Describe the superclass fields first via next-method call */
super = SEG_SUPERCLASS(GCSegClass); super = SEG_SUPERCLASS(GCSegClass);
res = super->describe(seg, stream, depth); res = super->describe(seg, stream, depth);
if (res != ResOK) return res; if (res != ResOK)
return res;
res = WriteF(stream, depth, res = WriteF(stream, depth,
"summary $W\n", (WriteFW)gcseg->summary, "summary $W\n", (WriteFW)gcseg->summary,
NULL); NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
if (gcseg->buffer == NULL) { if (gcseg->buffer == NULL) {
res = WriteF(stream, depth, "buffer: NULL\n", NULL); res = WriteF(stream, depth, "buffer: NULL\n", NULL);
} else { } else {
res = BufferDescribe(gcseg->buffer, stream, depth); res = BufferDescribe(gcseg->buffer, stream, depth);
} }
if (res != ResOK) return res; if (res != ResOK)
return res;
return ResOK; return ResOK;
} }

View file

@ -1,7 +1,7 @@
/* shield.c: SHIELD IMPLEMENTATION /* shield.c: SHIELD IMPLEMENTATION
* *
* $Id$ * $Id$
* Copyright (c) 2001 Ravenbrook Limited. See end of file for license. * Copyright (c) 2001-2014 Ravenbrook Limited. See end of file for license.
* *
* See: idea.shield, design.mps.shield. * See: idea.shield, design.mps.shield.
* *
@ -133,7 +133,8 @@ static void flush(Arena arena, Size i)
AVER(i < arena->shCacheLimit); AVER(i < arena->shCacheLimit);
seg = arena->shCache[i]; seg = arena->shCache[i];
if (seg == NULL) return; if (seg == NULL)
return;
AVERT(Seg, seg); AVERT(Seg, seg);
AVER(arena->shDepth > 0); AVER(arena->shDepth > 0);
@ -157,7 +158,8 @@ static void cache(Arena arena, Seg seg)
AVERT_CRITICAL(Arena, arena); AVERT_CRITICAL(Arena, arena);
AVERT_CRITICAL(Seg, seg); AVERT_CRITICAL(Seg, seg);
if (SegSM(seg) == SegPM(seg)) return; if (SegSM(seg)
== SegPM(seg)) return;
if (SegDepth(seg) > 0) { if (SegDepth(seg) > 0) {
ShieldSuspend(arena); ShieldSuspend(arena);
return; return;
@ -334,7 +336,7 @@ void (ShieldCover)(Arena arena, Seg seg)
/* C. COPYRIGHT AND LICENSE /* C. COPYRIGHT AND LICENSE
* *
* Copyright (C) 2001-2002 Ravenbrook Limited <http://www.ravenbrook.com/>. * Copyright (C) 2001-2014 Ravenbrook Limited <http://www.ravenbrook.com/>.
* All rights reserved. This is an open source license. Contact * All rights reserved. This is an open source license. Contact
* Ravenbrook for commercial licensing options. * Ravenbrook for commercial licensing options.
* *

View file

@ -1024,34 +1024,44 @@ static Res SplayNodeDescribe(Tree node, mps_lib_FILE *stream,
{ {
Res res; Res res;
if (!TreeCheck(node)) return ResFAIL; if (!TreeCheck(node))
if (stream == NULL) return ResFAIL; return ResFAIL;
if (nodeDescribe == NULL) return ResFAIL; if (stream == NULL)
return ResFAIL;
if (nodeDescribe == NULL)
return ResFAIL;
res = WriteF(stream, 0, "( ", NULL); res = WriteF(stream, 0, "( ", NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
if (TreeHasLeft(node)) { if (TreeHasLeft(node)) {
res = SplayNodeDescribe(TreeLeft(node), stream, nodeDescribe); res = SplayNodeDescribe(TreeLeft(node), stream, nodeDescribe);
if (res != ResOK) return res; if (res != ResOK)
return res;
res = WriteF(stream, 0, " / ", NULL); res = WriteF(stream, 0, " / ", NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
} }
res = (*nodeDescribe)(node, stream); res = (*nodeDescribe)(node, stream);
if (res != ResOK) return res; if (res != ResOK)
return res;
if (TreeHasRight(node)) { if (TreeHasRight(node)) {
res = WriteF(stream, 0, " \\ ", NULL); res = WriteF(stream, 0, " \\ ", NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
res = SplayNodeDescribe(TreeRight(node), stream, nodeDescribe); res = SplayNodeDescribe(TreeRight(node), stream, nodeDescribe);
if (res != ResOK) return res; if (res != ResOK)
return res;
} }
res = WriteF(stream, 0, " )", NULL); res = WriteF(stream, 0, " )", NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
return ResOK; return ResOK;
} }
@ -1356,9 +1366,12 @@ Res SplayTreeDescribe(SplayTree splay, mps_lib_FILE *stream, Count depth,
{ {
Res res; Res res;
if (!TESTT(SplayTree, splay)) return ResFAIL; if (!TESTT(SplayTree, splay))
if (stream == NULL) return ResFAIL; return ResFAIL;
if (nodeDescribe == NULL) return ResFAIL; if (stream == NULL)
return ResFAIL;
if (nodeDescribe == NULL)
return ResFAIL;
res = WriteF(stream, depth, res = WriteF(stream, depth,
"Splay $P {\n", (WriteFP)splay, "Splay $P {\n", (WriteFP)splay,
@ -1366,13 +1379,16 @@ Res SplayTreeDescribe(SplayTree splay, mps_lib_FILE *stream, Count depth,
" nodeKey $F\n", (WriteFF)splay->nodeKey, " nodeKey $F\n", (WriteFF)splay->nodeKey,
" updateNode $F\n", (WriteFF)splay->updateNode, " updateNode $F\n", (WriteFF)splay->updateNode,
NULL); NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
if (SplayTreeRoot(splay) != TreeEMPTY) { if (SplayTreeRoot(splay) != TreeEMPTY) {
res = WriteF(stream, depth, " tree ", NULL); res = WriteF(stream, depth, " tree ", NULL);
if (res != ResOK) return res; if (res != ResOK)
return res;
res = SplayNodeDescribe(SplayTreeRoot(splay), stream, nodeDescribe); res = SplayNodeDescribe(SplayTreeRoot(splay), stream, nodeDescribe);
if (res != ResOK) return res; if (res != ResOK)
return res;
} }
res = WriteF(stream, depth, "\n} Splay $P\n", (WriteFP)splay, NULL); res = WriteF(stream, depth, "\n} Splay $P\n", (WriteFP)splay, NULL);

View file

@ -1,7 +1,7 @@
/* table.h: A dictionary mapping a Word to a void* /* table.h: A dictionary mapping a Word to a void*
* *
* $Id$ * $Id$
* Copyright (c) 2001 Ravenbrook Limited. See end of file for license. * Copyright (c) 2001-2014 Ravenbrook Limited. See end of file for license.
* *
* .note.good-hash: As is common in hash table implementations, we * .note.good-hash: As is common in hash table implementations, we
* assume that the hash function is good. * assume that the hash function is good.
@ -301,7 +301,8 @@ extern Res TableDefine(Table table, Word key, void *value)
if (table->count >= table->length * SPACEFRACTION) { if (table->count >= table->length * SPACEFRACTION) {
Res res = TableGrow(table, 1); Res res = TableGrow(table, 1);
if(res != ResOK) return res; if (res != ResOK)
return res;
entry = tableFind(table, key, FALSE /* no deletions yet */); entry = tableFind(table, key, FALSE /* no deletions yet */);
AVER(entry != NULL); AVER(entry != NULL);
if (entryIsActive(table, entry)) if (entryIsActive(table, entry))
@ -382,7 +383,7 @@ extern Count TableCount(Table table)
/* C. COPYRIGHT AND LICENSE /* C. COPYRIGHT AND LICENSE
* *
* Copyright (C) 2001-2002 Ravenbrook Limited <http://www.ravenbrook.com/>. * Copyright (C) 2001-2014 Ravenbrook Limited <http://www.ravenbrook.com/>.
* All rights reserved. This is an open source license. Contact * All rights reserved. This is an open source license. Contact
* Ravenbrook for commercial licensing options. * Ravenbrook for commercial licensing options.
* *

View file

@ -53,7 +53,8 @@ Res ThreadRegister(Thread *threadReturn, Arena arena)
res = ControlAlloc(&p, arena, sizeof(ThreadStruct), res = ControlAlloc(&p, arena, sizeof(ThreadStruct),
/* withReservoirPermit */ FALSE); /* withReservoirPermit */ FALSE);
if(res != ResOK) return res; if (res != ResOK)
return res;
thread = (Thread)p; thread = (Thread)p;
thread->arena = arena; thread->arena = arena;
@ -138,7 +139,8 @@ Res ThreadDescribe(Thread thread, mps_lib_FILE *stream, Count depth)
(WriteFP)thread->arena, (WriteFU)thread->arena->serial, (WriteFP)thread->arena, (WriteFU)thread->arena->serial,
"} Thread $P ($U)\n", (WriteFP)thread, (WriteFU)thread->serial, "} Thread $P ($U)\n", (WriteFP)thread, (WriteFU)thread->serial,
NULL); NULL);
if(res != ResOK) return res; if (res != ResOK)
return res;
return ResOK; return ResOK;
} }

View file

@ -69,7 +69,8 @@ Res ThreadRegister(Thread *threadReturn, Arena arena)
res = ControlAlloc(&p, arena, sizeof(ThreadStruct), res = ControlAlloc(&p, arena, sizeof(ThreadStruct),
/* withReservoirPermit */ FALSE); /* withReservoirPermit */ FALSE);
if(res != ResOK) return res; if (res != ResOK)
return res;
thread = (Thread)p; thread = (Thread)p;
thread->arena = arena; thread->arena = arena;
@ -259,7 +260,8 @@ Res ThreadDescribe(Thread thread, mps_lib_FILE *stream, Count depth)
" port $U\n", (WriteFU)thread->port, " port $U\n", (WriteFU)thread->port,
"} Thread $P ($U)\n", (WriteFP)thread, (WriteFU)thread->serial, "} Thread $P ($U)\n", (WriteFP)thread, (WriteFU)thread->serial,
NULL); NULL);
if(res != ResOK) return res; if (res != ResOK)
return res;
return ResOK; return ResOK;
} }

View file

@ -1440,7 +1440,8 @@ Res TraceScanArea(ScanState ss, Addr *base, Addr *limit)
TRACE_SCAN_BEGIN(ss) { TRACE_SCAN_BEGIN(ss) {
p = base; p = base;
loop: loop:
if(p >= limit) goto out; if (p >= limit)
goto out;
ref = *p++; ref = *p++;
if(!TRACE_FIX1(ss, ref)) if(!TRACE_FIX1(ss, ref))
goto loop; goto loop;
@ -1504,10 +1505,13 @@ Res TraceScanAreaMasked(ScanState ss, Addr *base, Addr *limit, Word mask)
TRACE_SCAN_BEGIN(ss) { TRACE_SCAN_BEGIN(ss) {
p = base; p = base;
loop: loop:
if(p >= limit) goto out; if (p >= limit)
goto out;
ref = *p++; ref = *p++;
if(((Word)ref & mask) != 0) goto loop; if (((Word)ref & mask)
if(!TRACE_FIX1(ss, ref)) goto loop; != 0) goto loop;
if (!TRACE_FIX1(ss, ref))
goto loop;
res = TRACE_FIX2(ss, p-1); res = TRACE_FIX2(ss, p-1);
if(res == ResOK) if(res == ResOK)
goto loop; goto loop;
@ -1916,8 +1920,10 @@ Res TraceDescribe(Trace trace, mps_lib_FILE *stream, Count depth)
Res res; Res res;
const char *state; const char *state;
if (!TESTT(Trace, trace)) return ResFAIL; if (!TESTT(Trace, trace))
if (stream == NULL) return ResFAIL; return ResFAIL;
if (stream == NULL)
return ResFAIL;
switch (trace->state) { switch (trace->state) {
case TraceINIT: state = "INIT"; break; case TraceINIT: state = "INIT"; break;

View file

@ -359,10 +359,13 @@ Res ChunkNodeDescribe(Tree node, mps_lib_FILE *stream)
{ {
Chunk chunk; Chunk chunk;
if (!TreeCheck(node)) return ResFAIL; if (!TreeCheck(node))
if (stream == NULL) return ResFAIL; return ResFAIL;
if (stream == NULL)
return ResFAIL;
chunk = ChunkOfTree(node); chunk = ChunkOfTree(node);
if (!TESTT(Chunk, chunk)) return ResFAIL; if (!TESTT(Chunk, chunk))
return ResFAIL;
return WriteF(stream, 0, "[$P,$P)", (WriteFP)chunk->base, return WriteF(stream, 0, "[$P,$P)", (WriteFP)chunk->base,
(WriteFP)chunk->limit, NULL); (WriteFP)chunk->limit, NULL);

View file

@ -205,7 +205,8 @@ static void get(mps_arena_t arena)
(ulongest_t)mclockEnd, (ulongest_t)(mclockEnd - mclockBegin)); (ulongest_t)mclockEnd, (ulongest_t)(mclockEnd - mclockBegin));
printf(" Coll End "); printf(" Coll End ");
showStatsText(notcon, con, live); showStatsText(notcon, con, live);
if(rnd()==0) showStatsAscii(notcon, con, live, alimit); if (rnd()==0)
showStatsAscii(notcon, con, live, alimit);
break; break;
} }
case mps_message_type_finalization(): { case mps_message_type_finalization(): {