version 1.15, 2002/01/20 19:04:11
|
version 1.20, 2003/01/03 17:10:10
|
Line 92
|
Line 92
|
*/ |
*/ |
|
|
#ifdef DOUBLY_INDIRECT |
#ifdef DOUBLY_INDIRECT |
|
# ifndef DEBUG_DITC |
|
# define DEBUG_DITC 0 |
|
# endif |
|
/* define to 1 if you want to check consistency */ |
# define NEXT_P0 ({cfa=*ip;}) |
# define NEXT_P0 ({cfa=*ip;}) |
# define IP (ip) |
# define IP (ip) |
# define SET_IP(p) ({ip=(p); NEXT_P0;}) |
# define SET_IP(p) ({ip=(p); NEXT_P0;}) |
Line 99
|
Line 103
|
# define INC_IP(const_inc) ({cfa=IP[const_inc]; ip+=(const_inc);}) |
# define INC_IP(const_inc) ({cfa=IP[const_inc]; ip+=(const_inc);}) |
# define DEF_CA Label ca; |
# define DEF_CA Label ca; |
# define NEXT_P1 ({\ |
# define NEXT_P1 ({\ |
if (cfa<=vm_prims+DOESJUMP || cfa>=vm_prims+npriminfos) \ |
if (DEBUG_DITC && (cfa<=vm_prims+DOESJUMP || cfa>=vm_prims+npriminfos)) \ |
fprintf(stderr,"NEXT encountered prim %p at ip=%p\n", cfa, ip); \ |
fprintf(stderr,"NEXT encountered prim %p at ip=%p\n", cfa, ip); \ |
ip++; ca=**cfa;}) |
ip++; ca=**cfa;}) |
# define NEXT_P2 ({goto *ca;}) |
# define NEXT_P2 ({goto *ca;}) |
# define EXEC(XT) ({DEF_CA cfa=(XT);\ |
# define EXEC(XT) ({DEF_CA cfa=(XT);\ |
if (cfa>vm_prims+DOESJUMP && cfa<vm_prims+npriminfos) \ |
if (DEBUG_DITC && (cfa>vm_prims+DOESJUMP && cfa<vm_prims+npriminfos)) \ |
fprintf(stderr,"EXEC encountered xt %p at ip=%p, vm_prims=%p, xts=%p\n", cfa, ip, vm_prims, xts); \ |
fprintf(stderr,"EXEC encountered xt %p at ip=%p, vm_prims=%p, xts=%p\n", cfa, ip, vm_prims, xts); \ |
ca=**cfa; goto *ca;}) |
ca=**cfa; goto *ca;}) |
|
|
#else /* !defined(DOUBLY_INDIRECT) */ |
#elif defined(NO_IP) |
|
|
|
#define NEXT_P0 |
|
#define SET_IP(target) assert(0) |
|
#define INC_IP(n) ((void)0) |
|
#define DEF_CA |
|
#define NEXT_P1 |
|
#define NEXT_P2 ({goto *next_code;}) |
|
/* set next_code to the return address before performing EXEC */ |
|
#define EXEC(XT) ({cfa=(XT); goto **cfa;}) |
|
|
|
#else /* !defined(DOUBLY_INDIRECT) && !defined(NO_IP) */ |
|
|
#if defined(DIRECT_THREADED) |
#if defined(DIRECT_THREADED) |
|
|
|
/* This lets the compiler know that cfa is dead before; we place it at |
|
"goto *"s that perform direct threaded dispatch (i.e., not EXECUTE |
|
etc.), and thus do not reach doers, which would use cfa; the only |
|
way to a doer is through EXECUTE etc., which set the cfa |
|
themselves. |
|
|
|
Some of these direct threaded schemes use "cfa" to hold the code |
|
address in normal direct threaded code. Of course we cannot use |
|
KILLS there. |
|
|
|
KILLS works by having an empty asm instruction, and claiming to the |
|
compiler that it writes to cfa. |
|
|
|
KILLS is optional. You can write |
|
|
|
#define KILLS |
|
|
|
and lose just a little performance. |
|
*/ |
|
#define KILLS asm("":"=X"(cfa)); |
|
|
|
#ifndef THREADING_SCHEME |
|
#define THREADING_SCHEME 6 |
|
#endif |
|
|
#if THREADING_SCHEME==1 |
#if THREADING_SCHEME==1 |
#warning direct threading scheme 1: autoinc, long latency, cfa live |
#warning direct threading scheme 1: autoinc, long latency, cfa live |
# define NEXT_P0 ({cfa=*ip++;}) |
# define NEXT_P0 ({cfa=*ip++;}) |
Line 134
|
Line 174
|
# define INC_IP(const_inc) ({ ip+=(const_inc);}) |
# define INC_IP(const_inc) ({ ip+=(const_inc);}) |
# define DEF_CA |
# define DEF_CA |
# define NEXT_P1 |
# define NEXT_P1 |
# define NEXT_P2 ({goto **(ip-1);}) |
# define NEXT_P2 ({KILLS goto **(ip-1);}) |
# define EXEC(XT) ({cfa=(XT); goto **cfa;}) |
# define EXEC(XT) ({cfa=(XT); goto **cfa;}) |
#endif |
#endif |
|
|
Line 161
|
Line 201
|
# define INC_IP(const_inc) ({ ip+=(const_inc);}) |
# define INC_IP(const_inc) ({ ip+=(const_inc);}) |
# define DEF_CA |
# define DEF_CA |
# define NEXT_P1 |
# define NEXT_P1 |
# define NEXT_P2 ({goto **(ip++);}) |
# define NEXT_P2 ({KILLS goto **(ip++);}) |
# define EXEC(XT) ({cfa=(XT); goto **cfa;}) |
# define EXEC(XT) ({cfa=(XT); goto **cfa;}) |
#endif |
#endif |
|
|
Line 187
|
Line 227
|
# define INC_IP(const_inc) ({ip+=(const_inc);}) |
# define INC_IP(const_inc) ({ip+=(const_inc);}) |
# define DEF_CA |
# define DEF_CA |
# define NEXT_P1 (ip++) |
# define NEXT_P1 (ip++) |
# define NEXT_P2 ({goto **(ip-1);}) |
# define NEXT_P2 ({KILLS goto **(ip-1);}) |
# define EXEC(XT) ({cfa=(XT); goto **cfa;}) |
# define EXEC(XT) ({cfa=(XT); goto **cfa;}) |
#endif |
#endif |
|
|
Line 214
|
Line 254
|
# define INC_IP(const_inc) ({ ip+=(const_inc);}) |
# define INC_IP(const_inc) ({ ip+=(const_inc);}) |
# define DEF_CA |
# define DEF_CA |
# define NEXT_P1 (ip++) |
# define NEXT_P1 (ip++) |
# define NEXT_P2 ({goto **(ip-1);}) |
# define NEXT_P2 ({KILLS goto **(ip-1);}) |
# define EXEC(XT) ({cfa=(XT); goto **cfa;}) |
# define EXEC(XT) ({cfa=(XT); goto **cfa;}) |
#endif |
#endif |
|
|
Line 252
|
Line 292
|
#else |
#else |
/* indirect THREADED */ |
/* indirect THREADED */ |
|
|
|
#ifndef THREADING_SCHEME |
|
#define THREADING_SCHEME 6 |
|
#endif |
|
|
#if THREADING_SCHEME==1 |
#if THREADING_SCHEME==1 |
#warning indirect threading scheme 1: autoinc, long latency, cisc |
#warning indirect threading scheme 1: autoinc, long latency, cisc |
# define NEXT_P0 ({cfa=*ip++;}) |
# define NEXT_P0 ({cfa=*ip++;}) |
Line 361
|
Line 405
|
/* indirect threaded */ |
/* indirect threaded */ |
#endif |
#endif |
|
|
#endif /* !defined(DOUBLY_INDIRECT) */ |
#endif /* !defined(DOUBLY_INDIRECT) && !defined(NO_IP) */ |
|
|
#define NEXT ({DEF_CA NEXT_P1; NEXT_P2;}) |
#define NEXT ({DEF_CA NEXT_P1; NEXT_P2;}) |
#define IPTOS NEXT_INST |
#define IPTOS NEXT_INST |