From 0600810f7c3cc285befbdf797def8919c8dcea65 Mon Sep 17 00:00:00 2001 From: Pekka Pirinen Date: Fri, 17 Apr 1998 15:07:14 +0100 Subject: [PATCH] Speed up by removing some avers (160028) Copied from Perforce Change: 19424 ServerID: perforce.ravenbrook.com --- mps/src/pool.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/mps/src/pool.c b/mps/src/pool.c index f77ca086e98..c2d84eac59a 100644 --- a/mps/src/pool.c +++ b/mps/src/pool.c @@ -1,7 +1,7 @@ /* impl.c.pool: POOL IMPLEMENTATION * - * $HopeName: MMsrc!pool.c(trunk.48) $ - * Copyright (C) 1997 The Harlequin Group Limited. All rights reserved. + * $HopeName: MMsrc!pool.c(trunk.49) $ + * Copyright (C) 1997. Harlequin Group plc. All rights reserved. * * READERSHIP * @@ -37,7 +37,7 @@ #include "mpm.h" -SRCID(pool, "$HopeName: MMsrc!pool.c(trunk.48) $"); +SRCID(pool, "$HopeName: MMsrc!pool.c(trunk.49) $"); Bool PoolClassCheck(PoolClass class) @@ -251,6 +251,9 @@ void PoolDestroy(Pool pool) ArenaFree(arena, base, (Size)(class->size)); } + +/* PoolAlloc -- allocate a block of memory from a pool */ + Res PoolAlloc(Addr *pReturn, Pool pool, Size size) { Res res; @@ -265,25 +268,31 @@ Res PoolAlloc(Addr *pReturn, Pool pool, Size size) return res; /* Make sure that the allocated address was in the pool's memory. */ - AVER(PoolHasAddr(pool, *pReturn)); + /* .hasaddr.critical: The PoolHasAddr check is expensive, and in */ + /* allocation-bound programs this is on the critical path. */ + AVER_CRITICAL(PoolHasAddr(pool, *pReturn)); EVENT_PAW(PoolAlloc, pool, *pReturn, size); return ResOK; } + +/* PoolFree -- deallocate a block of memory allocated from the pool */ + void PoolFree(Pool pool, Addr old, Size size) { AVERT(Pool, pool); AVER((pool->class->attr & AttrFREE) != 0); AVER(old != NULL); - AVER(PoolHasAddr(pool, old)); + /* The pool methods should check that old is in pool. */ AVER(size > 0); (*pool->class->free)(pool, old, size); EVENT_PAW(PoolFree, pool, old, size); } + Res PoolTraceBegin(Pool pool, Trace trace) { AVERT(Pool, pool);