Annotation of gforth/engine/threaded.h, revision 1.32

1.1       anton       1: /* This file defines a number of threading schemes.
                      2: 
1.27      anton       3:   Copyright (C) 1995, 1996,1997,1999,2003,2004 Free Software Foundation, Inc.
1.1       anton       4: 
                      5:   This file is part of Gforth.
                      6: 
                      7:   Gforth is free software; you can redistribute it and/or
                      8:   modify it under the terms of the GNU General Public License
                      9:   as published by the Free Software Foundation; either version 2
                     10:   of the License, or (at your option) any later version.
                     11: 
                     12:   This program is distributed in the hope that it will be useful,
                     13:   but WITHOUT ANY WARRANTY; without even the implied warranty of
                     14:   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     15:   GNU General Public License for more details.
                     16: 
                     17:   You should have received a copy of the GNU General Public License
                     18:   along with this program; if not, write to the Free Software
1.7       anton      19:   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
1.1       anton      20: 
                     21: 
                     22:   This files defines macros for threading. Many sets of macros are
                     23:   defined. Functionally they have only one difference: Some implement
                     24:   direct threading, some indirect threading. The other differences are
                     25:   just variations to help GCC generate faster code for various
                     26:   machines.
                     27: 
                     28:   (Well, to tell the truth, there actually is another functional
                     29:   difference in some pathological cases: e.g., a '!' stores into the
                     30:   cell where the next executed word comes from; or, the next word
                     31:   executed comes from the top-of-stack. These differences are one of
                     32:   the reasons why GCC cannot produce the right variation by itself. We
                     33:   chose disallowing such practices and using the added implementation
                     34:   freedom to achieve a significant speedup, because these practices
                     35:   are not common in Forth (I have never heard of or seen anyone using
                     36:   them), and it is easy to circumvent problems: A control flow change
                     37:   will flush any prefetched words; you may want to do a "0
                     38:   drop" before that to write back the top-of-stack cache.)
                     39: 
                     40:   These macro sets are used in the following ways: After translation
                     41:   to C a typical primitive looks like
                     42: 
                     43:   ...
                     44:   {
                     45:   DEF_CA
                     46:   other declarations
                     47:   NEXT_P0;
                     48:   main part of the primitive
                     49:   NEXT_P1;
                     50:   store results to stack
                     51:   NEXT_P2;
                     52:   }
                     53: 
                     54:   DEF_CA and all the NEXT_P* together must implement NEXT; In the main
                     55:   part the instruction pointer can be read with IP, changed with
                     56:   INC_IP(const_inc), and the cell right behind the presently executing
                     57:   word (i.e. the value of *IP) is accessed with NEXT_INST.
                     58: 
                     59:   If a primitive does not fall through the main part, it has to do the
                     60:   rest by itself. If it changes ip, it has to redo NEXT_P0 (perhaps we
                     61:   should define a macro SET_IP).
                     62: 
                     63:   Some primitives (execute, dodefer) do not end with NEXT, but with
                     64:   EXEC(.). If NEXT_P0 has been called earlier, it has to perform
                     65:   "ip=IP;" to ensure that ip has the right value (NEXT_P0 may change
                     66:   it).
                     67: 
                     68:   Finally, there is NEXT1_P1 and NEXT1_P2, which are parts of EXEC
                     69:   (EXEC(XT) could be defined as "cfa=XT; NEXT1_P1; NEXT1_P2;" (is this
                     70:   true?)) and are used for making docol faster.
                     71: 
                     72:   We can define the ways in which these macros are used with a regular
                     73:   expression:
                     74: 
                     75:   For a primitive
                     76: 
                     77:   DEF_CA NEXT_P0 ( IP | INC_IP | NEXT_INST | ip=...; NEXT_P0 ) * ( NEXT_P1 NEXT_P2 | EXEC(...) )
                     78: 
                     79:   For a run-time routine, e.g., docol:
                     80:   PFA1(cfa) ( NEXT_P0 NEXT | cfa=...; NEXT1_P1; NEXT1_P2 | EXEC(...) )
                     81: 
                     82:   This comment does not yet describe all the dependences that the
                     83:   macros have to satisfy.
                     84: 
                     85:   To organize the former ifdef chaos, each path is separated
                     86:   This gives a quite impressive number of paths, but you clearly
                     87:   find things that go together.
                     88: 
                     89:   It should be possible to organize the whole thing in a way that
                     90:   contains less redundancy and allows a simpler description.
                     91: 
                     92: */
                     93: 
1.29      anton      94: #ifdef GCC_PR15242_WORKAROUND
                     95: #define DO_GOTO goto before_goto
                     96: #else
                     97: #define DO_GOTO goto *real_ca
                     98: #endif
1.30      pazsan     99: #ifndef GOTO_ALIGN
                    100: #define GOTO_ALIGN
                    101: #endif
1.29      anton     102: 
1.28      anton     103: #define GOTO(target) do {(real_ca=(target));} while(0)
                    104: #define NEXT_P2 do {NEXT_P1_5; DO_GOTO;} while(0)
1.32    ! anton     105: #define EXEC(XT) do { real_ca=EXEC1(XT); DO_GOTO;} while (0)
        !           106: #define VM_JUMP(target) do {GOTO(target); DO_GOTO;} while (0)
1.28      anton     107: #define NEXT do {DEF_CA NEXT_P1; NEXT_P2;} while(0)
1.30      pazsan    108: #define FIRST_NEXT_P2 NEXT_P1_5; GOTO_ALIGN; \
                    109: before_goto: goto *real_ca; after_goto:
1.31      anton     110: #define FIRST_NEXT do {DEF_CA NEXT_P1; FIRST_NEXT_P2;} while(0)
1.28      anton     111: #define IPTOS NEXT_INST
                    112: 
                    113: 
1.1       anton     114: #ifdef DOUBLY_INDIRECT
1.19      pazsan    115: # ifndef DEBUG_DITC
                    116: #  define DEBUG_DITC 0
                    117: # endif
                    118: /* define to 1 if you want to check consistency */
1.26      pazsan    119: #  define NEXT_P0      do {cfa1=cfa; cfa=*ip;} while(0)
1.23      anton     120: #  define CFA          cfa1
                    121: #  define MORE_VARS     Xt cfa1;
1.1       anton     122: #  define IP           (ip)
1.26      pazsan    123: #  define SET_IP(p)    do {ip=(p); cfa=*ip;} while(0)
1.1       anton     124: #  define NEXT_INST    (cfa)
1.26      pazsan    125: #  define INC_IP(const_inc)    do {cfa=IP[const_inc]; ip+=(const_inc);} while(0)
1.1       anton     126: #  define DEF_CA       Label ca;
1.26      pazsan    127: #  define NEXT_P1      do {\
1.19      pazsan    128:   if (DEBUG_DITC && (cfa<=vm_prims+DOESJUMP || cfa>=vm_prims+npriminfos)) \
                    129:     fprintf(stderr,"NEXT encountered prim %p at ip=%p\n", cfa, ip); \
1.26      pazsan    130:   ip++;} while(0)
1.28      anton     131: #  define NEXT_P1_5    do {ca=**cfa; GOTO(ca);} while(0)
1.32    ! anton     132: #  define EXEC1(XT)    ({DEF_CA cfa=(XT);\
1.19      pazsan    133:   if (DEBUG_DITC && (cfa>vm_prims+DOESJUMP && cfa<vm_prims+npriminfos)) \
1.14      anton     134:     fprintf(stderr,"EXEC encountered xt %p at ip=%p, vm_prims=%p, xts=%p\n", cfa, ip, vm_prims, xts); \
1.32    ! anton     135:  ca=**cfa; ca;})
1.1       anton     136: 
1.16      anton     137: #elif defined(NO_IP)
                    138: 
                    139: #define NEXT_P0
1.25      anton     140: #  define CFA          cfa
1.16      anton     141: #define SET_IP(target) assert(0)
                    142: #define INC_IP(n)      ((void)0)
                    143: #define DEF_CA
                    144: #define NEXT_P1
1.28      anton     145: #define NEXT_P1_5              do {goto *next_code;} while(0)
1.16      anton     146: /* set next_code to the return address before performing EXEC */
1.32    ! anton     147: /* original: */
        !           148: /* #define EXEC1(XT)   do {cfa=(XT); goto **cfa;} while(0) */
        !           149: /* fake, to make syntax check work */
        !           150: #define EXEC1(XT)      ({cfa=(XT); *cfa;})
1.16      anton     151: 
                    152: #else  /* !defined(DOUBLY_INDIRECT) && !defined(NO_IP) */
1.1       anton     153: 
1.3       anton     154: #if defined(DIRECT_THREADED)
                    155: 
1.17      anton     156: /* This lets the compiler know that cfa is dead before; we place it at
                    157:    "goto *"s that perform direct threaded dispatch (i.e., not EXECUTE
                    158:    etc.), and thus do not reach doers, which would use cfa; the only
                    159:    way to a doer is through EXECUTE etc., which set the cfa
                    160:    themselves.
                    161: 
                    162:    Some of these direct threaded schemes use "cfa" to hold the code
                    163:    address in normal direct threaded code.  Of course we cannot use
                    164:    KILLS there.
                    165: 
                    166:    KILLS works by having an empty asm instruction, and claiming to the
                    167:    compiler that it writes to cfa.
                    168: 
                    169:    KILLS is optional.  You can write
                    170: 
                    171: #define KILLS
                    172: 
                    173:    and lose just a little performance.
                    174: */
                    175: #define KILLS asm("":"=X"(cfa));
                    176: 
1.20      anton     177: #ifndef THREADING_SCHEME
1.24      anton     178: #define THREADING_SCHEME 7
1.20      anton     179: #endif
                    180: 
1.3       anton     181: #if THREADING_SCHEME==1
                    182: #warning direct threading scheme 1: autoinc, long latency, cfa live
1.26      pazsan    183: #  define NEXT_P0      do {cfa1=cfa; cfa=*ip++;} while(0)
1.23      anton     184: #  define CFA          cfa1
                    185: #  define MORE_VARS     Xt cfa1;
1.1       anton     186: #  define IP           (ip-1)
1.26      pazsan    187: #  define SET_IP(p)    do {ip=(p); cfa=*ip++;} while(0)
1.1       anton     188: #  define NEXT_INST    (cfa)
1.26      pazsan    189: #  define INC_IP(const_inc)    do {cfa=IP[const_inc]; ip+=(const_inc);} while(0)
1.1       anton     190: #  define DEF_CA
                    191: #  define NEXT_P1
1.28      anton     192: #  define NEXT_P1_5    do {GOTO(cfa);} while(0)
1.32    ! anton     193: #  define EXEC1(XT)    ({cfa=(XT); *cfa;})
1.1       anton     194: #endif
                    195: 
1.3       anton     196: #if THREADING_SCHEME==2
                    197: #warning direct threading scheme 2: autoinc, long latency, cfa dead
1.1       anton     198: #  define NEXT_P0      (ip++)
1.23      anton     199: #  define CFA          cfa
1.1       anton     200: #  define IP           (ip-1)
1.26      pazsan    201: #  define SET_IP(p)    do {ip=(p); NEXT_P0;} while(0)
1.1       anton     202: #  define NEXT_INST    (*(ip-1))
1.26      pazsan    203: #  define INC_IP(const_inc)    do { ip+=(const_inc);} while(0)
1.1       anton     204: #  define DEF_CA
                    205: #  define NEXT_P1
1.28      anton     206: #  define NEXT_P1_5    do {KILLS GOTO(*(ip-1));} while(0)
1.32    ! anton     207: #  define EXEC1(XT)    ({cfa=(XT); *cfa;})
1.1       anton     208: #endif
                    209: 
                    210: 
1.3       anton     211: #if THREADING_SCHEME==3
                    212: #warning direct threading scheme 3: autoinc, low latency, cfa live
1.1       anton     213: #  define NEXT_P0
1.23      anton     214: #  define CFA          cfa
1.1       anton     215: #  define IP           (ip)
1.26      pazsan    216: #  define SET_IP(p)    do {ip=(p); NEXT_P0;} while(0)
1.1       anton     217: #  define NEXT_INST    (*ip)
1.26      pazsan    218: #  define INC_IP(const_inc)    do {ip+=(const_inc);} while(0)
1.1       anton     219: #  define DEF_CA
1.26      pazsan    220: #  define NEXT_P1      do {cfa=*ip++;} while(0)
1.28      anton     221: #  define NEXT_P1_5    do {GOTO(cfa);} while(0)
1.32    ! anton     222: #  define EXEC1(XT)    ({cfa=(XT); *cfa;})
1.1       anton     223: #endif
                    224: 
1.3       anton     225: #if THREADING_SCHEME==4
                    226: #warning direct threading scheme 4: autoinc, low latency, cfa dead
1.1       anton     227: #  define NEXT_P0
1.23      anton     228: #  define CFA          cfa
1.1       anton     229: #  define IP           (ip)
1.26      pazsan    230: #  define SET_IP(p)    do {ip=(p); NEXT_P0;} while(0)
1.1       anton     231: #  define NEXT_INST    (*ip)
1.26      pazsan    232: #  define INC_IP(const_inc)    do { ip+=(const_inc);} while(0)
1.1       anton     233: #  define DEF_CA
                    234: #  define NEXT_P1
1.28      anton     235: #  define NEXT_P1_5    do {KILLS GOTO(*(ip++));} while(0)
1.32    ! anton     236: #  define EXEC1(XT)    ({cfa=(XT); *cfa;})
1.1       anton     237: #endif
                    238: 
1.3       anton     239: #if THREADING_SCHEME==5
                    240: #warning direct threading scheme 5: long latency, cfa live
1.26      pazsan    241: #  define NEXT_P0      do {cfa1=cfa; cfa=*ip;} while(0)
1.23      anton     242: #  define CFA          cfa1
                    243: #  define MORE_VARS     Xt cfa1;
1.1       anton     244: #  define IP           (ip)
1.26      pazsan    245: #  define SET_IP(p)    do {ip=(p); cfa=*ip;} while(0)
1.1       anton     246: #  define NEXT_INST    (cfa)
1.26      pazsan    247: #  define INC_IP(const_inc)    do {cfa=IP[const_inc]; ip+=(const_inc);} while(0)
1.1       anton     248: #  define DEF_CA
                    249: #  define NEXT_P1      (ip++)
1.28      anton     250: #  define NEXT_P1_5    do {GOTO(cfa);} while(0)
1.32    ! anton     251: #  define EXEC1(XT)    ({cfa=(XT); *cfa;})
1.1       anton     252: #endif
                    253: 
1.3       anton     254: #if THREADING_SCHEME==6
                    255: #warning direct threading scheme 6: long latency, cfa dead
1.1       anton     256: #  define NEXT_P0
1.23      anton     257: #  define CFA          cfa
1.1       anton     258: #  define IP           (ip)
1.26      pazsan    259: #  define SET_IP(p)    do {ip=(p); NEXT_P0;} while(0)
1.1       anton     260: #  define NEXT_INST    (*ip)
1.26      pazsan    261: #  define INC_IP(const_inc)    do {ip+=(const_inc);} while(0)
1.1       anton     262: #  define DEF_CA
                    263: #  define NEXT_P1      (ip++)
1.28      anton     264: #  define NEXT_P1_5    do {KILLS GOTO(*(ip-1));} while(0)
1.32    ! anton     265: #  define EXEC1(XT)    ({cfa=(XT); *cfa;})
1.1       anton     266: #endif
                    267: 
                    268: 
1.3       anton     269: #if THREADING_SCHEME==7
                    270: #warning direct threading scheme 7: low latency, cfa live
1.1       anton     271: #  define NEXT_P0
1.23      anton     272: #  define CFA          cfa
1.1       anton     273: #  define IP           (ip)
1.26      pazsan    274: #  define SET_IP(p)    do {ip=(p); NEXT_P0;} while(0)
1.1       anton     275: #  define NEXT_INST    (*ip)
1.26      pazsan    276: #  define INC_IP(const_inc)    do {ip+=(const_inc);} while(0)
1.1       anton     277: #  define DEF_CA
1.26      pazsan    278: #  define NEXT_P1      do {cfa=*ip++;} while(0)
1.28      anton     279: #  define NEXT_P1_5    do {GOTO(cfa);} while(0)
1.32    ! anton     280: #  define EXEC1(XT)    ({cfa=(XT); *cfa;})
1.1       anton     281: #endif
                    282: 
1.3       anton     283: #if THREADING_SCHEME==8
                    284: #warning direct threading scheme 8: cfa dead, i386 hack
1.1       anton     285: #  define NEXT_P0
1.23      anton     286: #  define CFA          cfa
1.1       anton     287: #  define IP           (ip)
1.26      pazsan    288: #  define SET_IP(p)    do {ip=(p); NEXT_P0;} while(0)
1.1       anton     289: #  define NEXT_INST    (*IP)
1.26      pazsan    290: #  define INC_IP(const_inc)    do { ip+=(const_inc);} while(0)
1.1       anton     291: #  define DEF_CA
                    292: #  define NEXT_P1      (ip++)
1.28      anton     293: #  define NEXT_P1_5    do {KILLS GOTO(*(ip-1));} while(0)
1.32    ! anton     294: #  define EXEC1(XT)    ({cfa=(XT); *cfa;})
1.1       anton     295: #endif
                    296: 
1.3       anton     297: #if THREADING_SCHEME==9
                    298: #warning direct threading scheme 9: Power/PPC hack, long latency
                    299: /* Power uses a prepare-to-branch instruction, and the latency between
                    300:    this inst and the branch is 5 cycles on a PPC604; so we utilize this
                    301:    to do some prefetching in between */
                    302: #  define NEXT_P0
1.23      anton     303: #  define CFA          cfa
1.3       anton     304: #  define IP           ip
1.26      pazsan    305: #  define SET_IP(p)    do {ip=(p); next_cfa=*ip; NEXT_P0;} while(0)
1.3       anton     306: #  define NEXT_INST    (next_cfa)
1.26      pazsan    307: #  define INC_IP(const_inc)    do {next_cfa=IP[const_inc]; ip+=(const_inc);} while(0)
1.8       anton     308: #  define DEF_CA       
1.26      pazsan    309: #  define NEXT_P1      do {cfa=next_cfa; ip++; next_cfa=*ip;} while(0)
1.28      anton     310: #  define NEXT_P1_5    do {GOTO(cfa);} while(0)
1.32    ! anton     311: #  define EXEC1(XT)    ({cfa=(XT); *cfa;})
1.3       anton     312: #  define MORE_VARS    Xt next_cfa;
                    313: #endif
1.1       anton     314: 
1.3       anton     315: #if THREADING_SCHEME==10
                    316: #warning direct threading scheme 10: plain (no attempt at scheduling)
                    317: #  define NEXT_P0
1.23      anton     318: #  define CFA          cfa
1.3       anton     319: #  define IP           (ip)
1.26      pazsan    320: #  define SET_IP(p)    do {ip=(p); NEXT_P0;} while(0)
1.3       anton     321: #  define NEXT_INST    (*ip)
1.26      pazsan    322: #  define INC_IP(const_inc)    do {ip+=(const_inc);} while(0)
1.3       anton     323: #  define DEF_CA
                    324: #  define NEXT_P1
1.28      anton     325: #  define NEXT_P1_5    do {cfa=*ip++; GOTO(cfa);} while(0)
1.32    ! anton     326: #  define EXEC1(XT)    ({cfa=(XT); *cfa;})
1.3       anton     327: #endif
1.1       anton     328: 
1.3       anton     329: /* direct threaded */
                    330: #else
1.1       anton     331: /* indirect THREADED  */
1.20      anton     332: 
                    333: #ifndef THREADING_SCHEME
                    334: #define THREADING_SCHEME 6
                    335: #endif
1.1       anton     336: 
1.3       anton     337: #if THREADING_SCHEME==1
                    338: #warning indirect threading scheme 1: autoinc, long latency, cisc
1.26      pazsan    339: #  define NEXT_P0      do {cfa1=cfa; cfa=*ip++;} while(0)
1.23      anton     340: #  define CFA          cfa1
                    341: #  define MORE_VARS     Xt cfa1;
1.1       anton     342: #  define IP           (ip-1)
1.26      pazsan    343: #  define SET_IP(p)    do {ip=(p); cfa=*ip++;} while(0)
1.1       anton     344: #  define NEXT_INST    (cfa)
1.26      pazsan    345: #  define INC_IP(const_inc)    do {cfa=IP[const_inc]; ip+=(const_inc);} while(0)
1.1       anton     346: #  define DEF_CA
                    347: #  define NEXT_P1
1.28      anton     348: #  define NEXT_P1_5    do {GOTO(*cfa);} while(0)
1.32    ! anton     349: #  define EXEC1(XT)    ({cfa=(XT); *cfa;})
1.1       anton     350: #endif
                    351: 
1.3       anton     352: #if THREADING_SCHEME==2
                    353: #warning indirect threading scheme 2: autoinc, long latency
1.26      pazsan    354: #  define NEXT_P0      do {cfa1=cfa; cfa=*ip++;} while(0)
1.23      anton     355: #  define CFA          cfa1
                    356: #  define MORE_VARS     Xt cfa1;
1.1       anton     357: #  define IP           (ip-1)
1.26      pazsan    358: #  define SET_IP(p)    do {ip=(p); cfa=*ip++;} while(0)
1.1       anton     359: #  define NEXT_INST    (cfa)
1.26      pazsan    360: #  define INC_IP(const_inc)    do {cfa=IP[const_inc]; ip+=(const_inc);} while(0)
1.1       anton     361: #  define DEF_CA       Label ca;
1.26      pazsan    362: #  define NEXT_P1      do {ca=*cfa;} while(0)
1.28      anton     363: #  define NEXT_P1_5    do {GOTO(ca);} while(0)
1.32    ! anton     364: #  define EXEC1(XT)    ({DEF_CA cfa=(XT); ca=*cfa; ca;})
1.1       anton     365: #endif
                    366: 
                    367: 
1.3       anton     368: #if THREADING_SCHEME==3
                    369: #warning indirect threading scheme 3: autoinc, low latency, cisc
1.1       anton     370: #  define NEXT_P0
1.23      anton     371: #  define CFA          cfa
1.1       anton     372: #  define IP           (ip)
1.26      pazsan    373: #  define SET_IP(p)    do {ip=(p); NEXT_P0;} while(0)
1.1       anton     374: #  define NEXT_INST    (*ip)
1.26      pazsan    375: #  define INC_IP(const_inc)    do {ip+=(const_inc);} while(0)
1.1       anton     376: #  define DEF_CA
                    377: #  define NEXT_P1
1.28      anton     378: #  define NEXT_P1_5    do {cfa=*ip++; GOTO(*cfa);} while(0)
1.32    ! anton     379: #  define EXEC1(XT)    ({cfa=(XT); *cfa;})
1.1       anton     380: #endif
                    381: 
1.3       anton     382: #if THREADING_SCHEME==4
                    383: #warning indirect threading scheme 4: autoinc, low latency
1.26      pazsan    384: #  define NEXT_P0      do {cfa1=cfa; cfa=*ip++;} while(0)
1.23      anton     385: #  define CFA          cfa1
                    386: #  define MORE_VARS     Xt cfa1;
1.1       anton     387: #  define IP           (ip-1)
1.26      pazsan    388: #  define SET_IP(p)    do {ip=(p); cfa=*ip++;} while(0)
1.1       anton     389: #  define NEXT_INST    (cfa)
1.26      pazsan    390: #  define INC_IP(const_inc)    do {cfa=IP[const_inc]; ip+=(const_inc);} while(0)
1.1       anton     391: #  define DEF_CA       Label ca;
1.26      pazsan    392: #  define NEXT_P1      do {ca=*cfa;} while(0)
1.28      anton     393: #  define NEXT_P1_5    do {GOTO(ca);} while(0)
1.32    ! anton     394: #  define EXEC1(XT)    ({DEF_CA cfa=(XT); ca=*cfa; ca;})
1.1       anton     395: #endif
                    396: 
                    397: 
1.3       anton     398: #if THREADING_SCHEME==5
                    399: #warning indirect threading scheme 5: long latency, cisc
1.26      pazsan    400: #  define NEXT_P0      do {cfa1=cfa; cfa=*ip;} while(0)
1.23      anton     401: #  define CFA          cfa1
                    402: #  define MORE_VARS     Xt cfa1;
1.1       anton     403: #  define IP           (ip)
1.26      pazsan    404: #  define SET_IP(p)    do {ip=(p); cfa=*ip;} while(0)
1.1       anton     405: #  define NEXT_INST    (cfa)
1.26      pazsan    406: #  define INC_IP(const_inc)    do {cfa=IP[const_inc]; ip+=(const_inc);} while(0)
1.1       anton     407: #  define DEF_CA
                    408: #  define NEXT_P1      (ip++)
1.28      anton     409: #  define NEXT_P1_5    do {GOTO(*cfa);} while(0)
1.32    ! anton     410: #  define EXEC1(XT)    ({cfa=(XT); *cfa;})
1.1       anton     411: #endif
                    412: 
1.3       anton     413: #if THREADING_SCHEME==6
                    414: #warning indirect threading scheme 6: long latency
1.26      pazsan    415: #  define NEXT_P0      do {cfa1=cfa; cfa=*ip;} while(0)
1.23      anton     416: #  define CFA          cfa1
                    417: #  define MORE_VARS     Xt cfa1;
1.1       anton     418: #  define IP           (ip)
1.26      pazsan    419: #  define SET_IP(p)    do {ip=(p); cfa=*ip;} while(0)
1.1       anton     420: #  define NEXT_INST    (cfa)
1.26      pazsan    421: #  define INC_IP(const_inc)    do {cfa=IP[const_inc]; ip+=(const_inc);} while(0)
1.1       anton     422: #  define DEF_CA       Label ca;
1.26      pazsan    423: #  define NEXT_P1      do {ip++; ca=*cfa;} while(0)
1.28      anton     424: #  define NEXT_P1_5    do {GOTO(ca);} while(0)
1.32    ! anton     425: #  define EXEC1(XT)    ({DEF_CA cfa=(XT); ca=*cfa; ca;})
1.1       anton     426: #endif
                    427: 
1.3       anton     428: #if THREADING_SCHEME==7
                    429: #warning indirect threading scheme 7: low latency
1.26      pazsan    430: #  define NEXT_P0      do {cfa1=cfa; cfa=*ip;} while(0)
1.23      anton     431: #  define CFA          cfa1
                    432: #  define MORE_VARS     Xt cfa1;
1.3       anton     433: #  define IP           (ip)
1.26      pazsan    434: #  define SET_IP(p)    do {ip=(p); cfa=*ip;} while(0)
1.3       anton     435: #  define NEXT_INST    (cfa)
1.26      pazsan    436: #  define INC_IP(const_inc)    do {cfa=IP[const_inc]; ip+=(const_inc);} while(0)
1.3       anton     437: #  define DEF_CA       Label ca;
1.26      pazsan    438: #  define NEXT_P1      do {ip++; ca=*cfa;} while(0)
1.28      anton     439: #  define NEXT_P1_5    do {GOTO(ca);} while(0)
1.32    ! anton     440: #  define EXEC1(XT)    ({DEF_CA cfa=(XT); ca=*cfa; ca;})
1.3       anton     441: #endif
1.1       anton     442: 
1.3       anton     443: #if THREADING_SCHEME==8
                    444: #warning indirect threading scheme 8: low latency,cisc
1.1       anton     445: #  define NEXT_P0
1.23      anton     446: #  define CFA          cfa
1.1       anton     447: #  define IP           (ip)
1.26      pazsan    448: #  define SET_IP(p)    do {ip=(p); NEXT_P0;} while(0)
1.1       anton     449: #  define NEXT_INST    (*ip)
1.26      pazsan    450: #  define INC_IP(const_inc)    do {ip+=(const_inc);} while(0)
1.1       anton     451: #  define DEF_CA
                    452: #  define NEXT_P1
1.28      anton     453: #  define NEXT_P1_5    do {cfa=*ip++; GOTO(*cfa);} while(0)
1.32    ! anton     454: #  define EXEC1(XT)    ({cfa=(XT); *cfa;})
1.1       anton     455: #endif
                    456: 
1.3       anton     457: /* indirect threaded */
1.1       anton     458: #endif
                    459: 
1.16      anton     460: #endif /* !defined(DOUBLY_INDIRECT) && !defined(NO_IP) */
1.1       anton     461: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>