1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 03:30:27 +02:00

add SCM_UNLIKELY to CHECK_UNDERFLOW

* libguile/vm-engine.h (CHECK_OVERFLOW, CHECK_UNDERFLOW): Add
  SCM_UNLIKELY blocks. Fix off-by-one error in CHECK_UNDERFLOW.
  (PRE_CHECK_UNDERFLOW): New macro, for checking underflow before
  accessing the current sp.
  (POP): Use PRE_CHECK_UNDERFLOW.
This commit is contained in:
Andy Wingo 2010-05-02 13:14:58 +02:00
parent 41e64dd73c
commit ba2d960396

View file

@ -259,17 +259,21 @@
#endif
#define CHECK_OVERFLOW() \
if (sp >= stack_limit) \
if (SCM_UNLIKELY (sp >= stack_limit)) \
goto vm_error_stack_overflow
#define CHECK_UNDERFLOW() \
if (sp < SCM_FRAME_UPPER_ADDRESS (fp)) \
if (SCM_UNLIKELY (sp <= SCM_FRAME_UPPER_ADDRESS (fp))) \
goto vm_error_stack_underflow;
#define PRE_CHECK_UNDERFLOW(N) \
if (SCM_UNLIKELY (sp - N <= SCM_FRAME_UPPER_ADDRESS (fp))) \
goto vm_error_stack_underflow;
#define PUSH(x) do { sp++; CHECK_OVERFLOW (); *sp = x; } while (0)
#define DROP() do { sp--; CHECK_UNDERFLOW (); NULLSTACK (1); } while (0)
#define DROPN(_n) do { sp -= (_n); CHECK_UNDERFLOW (); NULLSTACK (_n); } while (0)
#define POP(x) do { x = *sp; DROP (); } while (0)
#define DROPN(_n) do { sp -= (_n); CHECK_UNDERFLOW (); NULLSTACK (_n); } while (0)
#define POP(x) do { PRE_CHECK_UNDERFLOW (1); x = *sp--; NULLSTACK (1); } while (0)
/* A fast CONS. This has to be fast since its used, for instance, by
POP_LIST when fetching a function's argument list. Note: `scm_cell' is an