From 3f76b36cf4ebe168eae48b21c8a13e47b6b203b0 Mon Sep 17 00:00:00 2001 From: Richard Brooksby Date: Thu, 21 Apr 2016 15:24:51 +0100 Subject: [PATCH] Eliminating special case of amsinitinternal, since amst can now just use a standard next-method. Copied from Perforce Change: 191476 ServerID: perforce.ravenbrook.com --- mps/code/poolams.c | 40 ++++++++++------------------------------ mps/code/segsmss.c | 25 ++++--------------------- 2 files changed, 14 insertions(+), 51 deletions(-) diff --git a/mps/code/poolams.c b/mps/code/poolams.c index e281513229a..2cb2a79bfe1 100644 --- a/mps/code/poolams.c +++ b/mps/code/poolams.c @@ -784,6 +784,7 @@ static Res AMSInit(Pool pool, Arena arena, PoolClass klass, ArgList args) Bool supportAmbiguous = AMS_SUPPORT_AMBIGUOUS_DEFAULT; unsigned gen = AMS_GEN_DEFAULT; ArgStruct arg; + AMS ams; AVER(pool != NULL); AVERT(Arena, arena); @@ -801,45 +802,22 @@ static Res AMSInit(Pool pool, Arena arena, PoolClass klass, ArgList args) if (ArgPick(&arg, args, MPS_KEY_AMS_SUPPORT_AMBIGUOUS)) supportAmbiguous = arg.val.b; - /* .ambiguous.noshare: If the pool is required to support ambiguous */ - /* references, the alloc and white tables cannot be shared. */ - res = AMSInitInternal(PoolAMS(pool), arena, klass, - chain, gen, !supportAmbiguous, args); - if (res == ResOK) { - EVENT3(PoolInitAMS, pool, PoolArena(pool), pool->format); - } - return res; -} + AVERT(Chain, chain); + AVER(gen <= ChainGens(chain)); + AVER(chain->arena == arena); - -/* AMSInitInternal -- initialize an AMS pool, given the format and the chain */ - -Res AMSInitInternal(AMS ams, Arena arena, PoolClass klass, - Chain chain, unsigned gen, - Bool shareAllocTable, ArgList args) -{ - Pool pool; - Res res; - - /* Can't check ams, it's not initialized. */ - pool = AMSPool(ams); - - AVERT(Arena, arena); res = PoolAbsInit(pool, arena, klass, args); if (res != ResOK) goto failAbsInit; - AVER(ams == CouldBeA(AMSPool, pool)); - - - AVERT(Chain, chain); - AVER(gen <= ChainGens(chain)); - AVER(chain->arena == PoolArena(pool)); + ams = CouldBeA(AMSPool, pool); /* Ensure a format was supplied in the argument list. */ AVER(pool->format != NULL); pool->alignment = pool->format->alignment; ams->grainShift = SizeLog2(PoolAlignment(pool)); - ams->shareAllocTable = shareAllocTable; + /* .ambiguous.noshare: If the pool is required to support ambiguous */ + /* references, the alloc and white tables cannot be shared. */ + ams->shareAllocTable = !supportAmbiguous; ams->pgen = NULL; RingInit(&ams->segRing); @@ -859,6 +837,8 @@ Res AMSInitInternal(AMS ams, Arena arena, PoolClass klass, goto failGenInit; ams->pgen = &ams->pgenStruct; + EVENT3(PoolInitAMS, pool, PoolArena(pool), pool->format); + return ResOK; failGenInit: diff --git a/mps/code/segsmss.c b/mps/code/segsmss.c index 5055bf3b939..5e0e63d4510 100644 --- a/mps/code/segsmss.c +++ b/mps/code/segsmss.c @@ -314,31 +314,14 @@ static Res AMSTSegSizePolicy(Size *sizeReturn, static Res AMSTInit(Pool pool, Arena arena, PoolClass klass, ArgList args) { - AMST amst; AMS ams; - Chain chain; + AMST amst; + AMS ams; Res res; - unsigned gen = AMS_GEN_DEFAULT; - ArgStruct arg; - AVER(pool != NULL); - AVERT(Arena, arena); - AVERT(ArgList, args); - UNUSED(klass); /* used for debug pools only */ - - if (ArgPick(&arg, args, MPS_KEY_CHAIN)) - chain = arg.val.chain; - else { - chain = ArenaGlobals(arena)->defaultChain; - gen = 1; /* avoid the nursery of the default chain by default */ - } - if (ArgPick(&arg, args, MPS_KEY_GEN)) - gen = arg.val.u; - - /* FIXME: Generalise to next-method call */ - res = AMSInitInternal(PoolAMS(pool), arena, klass, - chain, gen, FALSE, args); + res = NextMethod(Pool, AMSTPool, init)(pool, arena, klass, args); if (res != ResOK) return res; + amst = CouldBeA(AMSTPool, pool); ams = MustBeA(AMSPool, pool);