This is the mail archive of the guile@sources.redhat.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: debug evaluator is faster than regular one?


Keisuke Nishida <kxn30@po.cwru.edu> writes:

> cwitty@newtonlabs.com (Carl R. Witty) writes:
> 
> > The Hugs implementation of Haskell uses a bytecode interpreter that
> > uses "computed goto" when compiled with gcc and "switch" otherwise.
> > It does this with a few lines of preprocessor hacks; the main body of
> > the bytecode interpreter is shared between the two compilation
> > variants.  You might want to look how they do it.
> 
> Probably, something like the following definition is enough..
> 
> #ifdef __GNUC__
> #define START
> #define NEXT    goto *pc++;
> #define END
> #else
> #define START   start: switch (SCM_UNPACK (*pc++)) {
> #define NEXT    goto start;
> #define END     }
> #end

Here's the actual Hugs code.  You missed an equivalent for the Case()
macro.

#if     !DEBUG_CODE && HAVE_LABELS_AS_VALUES
#define Ins(x)          &&l##x
static  void *labs[] = { INSTRLIST };
#undef  Ins
#define Case(x)         l##x
#define Continue        goto *labs[(pc++)->instr]
#define Dispatch        Continue;
#define EndDispatch
#else
#if DEBUG_CODE
#define Dispatch        for (;;) {                                        \
                            if (debugCode) {                              \
                                Printf("%*s0x%04X: ", root, "", pc-memory);  \
                                dissInstr(pc-memory);                     \
                            }                                             \
                            switch((pc++)->instr) {
#else
#define Dispatch        for (;;) { switch((pc++)->instr) {
#endif
#define Case(x)         case x
#define Continue        continue
#define EndDispatch     default : internal("illegal instruction"); \
                                  break;                           \
                        }}
#endif


Carl Witty

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]