mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-17 08:31:09 -08:00
Change.dylan.box-turtle.170551, speeding up aver
Copied from Perforce Change: 19352 ServerID: perforce.ravenbrook.com
This commit is contained in:
parent
44b8935f1e
commit
45e64dd7bd
3 changed files with 64 additions and 33 deletions
|
|
@ -1,16 +1,16 @@
|
|||
/* impl.c.assert: ASSERTION IMPLEMENTATION
|
||||
*
|
||||
* $HopeName: MMsrc!assert.c(trunk.7) $
|
||||
* $HopeName: MMsrc!assert.c(trunk.8) $
|
||||
*
|
||||
* This source provides the AssertFail function which is
|
||||
* invoked by the assertion macros (see impl.h.assert).
|
||||
* It also provides for user-installed assertion failure handlers.
|
||||
*
|
||||
* Notes
|
||||
*
|
||||
* 3. To be really solid, assert should write the information into a
|
||||
* buffer before reaching the handler, so that it can be recovered
|
||||
* even if printing fails. richard 1994-11-15
|
||||
* NOTES
|
||||
*
|
||||
* .note.assert-buffer: The Assertion Buffer is not used. In the future
|
||||
* we probably ought to use it. (see .buffer.* below)
|
||||
*/
|
||||
|
||||
#include "mpm.h"
|
||||
|
|
@ -24,6 +24,20 @@
|
|||
|
||||
Word CheckLevel = CheckSHALLOW;
|
||||
|
||||
|
||||
/* Assertion buffer
|
||||
*
|
||||
* .buffer.purpose: the assertion buffer serves two purposes:
|
||||
* .buffer.purpose.modify: assertion strings are picked apart and
|
||||
* modified before being passed to assertion handlers, this
|
||||
* buffer is used to do that.
|
||||
* .buffer.purpose.store: Debuggers, post-mortem dumps, etc, can retrieve the
|
||||
* assertion text even if for some reason printing the text out failed.
|
||||
* [note this is not used, see .note.buffer]
|
||||
*/
|
||||
|
||||
char AssertBuffer[ASSERT_BUFFER_SIZE];
|
||||
|
||||
static void AssertLib(const char *cond, const char *id,
|
||||
const char *file, unsigned line)
|
||||
{
|
||||
|
|
@ -63,9 +77,8 @@ AssertHandler AssertInstall(AssertHandler new)
|
|||
* handler returns the progam continues.
|
||||
*/
|
||||
|
||||
void AssertFail(const char *cond, const char *id,
|
||||
const char *file, unsigned line)
|
||||
void AssertFail1(const char *s)
|
||||
{
|
||||
if(handler != NULL)
|
||||
(*handler)(cond, id, file, line);
|
||||
(*handler)(s, "", "", 0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* impl.h.check: ASSERTION INTERFACE
|
||||
*
|
||||
* $HopeName: MMsrc!check.h(trunk.8) $
|
||||
* $HopeName: MMsrc!check.h(trunk.9) $
|
||||
*
|
||||
* This header defines a family of AVER and NOTREACHED macros. The
|
||||
* macros should be used to instrument and annotate code with
|
||||
|
|
@ -38,17 +38,20 @@
|
|||
|
||||
#elif defined(MPS_HOT_RED)
|
||||
|
||||
#define AVER(cond) ASSERT(cond)
|
||||
#define AVERT(type, val) ASSERT(type ## Check(val))
|
||||
#define AVER(cond) ASSERT(cond, #cond)
|
||||
#define AVERT(type, val) ASSERT(type ## Check(val), \
|
||||
"TypeCheck " #type ": " #val)
|
||||
#define AVER_CRITICAL(cond) NOCHECK(cond)
|
||||
#define AVERT_CRITICAL(type, val) NOCHECK(type ## Check(val))
|
||||
|
||||
#elif defined(MPS_COOL)
|
||||
|
||||
#define AVER(cond) ASSERT(cond)
|
||||
#define AVERT(type, val) ASSERT(type ## Check(val))
|
||||
#define AVER_CRITICAL(cond) ASSERT(cond)
|
||||
#define AVERT_CRITICAL(type, val) ASSERT(type ## Check(val))
|
||||
#define AVER(cond) ASSERT(cond, #cond)
|
||||
#define AVERT(type, val) ASSERT(type ## Check(val), \
|
||||
"TypeCheck " #type ": " #val)
|
||||
#define AVER_CRITICAL(cond) ASSERT(cond, #cond)
|
||||
#define AVERT_CRITICAL(type, val) ASSERT(type ## Check(val), \
|
||||
"TypeCheck " #type ": " #val)
|
||||
|
||||
#else
|
||||
|
||||
|
|
@ -61,14 +64,20 @@ typedef void (*AssertHandler)(const char *cond, const char *id,
|
|||
extern AssertHandler AssertInstall(AssertHandler handler);
|
||||
extern AssertHandler AssertDefault(void);
|
||||
|
||||
extern void AssertFail(const char *cond, const char *id,
|
||||
const char *file, unsigned line);
|
||||
extern void AssertFail1(const char *s);
|
||||
|
||||
#define ASSERT(cond) \
|
||||
/* STR(x) expands into a string of the expansion of x. */
|
||||
/* Eg, if we have: */
|
||||
/* #define a b */
|
||||
/* STR(a) will expand into "b". */
|
||||
/* @@@@ really STR belongs in some generic support file. */
|
||||
#define STR_(x) #x
|
||||
#define STR(x) STR_(x)
|
||||
|
||||
#define ASSERT(cond, condstring) \
|
||||
BEGIN \
|
||||
if(cond) NOOP; else \
|
||||
AssertFail(#cond, FileSrcIdStruct.hopename, \
|
||||
FileSrcIdStruct.file, __LINE__); \
|
||||
AssertFail1(condstring "\n" __FILE__ "\n" STR(__LINE__)); \
|
||||
END
|
||||
|
||||
|
||||
|
|
@ -80,16 +89,13 @@ extern void AssertFail(const char *cond, const char *id,
|
|||
|
||||
#define NOTREACHED \
|
||||
BEGIN \
|
||||
AssertFail("unreachable statement", \
|
||||
FileSrcIdStruct.hopename, FileSrcIdStruct.file, \
|
||||
__LINE__); \
|
||||
AssertFail1("unreachable statement" "\n" __FILE__ "\n" STR(__LINE__)); \
|
||||
END
|
||||
|
||||
#define CHECKC(cond) \
|
||||
#define CHECKC(cond, condstring) \
|
||||
BEGIN \
|
||||
if(cond) NOOP; else \
|
||||
AssertFail(#cond, FileSrcIdStruct.hopename, \
|
||||
FileSrcIdStruct.file, __LINE__); \
|
||||
AssertFail1(condstring "\n" __FILE__ "\n" STR(__LINE__)); \
|
||||
END
|
||||
|
||||
|
||||
|
|
@ -122,7 +128,8 @@ extern void AssertFail(const char *cond, const char *id,
|
|||
#elif defined(MPS_HOT_RED)
|
||||
|
||||
/* CHECKS -- Check Signature */
|
||||
#define CHECKS(type, val) CHECKC(CHECKT(type, val))
|
||||
#define CHECKS(type, val) CHECKC(CHECKT(type, val), \
|
||||
"SigCheck " #type ": " #val)
|
||||
|
||||
#define CHECKL(cond) NOCHECK(cond)
|
||||
#define CHECKD(type, val) NOCHECK(CHECKT(type, val))
|
||||
|
|
@ -131,7 +138,8 @@ extern void AssertFail(const char *cond, const char *id,
|
|||
#elif defined(MPS_COOL)
|
||||
|
||||
/* CHECKS -- Check Signature */
|
||||
#define CHECKS(type, val) CHECKC(CHECKT(type, val))
|
||||
#define CHECKS(type, val) CHECKC(CHECKT(type, val), \
|
||||
"SigCheck " #type ": " #val)
|
||||
|
||||
/* CHECKL -- Check Local Invariant */
|
||||
/* Could make this an expression using ?: */
|
||||
|
|
@ -143,7 +151,7 @@ extern void AssertFail(const char *cond, const char *id,
|
|||
break; \
|
||||
case CheckSHALLOW: \
|
||||
case CheckDEEP: \
|
||||
CHECKC(cond); \
|
||||
CHECKC(cond, #cond); \
|
||||
break; \
|
||||
default: \
|
||||
NOTREACHED; \
|
||||
|
|
@ -159,10 +167,12 @@ extern void AssertFail(const char *cond, const char *id,
|
|||
NOOP; \
|
||||
break; \
|
||||
case CheckSHALLOW: \
|
||||
CHECKC(CHECKT(type, val)); \
|
||||
CHECKC(CHECKT(type, val), \
|
||||
"SigCheck " #type ": " #val); \
|
||||
break; \
|
||||
case CheckDEEP: \
|
||||
CHECKC(type ## Check(val)); \
|
||||
CHECKC(type ## Check(val), \
|
||||
"TypeCheck " #type ": " #val); \
|
||||
break; \
|
||||
default: \
|
||||
NOTREACHED; \
|
||||
|
|
@ -179,7 +189,8 @@ extern void AssertFail(const char *cond, const char *id,
|
|||
break; \
|
||||
case CheckSHALLOW: \
|
||||
case CheckDEEP: \
|
||||
CHECKC(CHECKT(type, val)); \
|
||||
CHECKC(CHECKT(type, val), \
|
||||
"SigCheck " #type ": " #val); \
|
||||
break; \
|
||||
default: \
|
||||
NOTREACHED; \
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/* impl.h.config: MPS CONFIGURATION
|
||||
*
|
||||
* Copyright (C) 1997, 1998 Harlequin Group, all rights reserved.
|
||||
* $HopeName: MMsrc!config.h(trunk.20) $
|
||||
* $HopeName: MMsrc!config.h(trunk.21) $
|
||||
*
|
||||
* .readership: MPS developers.
|
||||
*/
|
||||
|
|
@ -210,6 +210,13 @@
|
|||
#define EVENT_HEADER_SIZE ((Count)3)
|
||||
|
||||
|
||||
/* Assert Buffer
|
||||
*
|
||||
* The Assert Buffer lives in assert.c */
|
||||
|
||||
#define ASSERT_BUFFER_SIZE ((Size)512)
|
||||
|
||||
|
||||
/* memcpy configuration
|
||||
*
|
||||
* PoolClass AMC requires an efficient memcpy routine.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue