--- gforth/engine/threaded.h 2002/01/16 10:40:26 1.14 +++ gforth/engine/threaded.h 2002/11/24 13:54:02 1.16 @@ -91,12 +91,9 @@ */ -/* CFA_NEXT: if NEXT uses cfa, you have to #define CFA_NEXT, to get - * cfa declared in engine. - */ + #ifdef DOUBLY_INDIRECT -# define CFA_NEXT # define NEXT_P0 ({cfa=*ip;}) # define IP (ip) # define SET_IP(p) ({ip=(p); NEXT_P0;}) @@ -113,15 +110,23 @@ fprintf(stderr,"EXEC encountered xt %p at ip=%p, vm_prims=%p, xts=%p\n", cfa, ip, vm_prims, xts); \ ca=**cfa; goto *ca;}) -#else /* !defined(DOUBLY_INDIRECT) */ +#elif defined(NO_IP) -#if defined(DIRECT_THREADED) +#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;}) -/* note that the "cfa dead" versions only work if GETCFA exists and works */ +#else /* !defined(DOUBLY_INDIRECT) && !defined(NO_IP) */ + +#if defined(DIRECT_THREADED) #if THREADING_SCHEME==1 #warning direct threading scheme 1: autoinc, long latency, cfa live -# define CFA_NEXT # define NEXT_P0 ({cfa=*ip++;}) # define IP (ip-1) # define SET_IP(p) ({ip=(p); NEXT_P0;}) @@ -130,14 +135,11 @@ # define DEF_CA # define NEXT_P1 # define NEXT_P2 ({goto *cfa;}) -# define EXEC(XT) ({cfa=(XT); goto *cfa;}) +# define EXEC(XT) ({cfa=(XT); goto **cfa;}) #endif #if THREADING_SCHEME==2 #warning direct threading scheme 2: autoinc, long latency, cfa dead -#ifndef GETCFA -#error GETCFA must be defined for cfa dead threading -#endif # define NEXT_P0 (ip++) # define IP (ip-1) # define SET_IP(p) ({ip=(p); NEXT_P0;}) @@ -146,13 +148,12 @@ # define DEF_CA # define NEXT_P1 # define NEXT_P2 ({goto **(ip-1);}) -# define EXEC(XT) ({goto *(XT);}) +# define EXEC(XT) ({cfa=(XT); goto **cfa;}) #endif #if THREADING_SCHEME==3 #warning direct threading scheme 3: autoinc, low latency, cfa live -# define CFA_NEXT # define NEXT_P0 # define IP (ip) # define SET_IP(p) ({ip=(p); NEXT_P0;}) @@ -161,14 +162,11 @@ # define DEF_CA # define NEXT_P1 ({cfa=*ip++;}) # define NEXT_P2 ({goto *cfa;}) -# define EXEC(XT) ({cfa=(XT); goto *cfa;}) +# define EXEC(XT) ({cfa=(XT); goto **cfa;}) #endif #if THREADING_SCHEME==4 #warning direct threading scheme 4: autoinc, low latency, cfa dead -#ifndef GETCFA -#error GETCFA must be defined for cfa dead threading -#endif # define NEXT_P0 # define IP (ip) # define SET_IP(p) ({ip=(p); NEXT_P0;}) @@ -177,12 +175,11 @@ # define DEF_CA # define NEXT_P1 # define NEXT_P2 ({goto **(ip++);}) -# define EXEC(XT) ({goto *(XT);}) +# define EXEC(XT) ({cfa=(XT); goto **cfa;}) #endif #if THREADING_SCHEME==5 #warning direct threading scheme 5: long latency, cfa live -# define CFA_NEXT # define NEXT_P0 ({cfa=*ip;}) # define IP (ip) # define SET_IP(p) ({ip=(p); NEXT_P0;}) @@ -191,14 +188,11 @@ # define DEF_CA # define NEXT_P1 (ip++) # define NEXT_P2 ({goto *cfa;}) -# define EXEC(XT) ({cfa=(XT); goto *cfa;}) +# define EXEC(XT) ({cfa=(XT); goto **cfa;}) #endif #if THREADING_SCHEME==6 #warning direct threading scheme 6: long latency, cfa dead -#ifndef GETCFA -#error GETCFA must be defined for cfa dead threading -#endif # define NEXT_P0 # define IP (ip) # define SET_IP(p) ({ip=(p); NEXT_P0;}) @@ -207,13 +201,12 @@ # define DEF_CA # define NEXT_P1 (ip++) # define NEXT_P2 ({goto **(ip-1);}) -# define EXEC(XT) ({goto *(XT);}) +# define EXEC(XT) ({cfa=(XT); goto **cfa;}) #endif #if THREADING_SCHEME==7 #warning direct threading scheme 7: low latency, cfa live -# define CFA_NEXT # define NEXT_P0 # define IP (ip) # define SET_IP(p) ({ip=(p); NEXT_P0;}) @@ -222,14 +215,11 @@ # define DEF_CA # define NEXT_P1 ({cfa=*ip++;}) # define NEXT_P2 ({goto *cfa;}) -# define EXEC(XT) ({cfa=(XT); goto *cfa;}) +# define EXEC(XT) ({cfa=(XT); goto **cfa;}) #endif #if THREADING_SCHEME==8 #warning direct threading scheme 8: cfa dead, i386 hack -#ifndef GETCFA -#error GETCFA must be defined for cfa dead threading -#endif # define NEXT_P0 # define IP (ip) # define SET_IP(p) ({ip=(p); NEXT_P0;}) @@ -238,7 +228,7 @@ # define DEF_CA # define NEXT_P1 (ip++) # define NEXT_P2 ({goto **(ip-1);}) -# define EXEC(XT) ({goto *(XT);}) +# define EXEC(XT) ({cfa=(XT); goto **cfa;}) #endif #if THREADING_SCHEME==9 @@ -246,7 +236,6 @@ /* Power uses a prepare-to-branch instruction, and the latency between this inst and the branch is 5 cycles on a PPC604; so we utilize this to do some prefetching in between */ -# define CFA_NEXT # define NEXT_P0 # define IP ip # define SET_IP(p) ({ip=(p); next_cfa=*ip; NEXT_P0;}) @@ -255,13 +244,12 @@ # define DEF_CA # define NEXT_P1 ({cfa=next_cfa; ip++; next_cfa=*ip;}) # define NEXT_P2 ({goto *cfa;}) -# define EXEC(XT) ({cfa=(XT); goto *cfa;}) +# define EXEC(XT) ({cfa=(XT); goto **cfa;}) # define MORE_VARS Xt next_cfa; #endif #if THREADING_SCHEME==10 #warning direct threading scheme 10: plain (no attempt at scheduling) -# define CFA_NEXT # define NEXT_P0 # define IP (ip) # define SET_IP(p) ({ip=(p); NEXT_P0;}) @@ -270,7 +258,7 @@ # define DEF_CA # define NEXT_P1 # define NEXT_P2 ({cfa=*ip++; goto *cfa;}) -# define EXEC(XT) ({cfa=(XT); goto *cfa;}) +# define EXEC(XT) ({cfa=(XT); goto **cfa;}) #endif /* direct threaded */ @@ -279,7 +267,6 @@ #if THREADING_SCHEME==1 #warning indirect threading scheme 1: autoinc, long latency, cisc -# define CFA_NEXT # define NEXT_P0 ({cfa=*ip++;}) # define IP (ip-1) # define SET_IP(p) ({ip=(p); NEXT_P0;}) @@ -293,7 +280,6 @@ #if THREADING_SCHEME==2 #warning indirect threading scheme 2: autoinc, long latency -# define CFA_NEXT # define NEXT_P0 ({cfa=*ip++;}) # define IP (ip-1) # define SET_IP(p) ({ip=(p); NEXT_P0;}) @@ -308,7 +294,6 @@ #if THREADING_SCHEME==3 #warning indirect threading scheme 3: autoinc, low latency, cisc -# define CFA_NEXT # define NEXT_P0 # define IP (ip) # define SET_IP(p) ({ip=(p); NEXT_P0;}) @@ -322,7 +307,6 @@ #if THREADING_SCHEME==4 #warning indirect threading scheme 4: autoinc, low latency -# define CFA_NEXT # define NEXT_P0 ({cfa=*ip++;}) # define IP (ip-1) # define SET_IP(p) ({ip=(p); NEXT_P0;}) @@ -337,7 +321,6 @@ #if THREADING_SCHEME==5 #warning indirect threading scheme 5: long latency, cisc -# define CFA_NEXT # define NEXT_P0 ({cfa=*ip;}) # define IP (ip) # define SET_IP(p) ({ip=(p); NEXT_P0;}) @@ -351,7 +334,6 @@ #if THREADING_SCHEME==6 #warning indirect threading scheme 6: long latency -# define CFA_NEXT # define NEXT_P0 ({cfa=*ip;}) # define IP (ip) # define SET_IP(p) ({ip=(p); NEXT_P0;}) @@ -365,7 +347,6 @@ #if THREADING_SCHEME==7 #warning indirect threading scheme 7: low latency -# define CFA_NEXT # define NEXT_P0 ({cfa=*ip;}) # define IP (ip) # define SET_IP(p) ({ip=(p); NEXT_P0;}) @@ -379,7 +360,6 @@ #if THREADING_SCHEME==8 #warning indirect threading scheme 8: low latency,cisc -# define CFA_NEXT # define NEXT_P0 # define IP (ip) # define SET_IP(p) ({ip=(p); NEXT_P0;}) @@ -394,7 +374,7 @@ /* indirect threaded */ #endif -#endif /* !defined(DOUBLY_INDIRECT) */ +#endif /* !defined(DOUBLY_INDIRECT) && !defined(NO_IP) */ #define NEXT ({DEF_CA NEXT_P1; NEXT_P2;}) #define IPTOS NEXT_INST