Diff for /gforth/engine/engine.c between versions 1.34 and 1.39

version 1.34, 2001/12/24 14:09:08 version 1.39, 2002/01/20 19:04:11
Line 19 Line 19
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
 */  */
   
   undefine(`symbols')
   
 #include "config.h"  #include "config.h"
 #include "forth.h"  #include "forth.h"
 #include <ctype.h>  #include <ctype.h>
Line 280  static int ufileattr[6]= { Line 282  static int ufileattr[6]= {
 # define CPU_DEP1 0  # define CPU_DEP1 0
 #endif  #endif
   
 /* declare and compute cfa for certain threading variants */  
 /* warning: this is nonsyntactical; it will not work in place of a statement */  
 #ifndef GETCFA  
 #define DOCFA  
 #else  
 #define DOCFA   Xt cfa; GETCFA(cfa)  
 #endif  
   
 /* instructions containing these must be the last instruction of a  /* instructions containing these must be the last instruction of a
    super-instruction (e.g., branches, EXECUTE, and other instructions     super-instruction (e.g., branches, EXECUTE, and other instructions
    ending the basic block). Instructions containing SET_IP get this     ending the basic block). Instructions containing SET_IP get this
Line 300  static int ufileattr[6]= { Line 294  static int ufileattr[6]= {
 #else  #else
 #define SUPER_END  #define SUPER_END
 #endif  #endif
   #define SUPER_CONTINUE
   
 #ifdef GFORTH_DEBUGGING  #ifdef GFORTH_DEBUGGING
 /* define some VM registers as global variables, so they survive exceptions;  /* define some VM registers as global variables, so they survive exceptions;
Line 309  Xt *ip; Line 304  Xt *ip;
 Cell *rp;  Cell *rp;
 #endif  #endif
   
   #ifdef DEBUG
   #define CFA_TO_NAME(__cfa) \
         Cell len, i; \
         char * name = __cfa; \
         for(i=0; i<32; i+=sizeof(Cell)) { \
           len = ((Cell*)name)[-1]; \
           if(len < 0) { \
             len &= 0x1F; \
             if((len+sizeof(Cell)) > i) break; \
           } len = 0; \
           name -= sizeof(Cell); \
         }
   #endif
   
 Xt *primtable(Label symbols[], Cell size)  Xt *primtable(Label symbols[], Cell size)
        /* used in primitive primtable for peephole optimization */
 {  {
 #ifdef DIRECT_THREADED  #ifdef DIRECT_THREADED
   return symbols;    return symbols;
Line 337  define(enginerest, Line 347  define(enginerest,
   register Cell *sp SPREG = sp0;    register Cell *sp SPREG = sp0;
   register Float *fp FPREG = fp0;    register Float *fp FPREG = fp0;
   register Address lp LPREG = lp0;    register Address lp LPREG = lp0;
 #ifdef CFA_NEXT  
   register Xt cfa CFAREG;    register Xt cfa CFAREG;
 #endif  
 #ifdef MORE_VARS  #ifdef MORE_VARS
   MORE_VARS    MORE_VARS
 #endif  #endif
Line 389  define(enginerest, Line 397  define(enginerest,
   
   if (ip == NULL) {    if (ip == NULL) {
 #if defined(DOUBLY_INDIRECT)  #if defined(DOUBLY_INDIRECT)
 #define CODE_OFFSET (22*sizeof(Cell))  #define CODE_OFFSET (26*sizeof(Cell))
   #define XT_OFFSET (22*sizeof(Cell))
     int i;      int i;
     Cell code_offset = offset_image? CODE_OFFSET : 0;      Cell code_offset = offset_image? CODE_OFFSET : 0;
       Cell xt_offset = offset_image? XT_OFFSET : 0;
   
     symbols = (Label *)(malloc(MAX_SYMBOLS*sizeof(Cell)+CODE_OFFSET)+code_offset);      symbols = (Label *)(malloc(MAX_SYMBOLS*sizeof(Cell)+CODE_OFFSET)+code_offset);
       xts = (Label *)(malloc(MAX_SYMBOLS*sizeof(Cell)+XT_OFFSET)+xt_offset);
     for (i=0; i<DOESJUMP+1; i++)      for (i=0; i<DOESJUMP+1; i++)
       symbols[i] = (Label)routines[i];        xts[i] = symbols[i] = (Label)routines[i];
     for (; routines[i]!=0; i++) {      for (; routines[i]!=0; i++) {
       if (i>=MAX_SYMBOLS) {        if (i>=MAX_SYMBOLS) {
         fprintf(stderr,"gforth-ditc: more than %d primitives\n",MAX_SYMBOLS);          fprintf(stderr,"gforth-ditc: more than %d primitives\n",MAX_SYMBOLS);
         exit(1);          exit(1);
       }        }
       symbols[i] = &routines[i];        xts[i] = symbols[i] = &routines[i];
     }      }
 #endif /* defined(DOUBLY_INDIRECT) */  #endif /* defined(DOUBLY_INDIRECT) */
     return symbols;      return symbols;
Line 421  define(enginerest, Line 432  define(enginerest,
       
  docol:   docol:
   {    {
     DOCFA;  
 #ifdef DEBUG  #ifdef DEBUG
     fprintf(stderr,"%08lx: col: %08lx\n",(Cell)ip,(Cell)PFA1(cfa));      {
         CFA_TO_NAME(cfa);
         fprintf(stderr,"%08lx: col: %08lx %.*s\n",(Cell)ip,(Cell)PFA1(cfa),
                 len,name);
       }
 #endif  #endif
 #ifdef CISC_NEXT  #ifdef CISC_NEXT
     /* this is the simple version */      /* this is the simple version */
Line 447  define(enginerest, Line 461  define(enginerest,
   
  docon:   docon:
   {    {
     DOCFA;  
 #ifdef DEBUG  #ifdef DEBUG
     fprintf(stderr,"%08lx: con: %08lx\n",(Cell)ip,*(Cell*)PFA1(cfa));      fprintf(stderr,"%08lx: con: %08lx\n",(Cell)ip,*(Cell*)PFA1(cfa));
 #endif  #endif
Line 463  define(enginerest, Line 476  define(enginerest,
       
  dovar:   dovar:
   {    {
     DOCFA;  
 #ifdef DEBUG  #ifdef DEBUG
     fprintf(stderr,"%08lx: var: %08lx\n",(Cell)ip,(Cell)PFA1(cfa));      fprintf(stderr,"%08lx: var: %08lx\n",(Cell)ip,(Cell)PFA1(cfa));
 #endif  #endif
Line 479  define(enginerest, Line 491  define(enginerest,
       
  douser:   douser:
   {    {
     DOCFA;  
 #ifdef DEBUG  #ifdef DEBUG
     fprintf(stderr,"%08lx: user: %08lx\n",(Cell)ip,(Cell)PFA1(cfa));      fprintf(stderr,"%08lx: user: %08lx\n",(Cell)ip,(Cell)PFA1(cfa));
 #endif  #endif
Line 495  define(enginerest, Line 506  define(enginerest,
       
  dodefer:   dodefer:
   {    {
     DOCFA;  
 #ifdef DEBUG  #ifdef DEBUG
     fprintf(stderr,"%08lx: defer: %08lx\n",(Cell)ip,*(Cell*)PFA1(cfa));      fprintf(stderr,"%08lx: defer: %08lx\n",(Cell)ip,*(Cell*)PFA1(cfa));
 #endif  #endif
Line 505  define(enginerest, Line 515  define(enginerest,
   
  dofield:   dofield:
   {    {
     DOCFA;  
 #ifdef DEBUG  #ifdef DEBUG
     fprintf(stderr,"%08lx: field: %08lx\n",(Cell)ip,(Cell)PFA1(cfa));      fprintf(stderr,"%08lx: field: %08lx\n",(Cell)ip,(Cell)PFA1(cfa));
 #endif  #endif
Line 533  define(enginerest, Line 542  define(enginerest,
             
      */       */
   {    {
     DOCFA;  
   
     /*    fprintf(stderr, "Got CFA %08lx at doescode %08lx/%08lx: does: %08lx\n",cfa,(Cell)ip,(Cell)PFA(cfa),(Cell)DOES_CODE1(cfa));*/      /*    fprintf(stderr, "Got CFA %08lx at doescode %08lx/%08lx: does: %08lx\n",cfa,(Cell)ip,(Cell)PFA(cfa),(Cell)DOES_CODE1(cfa));*/
 #ifdef DEBUG  #ifdef DEBUG
     fprintf(stderr,"%08lx/%08lx: does: %08lx\n",(Cell)ip,(Cell)PFA(cfa),(Cell)DOES_CODE1(cfa));      fprintf(stderr,"%08lx/%08lx: does: %08lx\n",(Cell)ip,(Cell)PFA(cfa),(Cell)DOES_CODE1(cfa));

Removed from v.1.34  
changed lines
  Added in v.1.39


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