diff --git a/mps/code/locus.c b/mps/code/locus.c index 5a6cb9b8395..140e1d9103c 100644 --- a/mps/code/locus.c +++ b/mps/code/locus.c @@ -107,7 +107,7 @@ Bool GenDescCheck(GenDesc gen) { CHECKS(GenDesc, gen); /* nothing to check for zones */ - /* nothing to check for capacity */ + CHECKL(gen->capacity > 0); CHECKL(gen->mortality >= 0.0); CHECKL(gen->mortality <= 1.0); CHECKD_NOSIG(Ring, &gen->locusRing); @@ -123,6 +123,7 @@ static Bool GenParamCheck(GenParamStruct *params) { CHECKL(params != NULL); CHECKL(params->capacity > 0); + CHECKL(params->capacity <= SizeMAX / 1024); CHECKL(params->mortality >= 0.0); CHECKL(params->mortality <= 1.0); return TRUE; @@ -139,7 +140,7 @@ static void GenDescInit(GenDesc gen, GenParamStruct *params) AVER(GenParamCheck(params)); gen->zones = ZoneSetEMPTY; - gen->capacity = params->capacity; + gen->capacity = params->capacity * 1024; gen->mortality = params->mortality; RingInit(&gen->locusRing); RingInit(&gen->segRing); @@ -162,7 +163,7 @@ static void GenDescFinish(GenDesc gen) gen->sig = SigInvalid; RingFinish(&gen->locusRing); RingFinish(&gen->segRing); - AVER(gen->activeTraces == TraceSetEMPTY); + AVER(gen->activeTraces == TraceSetEMPTY); /* */ for (ti = 0; ti < TraceLIMIT; ++ti) RingFinish(&gen->trace[ti].traceRing); } @@ -465,7 +466,7 @@ double ChainDeferral(Chain chain) GenDesc gen = &chain->gens[i]; if (gen->activeTraces != TraceSetEMPTY) return DBL_MAX; - genTime = gen->capacity * 1024.0 - (double)GenDescNewSize(&chain->gens[i]); + genTime = (double)gen->capacity - (double)GenDescNewSize(&chain->gens[i]); if (genTime < time) time = genTime; } @@ -864,7 +865,7 @@ void LocusInit(Arena arena) AVER(arena != NULL); /* not initialized yet. */ - params.capacity = 1; /* unused */ + params.capacity = 1; /* unused since top generation is not on any chain */ params.mortality = 0.5; GenDescInit(&arena->topGen, ¶ms); diff --git a/mps/code/locus.h b/mps/code/locus.h index 5525f242457..7c71a714dd1 100644 --- a/mps/code/locus.h +++ b/mps/code/locus.h @@ -43,7 +43,7 @@ typedef struct GenDescStruct *GenDesc; typedef struct GenDescStruct { Sig sig; ZoneSet zones; /* zoneset for this generation */ - Size capacity; /* capacity in kB */ + Size capacity; /* capacity in bytes */ double mortality; /* predicted mortality */ RingStruct locusRing; /* Ring of all PoolGen's in this GenDesc (locus) */ RingStruct segRing; /* Ring of GCSegs in this generation */ diff --git a/mps/code/mpmst.h b/mps/code/mpmst.h index ea6054bcdce..f68a7ce865f 100644 --- a/mps/code/mpmst.h +++ b/mps/code/mpmst.h @@ -434,7 +434,7 @@ typedef struct TraceStruct { Bool firstStretch; /* in first stretch of band (see accessor) */ SegFixMethod fix; /* fix method to apply to references */ void *fixClosure; /* see .ss.fix-closure */ - RingStruct genRing; /* ring of generations condemned by trace */ + RingStruct genRing; /* ring of generations condemned for trace */ STATISTIC_DECL(Size preTraceArenaReserved) /* ArenaReserved before this trace */ Size condemned; /* condemned bytes */ Size notCondemned; /* collectable but not condemned */ diff --git a/mps/code/policy.c b/mps/code/policy.c index eabb43d2e5d..34b5e3a9b54 100644 --- a/mps/code/policy.c +++ b/mps/code/policy.c @@ -229,7 +229,7 @@ static Res policyCondemnChain(double *mortalityReturn, Chain chain, Trace trace) -- topCondemnedGen; gen = &chain->gens[topCondemnedGen]; AVERT(GenDesc, gen); - if (GenDescNewSize(gen) >= gen->capacity * (Size)1024) + if (GenDescNewSize(gen) >= gen->capacity) break; } diff --git a/mps/manual/source/topic/error.rst b/mps/manual/source/topic/error.rst index 892a26b9bcf..e3df2352d7e 100644 --- a/mps/manual/source/topic/error.rst +++ b/mps/manual/source/topic/error.rst @@ -324,7 +324,7 @@ this documentation. :term:`stepper functions`. -``locus.c: chain->activeTraces == TraceSetEMPTY`` +``locus.c: gen->activeTraces == TraceSetEMPTY`` The client program called :c:func:`mps_chain_destroy`, but there was a garbage collection in progress on that chain. Park the arena