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

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

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