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

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: 
                     94: #ifdef DOUBLY_INDIRECT
1.19      pazsan     95: # ifndef DEBUG_DITC
                     96: #  define DEBUG_DITC 0
                     97: # endif
                     98: /* define to 1 if you want to check consistency */
1.26      pazsan     99: #  define NEXT_P0      do {cfa1=cfa; cfa=*ip;} while(0)
1.23      anton     100: #  define CFA          cfa1
                    101: #  define MORE_VARS     Xt cfa1;
1.1       anton     102: #  define IP           (ip)
1.26      pazsan    103: #  define SET_IP(p)    do {ip=(p); cfa=*ip;} while(0)
1.1       anton     104: #  define NEXT_INST    (cfa)
1.26      pazsan    105: #  define INC_IP(const_inc)    do {cfa=IP[const_inc]; ip+=(const_inc);} while(0)
1.1       anton     106: #  define DEF_CA       Label ca;
1.26      pazsan    107: #  define NEXT_P1      do {\
1.19      pazsan    108:   if (DEBUG_DITC && (cfa<=vm_prims+DOESJUMP || cfa>=vm_prims+npriminfos)) \
                    109:     fprintf(stderr,"NEXT encountered prim %p at ip=%p\n", cfa, ip); \
1.26      pazsan    110:   ip++;} while(0)
                    111: #  define NEXT_P2      do {ca=**cfa; goto *ca;} while(0)
                    112: #  define EXEC(XT)     do {DEF_CA cfa=(XT);\
1.19      pazsan    113:   if (DEBUG_DITC && (cfa>vm_prims+DOESJUMP && cfa<vm_prims+npriminfos)) \
1.14      anton     114:     fprintf(stderr,"EXEC encountered xt %p at ip=%p, vm_prims=%p, xts=%p\n", cfa, ip, vm_prims, xts); \
1.26      pazsan    115:  ca=**cfa; goto *ca;} while(0)
1.1       anton     116: 
1.16      anton     117: #elif defined(NO_IP)
                    118: 
                    119: #define NEXT_P0
1.25      anton     120: #  define CFA          cfa
1.16      anton     121: #define SET_IP(target) assert(0)
                    122: #define INC_IP(n)      ((void)0)
                    123: #define DEF_CA
                    124: #define NEXT_P1
1.26      pazsan    125: #define NEXT_P2                do {goto *next_code;} while(0)
1.16      anton     126: /* set next_code to the return address before performing EXEC */
1.26      pazsan    127: #define EXEC(XT)       do {cfa=(XT); goto **cfa;} while(0)
1.16      anton     128: 
                    129: #else  /* !defined(DOUBLY_INDIRECT) && !defined(NO_IP) */
1.1       anton     130: 
1.3       anton     131: #if defined(DIRECT_THREADED)
                    132: 
1.17      anton     133: /* This lets the compiler know that cfa is dead before; we place it at
                    134:    "goto *"s that perform direct threaded dispatch (i.e., not EXECUTE
                    135:    etc.), and thus do not reach doers, which would use cfa; the only
                    136:    way to a doer is through EXECUTE etc., which set the cfa
                    137:    themselves.
                    138: 
                    139:    Some of these direct threaded schemes use "cfa" to hold the code
                    140:    address in normal direct threaded code.  Of course we cannot use
                    141:    KILLS there.
                    142: 
                    143:    KILLS works by having an empty asm instruction, and claiming to the
                    144:    compiler that it writes to cfa.
                    145: 
                    146:    KILLS is optional.  You can write
                    147: 
                    148: #define KILLS
                    149: 
                    150:    and lose just a little performance.
                    151: */
                    152: #define KILLS asm("":"=X"(cfa));
                    153: 
1.20      anton     154: #ifndef THREADING_SCHEME
1.24      anton     155: #define THREADING_SCHEME 7
1.20      anton     156: #endif
                    157: 
1.3       anton     158: #if THREADING_SCHEME==1
                    159: #warning direct threading scheme 1: autoinc, long latency, cfa live
1.26      pazsan    160: #  define NEXT_P0      do {cfa1=cfa; cfa=*ip++;} while(0)
1.23      anton     161: #  define CFA          cfa1
                    162: #  define MORE_VARS     Xt cfa1;
1.1       anton     163: #  define IP           (ip-1)
1.26      pazsan    164: #  define SET_IP(p)    do {ip=(p); cfa=*ip++;} while(0)
1.1       anton     165: #  define NEXT_INST    (cfa)
1.26      pazsan    166: #  define INC_IP(const_inc)    do {cfa=IP[const_inc]; ip+=(const_inc);} while(0)
1.1       anton     167: #  define DEF_CA
                    168: #  define NEXT_P1
1.26      pazsan    169: #  define NEXT_P2      do {goto *cfa;} while(0)
                    170: #  define EXEC(XT)     do {cfa=(XT); goto **cfa;} while(0)
1.1       anton     171: #endif
                    172: 
1.3       anton     173: #if THREADING_SCHEME==2
                    174: #warning direct threading scheme 2: autoinc, long latency, cfa dead
1.1       anton     175: #  define NEXT_P0      (ip++)
1.23      anton     176: #  define CFA          cfa
1.1       anton     177: #  define IP           (ip-1)
1.26      pazsan    178: #  define SET_IP(p)    do {ip=(p); NEXT_P0;} while(0)
1.1       anton     179: #  define NEXT_INST    (*(ip-1))
1.26      pazsan    180: #  define INC_IP(const_inc)    do { ip+=(const_inc);} while(0)
1.1       anton     181: #  define DEF_CA
                    182: #  define NEXT_P1
1.26      pazsan    183: #  define NEXT_P2      do {KILLS goto **(ip-1);} while(0)
                    184: #  define EXEC(XT)     do {cfa=(XT); goto **cfa;} while(0)
1.1       anton     185: #endif
                    186: 
                    187: 
1.3       anton     188: #if THREADING_SCHEME==3
                    189: #warning direct threading scheme 3: autoinc, low latency, cfa live
1.1       anton     190: #  define NEXT_P0
1.23      anton     191: #  define CFA          cfa
1.1       anton     192: #  define IP           (ip)
1.26      pazsan    193: #  define SET_IP(p)    do {ip=(p); NEXT_P0;} while(0)
1.1       anton     194: #  define NEXT_INST    (*ip)
1.26      pazsan    195: #  define INC_IP(const_inc)    do {ip+=(const_inc);} while(0)
1.1       anton     196: #  define DEF_CA
1.26      pazsan    197: #  define NEXT_P1      do {cfa=*ip++;} while(0)
                    198: #  define NEXT_P2      do {goto *cfa;} while(0)
                    199: #  define EXEC(XT)     do {cfa=(XT); goto **cfa;} while(0)
1.1       anton     200: #endif
                    201: 
1.3       anton     202: #if THREADING_SCHEME==4
                    203: #warning direct threading scheme 4: autoinc, low latency, cfa dead
1.1       anton     204: #  define NEXT_P0
1.23      anton     205: #  define CFA          cfa
1.1       anton     206: #  define IP           (ip)
1.26      pazsan    207: #  define SET_IP(p)    do {ip=(p); NEXT_P0;} while(0)
1.1       anton     208: #  define NEXT_INST    (*ip)
1.26      pazsan    209: #  define INC_IP(const_inc)    do { ip+=(const_inc);} while(0)
1.1       anton     210: #  define DEF_CA
                    211: #  define NEXT_P1
1.26      pazsan    212: #  define NEXT_P2      do {KILLS goto **(ip++);} while(0)
                    213: #  define EXEC(XT)     do {cfa=(XT); goto **cfa;} while(0)
1.1       anton     214: #endif
                    215: 
1.3       anton     216: #if THREADING_SCHEME==5
                    217: #warning direct threading scheme 5: long latency, cfa live
1.26      pazsan    218: #  define NEXT_P0      do {cfa1=cfa; cfa=*ip;} while(0)
1.23      anton     219: #  define CFA          cfa1
                    220: #  define MORE_VARS     Xt cfa1;
1.1       anton     221: #  define IP           (ip)
1.26      pazsan    222: #  define SET_IP(p)    do {ip=(p); cfa=*ip;} while(0)
1.1       anton     223: #  define NEXT_INST    (cfa)
1.26      pazsan    224: #  define INC_IP(const_inc)    do {cfa=IP[const_inc]; ip+=(const_inc);} while(0)
1.1       anton     225: #  define DEF_CA
                    226: #  define NEXT_P1      (ip++)
1.26      pazsan    227: #  define NEXT_P2      do {goto *cfa;} while(0)
                    228: #  define EXEC(XT)     do {cfa=(XT); goto **cfa;} while(0)
1.1       anton     229: #endif
                    230: 
1.3       anton     231: #if THREADING_SCHEME==6
                    232: #warning direct threading scheme 6: long latency, cfa dead
1.1       anton     233: #  define NEXT_P0
1.23      anton     234: #  define CFA          cfa
1.1       anton     235: #  define IP           (ip)
1.26      pazsan    236: #  define SET_IP(p)    do {ip=(p); NEXT_P0;} while(0)
1.1       anton     237: #  define NEXT_INST    (*ip)
1.26      pazsan    238: #  define INC_IP(const_inc)    do {ip+=(const_inc);} while(0)
1.1       anton     239: #  define DEF_CA
                    240: #  define NEXT_P1      (ip++)
1.26      pazsan    241: #  define NEXT_P2      do {KILLS goto **(ip-1);} while(0)
                    242: #  define EXEC(XT)     do {cfa=(XT); goto **cfa;} while(0)
1.1       anton     243: #endif
                    244: 
                    245: 
1.3       anton     246: #if THREADING_SCHEME==7
                    247: #warning direct threading scheme 7: low latency, cfa live
1.1       anton     248: #  define NEXT_P0
1.23      anton     249: #  define CFA          cfa
1.1       anton     250: #  define IP           (ip)
1.26      pazsan    251: #  define SET_IP(p)    do {ip=(p); NEXT_P0;} while(0)
1.1       anton     252: #  define NEXT_INST    (*ip)
1.26      pazsan    253: #  define INC_IP(const_inc)    do {ip+=(const_inc);} while(0)
1.1       anton     254: #  define DEF_CA
1.26      pazsan    255: #  define NEXT_P1      do {cfa=*ip++;} while(0)
                    256: #  define NEXT_P2      do {goto *cfa;} while(0)
                    257: #  define EXEC(XT)     do {cfa=(XT); goto **cfa;} while(0)
1.1       anton     258: #endif
                    259: 
1.3       anton     260: #if THREADING_SCHEME==8
                    261: #warning direct threading scheme 8: cfa dead, i386 hack
1.1       anton     262: #  define NEXT_P0
1.23      anton     263: #  define CFA          cfa
1.1       anton     264: #  define IP           (ip)
1.26      pazsan    265: #  define SET_IP(p)    do {ip=(p); NEXT_P0;} while(0)
1.1       anton     266: #  define NEXT_INST    (*IP)
1.26      pazsan    267: #  define INC_IP(const_inc)    do { ip+=(const_inc);} while(0)
1.1       anton     268: #  define DEF_CA
                    269: #  define NEXT_P1      (ip++)
1.26      pazsan    270: #  define NEXT_P2      do {KILLS goto **(ip-1);} while(0)
                    271: #  define EXEC(XT)     do {cfa=(XT); goto **cfa;} while(0)
1.1       anton     272: #endif
                    273: 
1.3       anton     274: #if THREADING_SCHEME==9
                    275: #warning direct threading scheme 9: Power/PPC hack, long latency
                    276: /* Power uses a prepare-to-branch instruction, and the latency between
                    277:    this inst and the branch is 5 cycles on a PPC604; so we utilize this
                    278:    to do some prefetching in between */
                    279: #  define NEXT_P0
1.23      anton     280: #  define CFA          cfa
1.3       anton     281: #  define IP           ip
1.26      pazsan    282: #  define SET_IP(p)    do {ip=(p); next_cfa=*ip; NEXT_P0;} while(0)
1.3       anton     283: #  define NEXT_INST    (next_cfa)
1.26      pazsan    284: #  define INC_IP(const_inc)    do {next_cfa=IP[const_inc]; ip+=(const_inc);} while(0)
1.8       anton     285: #  define DEF_CA       
1.26      pazsan    286: #  define NEXT_P1      do {cfa=next_cfa; ip++; next_cfa=*ip;} while(0)
                    287: #  define NEXT_P2      do {goto *cfa;} while(0)
                    288: #  define EXEC(XT)     do {cfa=(XT); goto **cfa;} while(0)
1.3       anton     289: #  define MORE_VARS    Xt next_cfa;
                    290: #endif
1.1       anton     291: 
1.3       anton     292: #if THREADING_SCHEME==10
                    293: #warning direct threading scheme 10: plain (no attempt at scheduling)
                    294: #  define NEXT_P0
1.23      anton     295: #  define CFA          cfa
1.3       anton     296: #  define IP           (ip)
1.26      pazsan    297: #  define SET_IP(p)    do {ip=(p); NEXT_P0;} while(0)
1.3       anton     298: #  define NEXT_INST    (*ip)
1.26      pazsan    299: #  define INC_IP(const_inc)    do {ip+=(const_inc);} while(0)
1.3       anton     300: #  define DEF_CA
                    301: #  define NEXT_P1
1.26      pazsan    302: #  define NEXT_P2      do {cfa=*ip++; goto *cfa;} while(0)
                    303: #  define EXEC(XT)     do {cfa=(XT); goto **cfa;} while(0)
1.3       anton     304: #endif
1.1       anton     305: 
1.3       anton     306: /* direct threaded */
                    307: #else
1.1       anton     308: /* indirect THREADED  */
1.20      anton     309: 
                    310: #ifndef THREADING_SCHEME
                    311: #define THREADING_SCHEME 6
                    312: #endif
1.1       anton     313: 
1.3       anton     314: #if THREADING_SCHEME==1
                    315: #warning indirect threading scheme 1: autoinc, long latency, cisc
1.26      pazsan    316: #  define NEXT_P0      do {cfa1=cfa; cfa=*ip++;} while(0)
1.23      anton     317: #  define CFA          cfa1
                    318: #  define MORE_VARS     Xt cfa1;
1.1       anton     319: #  define IP           (ip-1)
1.26      pazsan    320: #  define SET_IP(p)    do {ip=(p); cfa=*ip++;} while(0)
1.1       anton     321: #  define NEXT_INST    (cfa)
1.26      pazsan    322: #  define INC_IP(const_inc)    do {cfa=IP[const_inc]; ip+=(const_inc);} while(0)
1.1       anton     323: #  define DEF_CA
                    324: #  define NEXT_P1
1.26      pazsan    325: #  define NEXT_P2      do {goto **cfa;} while(0)
                    326: #  define EXEC(XT)     do {cfa=(XT); goto **cfa;} while(0)
1.1       anton     327: #endif
                    328: 
1.3       anton     329: #if THREADING_SCHEME==2
                    330: #warning indirect threading scheme 2: autoinc, long latency
1.26      pazsan    331: #  define NEXT_P0      do {cfa1=cfa; cfa=*ip++;} while(0)
1.23      anton     332: #  define CFA          cfa1
                    333: #  define MORE_VARS     Xt cfa1;
1.1       anton     334: #  define IP           (ip-1)
1.26      pazsan    335: #  define SET_IP(p)    do {ip=(p); cfa=*ip++;} while(0)
1.1       anton     336: #  define NEXT_INST    (cfa)
1.26      pazsan    337: #  define INC_IP(const_inc)    do {cfa=IP[const_inc]; ip+=(const_inc);} while(0)
1.1       anton     338: #  define DEF_CA       Label ca;
1.26      pazsan    339: #  define NEXT_P1      do {ca=*cfa;} while(0)
                    340: #  define NEXT_P2      do {goto *ca;} while(0)
                    341: #  define EXEC(XT)     do {DEF_CA cfa=(XT); ca=*cfa; goto *ca;} while(0)
1.1       anton     342: #endif
                    343: 
                    344: 
1.3       anton     345: #if THREADING_SCHEME==3
                    346: #warning indirect threading scheme 3: autoinc, low latency, cisc
1.1       anton     347: #  define NEXT_P0
1.23      anton     348: #  define CFA          cfa
1.1       anton     349: #  define IP           (ip)
1.26      pazsan    350: #  define SET_IP(p)    do {ip=(p); NEXT_P0;} while(0)
1.1       anton     351: #  define NEXT_INST    (*ip)
1.26      pazsan    352: #  define INC_IP(const_inc)    do {ip+=(const_inc);} while(0)
1.1       anton     353: #  define DEF_CA
                    354: #  define NEXT_P1
1.26      pazsan    355: #  define NEXT_P2      do {cfa=*ip++; goto **cfa;} while(0)
                    356: #  define EXEC(XT)     do {cfa=(XT); goto **cfa;} while(0)
1.1       anton     357: #endif
                    358: 
1.3       anton     359: #if THREADING_SCHEME==4
                    360: #warning indirect threading scheme 4: autoinc, low latency
1.26      pazsan    361: #  define NEXT_P0      do {cfa1=cfa; cfa=*ip++;} while(0)
1.23      anton     362: #  define CFA          cfa1
                    363: #  define MORE_VARS     Xt cfa1;
1.1       anton     364: #  define IP           (ip-1)
1.26      pazsan    365: #  define SET_IP(p)    do {ip=(p); cfa=*ip++;} while(0)
1.1       anton     366: #  define NEXT_INST    (cfa)
1.26      pazsan    367: #  define INC_IP(const_inc)    do {cfa=IP[const_inc]; ip+=(const_inc);} while(0)
1.1       anton     368: #  define DEF_CA       Label ca;
1.26      pazsan    369: #  define NEXT_P1      do {ca=*cfa;} while(0)
                    370: #  define NEXT_P2      do {goto *ca;} while(0)
                    371: #  define EXEC(XT)     do {DEF_CA cfa=(XT); ca=*cfa; goto *ca;} while(0)
1.1       anton     372: #endif
                    373: 
                    374: 
1.3       anton     375: #if THREADING_SCHEME==5
                    376: #warning indirect threading scheme 5: long latency, cisc
1.26      pazsan    377: #  define NEXT_P0      do {cfa1=cfa; cfa=*ip;} while(0)
1.23      anton     378: #  define CFA          cfa1
                    379: #  define MORE_VARS     Xt cfa1;
1.1       anton     380: #  define IP           (ip)
1.26      pazsan    381: #  define SET_IP(p)    do {ip=(p); cfa=*ip;} while(0)
1.1       anton     382: #  define NEXT_INST    (cfa)
1.26      pazsan    383: #  define INC_IP(const_inc)    do {cfa=IP[const_inc]; ip+=(const_inc);} while(0)
1.1       anton     384: #  define DEF_CA
                    385: #  define NEXT_P1      (ip++)
1.26      pazsan    386: #  define NEXT_P2      do {goto **cfa;} while(0)
                    387: #  define EXEC(XT)     do {cfa=(XT); goto **cfa;} while(0)
1.1       anton     388: #endif
                    389: 
1.3       anton     390: #if THREADING_SCHEME==6
                    391: #warning indirect threading scheme 6: long latency
1.26      pazsan    392: #  define NEXT_P0      do {cfa1=cfa; cfa=*ip;} while(0)
1.23      anton     393: #  define CFA          cfa1
                    394: #  define MORE_VARS     Xt cfa1;
1.1       anton     395: #  define IP           (ip)
1.26      pazsan    396: #  define SET_IP(p)    do {ip=(p); cfa=*ip;} while(0)
1.1       anton     397: #  define NEXT_INST    (cfa)
1.26      pazsan    398: #  define INC_IP(const_inc)    do {cfa=IP[const_inc]; ip+=(const_inc);} while(0)
1.1       anton     399: #  define DEF_CA       Label ca;
1.26      pazsan    400: #  define NEXT_P1      do {ip++; ca=*cfa;} while(0)
                    401: #  define NEXT_P2      do {goto *ca;} while(0)
                    402: #  define EXEC(XT)     do {DEF_CA cfa=(XT); ca=*cfa; goto *ca;} while(0)
1.1       anton     403: #endif
                    404: 
1.3       anton     405: #if THREADING_SCHEME==7
                    406: #warning indirect threading scheme 7: low latency
1.26      pazsan    407: #  define NEXT_P0      do {cfa1=cfa; cfa=*ip;} while(0)
1.23      anton     408: #  define CFA          cfa1
                    409: #  define MORE_VARS     Xt cfa1;
1.3       anton     410: #  define IP           (ip)
1.26      pazsan    411: #  define SET_IP(p)    do {ip=(p); cfa=*ip;} while(0)
1.3       anton     412: #  define NEXT_INST    (cfa)
1.26      pazsan    413: #  define INC_IP(const_inc)    do {cfa=IP[const_inc]; ip+=(const_inc);} while(0)
1.3       anton     414: #  define DEF_CA       Label ca;
1.26      pazsan    415: #  define NEXT_P1      do {ip++; ca=*cfa;} while(0)
                    416: #  define NEXT_P2      do {goto *ca;} while(0)
                    417: #  define EXEC(XT)     do {DEF_CA cfa=(XT); ca=*cfa; goto *ca;} while(0)
1.3       anton     418: #endif
1.1       anton     419: 
1.3       anton     420: #if THREADING_SCHEME==8
                    421: #warning indirect threading scheme 8: low latency,cisc
1.1       anton     422: #  define NEXT_P0
1.23      anton     423: #  define CFA          cfa
1.1       anton     424: #  define IP           (ip)
1.26      pazsan    425: #  define SET_IP(p)    do {ip=(p); NEXT_P0;} while(0)
1.1       anton     426: #  define NEXT_INST    (*ip)
1.26      pazsan    427: #  define INC_IP(const_inc)    do {ip+=(const_inc);} while(0)
1.1       anton     428: #  define DEF_CA
                    429: #  define NEXT_P1
1.26      pazsan    430: #  define NEXT_P2      do {cfa=*ip++; goto **cfa;} while(0)
                    431: #  define EXEC(XT)     do {cfa=(XT); goto **cfa;} while(0)
1.1       anton     432: #endif
                    433: 
1.3       anton     434: /* indirect threaded */
1.1       anton     435: #endif
                    436: 
1.16      anton     437: #endif /* !defined(DOUBLY_INDIRECT) && !defined(NO_IP) */
1.1       anton     438: 
1.26      pazsan    439: #define NEXT do {DEF_CA NEXT_P1; NEXT_P2;} while(0)
1.10      anton     440: #define IPTOS NEXT_INST

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