From ef62affc6d31f42456673b04558460baffaa8dd2 Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Thu, 3 Sep 2015 15:35:38 +0100 Subject: [PATCH] Move the clearing of the emergency flag down into tracedestroy{init,finish}. Copied from Perforce Change: 188216 ServerID: perforce.ravenbrook.com --- mps/code/policy.c | 3 --- mps/code/trace.c | 15 +++++++-------- mps/code/traceanc.c | 7 +++---- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/mps/code/policy.c b/mps/code/policy.c index ff570e4899b..3cba467a2c7 100644 --- a/mps/code/policy.c +++ b/mps/code/policy.c @@ -259,9 +259,6 @@ Bool PolicyStartTrace(Trace *traceReturn, Arena arena) failCondemn: TraceDestroyInit(trace); - /* This is an unlikely case, but clear the emergency flag so the next attempt - starts normally. */ - ArenaSetEmergency(arena, FALSE); failStart: return FALSE; } diff --git a/mps/code/trace.c b/mps/code/trace.c index d34d953bf40..5786c677a51 100644 --- a/mps/code/trace.c +++ b/mps/code/trace.c @@ -771,6 +771,9 @@ void TraceDestroyInit(Trace trace) trace->sig = SigInvalid; trace->arena->busyTraces = TraceSetDel(trace->arena->busyTraces, trace); + + /* Clear the emergency flag so the next trace starts normally. */ + ArenaSetEmergency(trace->arena, FALSE); } @@ -828,6 +831,9 @@ void TraceDestroyFinished(Trace trace) trace->sig = SigInvalid; trace->arena->busyTraces = TraceSetDel(trace->arena->busyTraces, trace); trace->arena->flippedTraces = TraceSetDel(trace->arena->flippedTraces, trace); + + /* Hopefully the trace reclaimed some memory, so clear any emergency. */ + ArenaSetEmergency(trace->arena, FALSE); } @@ -1833,9 +1839,6 @@ failStart: NOTREACHED; failCondemn: TraceDestroyInit(trace); - /* We don't know how long it'll be before another collection. Make sure - the next one starts in normal mode. */ - ArenaSetEmergency(arena, FALSE); return res; } @@ -1873,12 +1876,8 @@ Work TracePoll(Globals globals) newWork = traceWork(trace); AVER(newWork >= oldWork); work = newWork - oldWork; - if (trace->state == TraceFINISHED) { + if (trace->state == TraceFINISHED) TraceDestroyFinished(trace); - /* A trace finished, and hopefully reclaimed some memory, so clear any - * emergency. */ - ArenaSetEmergency(arena, FALSE); - } return work; } diff --git a/mps/code/traceanc.c b/mps/code/traceanc.c index c3743b6dc29..e60f8ffcdb3 100644 --- a/mps/code/traceanc.c +++ b/mps/code/traceanc.c @@ -591,10 +591,9 @@ void ArenaPark(Globals globals) } ArenaAccumulateTime(arena, start); - - /* Clear any emergency flag so that the next collection starts normally. - Any traces that have been finished may have reclaimed memory. */ - ArenaSetEmergency(arena, FALSE); + + /* All traces have finished so there must not be an emergency. */ + AVER(!ArenaEmergency(arena)); } /* ArenaStartCollect -- start a collection of everything in the