ScmVM

From reading gauche
Jump to navigation Jump to search

概要[edit | edit source]

  • vm.hで定義
  • ScmVMRec の別名
  • GaucheVMの管理用データ

実装[edit | edit source]

 267 struct ScmVMRec {
 268     SCM_HEADER;
 269 #ifdef GAUCHE_USE_PTHREADS
 270     pthread_t thread;           /* the thread executing this VM. */
 271 #endif /*!GAUCHE_USE_PTHREADS*/
 272     int state;                  /* thread state. PUBLIC. */
 273     ScmInternalMutex  vmlock;   /* mutex to be used to lock this VM
 274                                    structure.  PUBLIC. */
 275     ScmInternalCond cond;       /* the condition variable to wait for state
 276                                    change of this VM.  PUBLIC. */
 277     ScmVM *canceller;           /* the thread that called thread-terminate!
 278                                    on this thread.  PUBLIC. */
 279     ScmObj name;                /* Scheme thread name. */
 280     ScmObj specific;            /* Scheme thread specific data. */
 281     ScmProcedure *thunk;        /* Entry point of this VM. */
 282     ScmObj result;              /* Result of thunk. */
 283     ScmObj resultException;     /* Exception that causes the thread to terminate.*/
 284     ScmModule *module;          /* current global namespace.  note that this
 285                                    is used only in compilation. */
 286     ScmCStack *cstack;          /* current escape point.  see the comment of
 287                                    "C stack rewinding" below. */
 288     unsigned int runtimeFlags;  /* Runtime flags */
 289     unsigned int compilerFlags; /* Compiler flags */
 290     unsigned int queueNotEmpty; /* Bitmask if sigq or finq is not empty */
 291 
 292     ScmPort *curin;             /* current input port */
 293     ScmPort *curout;            /* current output port */
 294     ScmPort *curerr;            /* current error port */
 295     ScmVMParameterTable parameters; /* parameter table */
 296 

VMの仮想レジスタ

 297     /* Registers */
 298     SCM_PCTYPE pc;              /* Program pointer.  Points list of
 299                                    instructions to be executed.              */
 300     ScmEnvFrame *env;           /* Current environment.                      */
 301     ScmContFrame *cont;         /* Current continuation.                     */
 302     ScmObj *argp;               /* Current argument pointer.  Points
 303                                    to the incomplete environment frame
 304                                    being accumulated.  This is a part of
 305                                    continuation.                             */
 306     ScmObj val0;                /* Value register.                           */
 307     ScmObj vals[SCM_VM_MAX_VALUES]; /* Value register for multiple values */
 308     int    numVals;             /* # of values */
 309 
 310     ScmObj handlers;            /* chain of active dynamic handlers          */
 311 
 312     ScmObj *sp;                 /* stack pointer */
 313     ScmObj *stack;              /* bottom of allocated stack area */
 314     ScmObj *stackBase;          /* base of current stack area  */
 315     ScmObj *stackEnd;           /* end of current stack area */
 316 
 317     /* Escape handling */
 318     ScmObj exceptionHandler;    /* the current exception handler installed by
 319                                    with-exception-handler. */
 320     ScmEscapePoint *escapePoint;/* chain of escape points (a kind of one-shot
 321                                    continuation).  used by system's default
 322                                    exception handler to escape from the error
 323                                    handlers. */
 324     int escapeReason;           /* temporary storage to pass data across
 325                                    longjmp(). */
 326     void *escapeData[2];        /* ditto. */
 327 
 328     /* Custom debugger */
 329     ScmObj defaultEscapeHandler;
 330 
 331     /* Program information */
 332     ScmObj load_next;           /* list of the directories to be searched */
 333     ScmObj load_history;        /* history of the nested load */
 334     ScmObj load_port;           /* current port from which we are loading */
 335 
 336     /* Signal information */
 337     ScmSignalQueue sigq;
 338     sigset_t sigMask;           /* current signal mask */
 339 };

情報[edit | edit source]