execute.h

来自「一个操作系统源代码 用于嵌入式设备 在Vc++环境下仿真 成功移植到多款处理器上」· C头文件 代码 · 共 514 行 · 第 1/2 页

H
514
字号
 * the continue will effect a jump to the start of the interpreter loop.
 *=======================================================================*/

#define CHECK_NOT_NULL(object)                  \
    if (object == NIL) {                        \
        goto handleNullPointerException;        \
}

/*=========================================================================
 * TRACE_METHOD_ENTRY - Macro for tracing
 *=======================================================================*/

#if INCLUDEDEBUGCODE
#define TRACE_METHOD_ENTRY(method, what) {                      \
   ASSERTING_NO_ALLOCATION                                      \
   if (tracemethodcallsverbose) Log->enterMethod(method, what); \
   END_ASSERTING_NO_ALLOCATION                                  \
}
#else
#define TRACE_METHOD_ENTRY(method, what) /**/
#endif

/*=========================================================================
 * TRACE_METHOD_EXIT - Macro for tracing
 *=======================================================================*/

#if INCLUDEDEBUGCODE
#define TRACE_METHOD_EXIT(method) {                      \
   ASSERTING_NO_ALLOCATION                               \
   if (tracemethodcallsverbose) Log->exitMethod(method); \
   END_ASSERTING_NO_ALLOCATION                           \
}
#else
#define TRACE_METHOD_EXIT(method)        /**/
#endif

/*=========================================================================
 * POP_FRAME - Macro to pop a stack frame
 *=======================================================================*/

#if INCLUDEDEBUGCODE
#define POP_FRAME {                                \
       VMSAVE                                      \
       popFrame();                                 \
       VMRESTORE                                   \
}
#else
#define POP_FRAME POPFRAMEMACRO
#endif


/*=========================================================================
 * INFREQUENTROUTINE - Have bytecode executed by the infrequent routine
 *=======================================================================*/

#if SPLITINFREQUENTBYTECODES
#define INFREQUENTROUTINE(x) case x: { goto callSlowInterpret; }
#else
#define INFREQUENTROUTINE(x) /**/
#endif

/*=========================================================================
 * INSTRUCTIONPROFILE - Instruction profiling
 *=======================================================================*/

#if ENABLEPROFILING
#define INSTRUCTIONPROFILE  {                   \
    VMSAVE                                      \
    InstructionProfile();                       \
    VMRESTORE                                   \
}
#else
#define INSTRUCTIONPROFILE /**/
#endif

/*=========================================================================
 * INSTRUCTIONTRACE - Instruction tracing
 *=======================================================================*/

#if INCLUDEDEBUGCODE
#define INSTRUCTIONTRACE  {                             \
        VMSAVE                                          \
        if (tracebytecodes) InstructionTrace(ip_global);\
        VMRESTORE                                       \
}
#else
#define INSTRUCTIONTRACE /**/
#endif

/*=========================================================================
 * RESCHEDULE - Thread rescheduling
 *=======================================================================*/

#if ENABLE_JAVA_DEBUGGER

#define __getNextToken()                                                \
        if (CurrentThread->isAtBreakpoint) {           \
            CurrentThread->isAtBreakpoint = FALSE;                      \
            token = CurrentThread->nextOpcode;                          \
        } else                                                          \
            token = *ip;

#define __doSingleStep()                                                \
        if (CurrentThread && CurrentThread->isStepping) {               \
            THREAD __thread__ = CurrentThread;                          \
            THREAD __tp__;                                              \
            VMSAVE                                                      \
            if (handleSingleStep(__thread__, &__tp__)) {                \
                __tp__->isAtBreakpoint = TRUE;                          \
                __tp__->nextOpcode = token;                             \
                VMRESTORE                                               \
                goto reschedulePoint;                                   \
            }                                                           \
            VMRESTORE                                                   \
        }

#define __checkDebugEvent()                                             \
        if (vmDebugReady && CurrentThread && CurrentThread->needEvent) {  \
            checkDebugEvent(CurrentThread);                             \
        }

/* This routine/macro is called from inside the interpreter */
/* to check if it is time to perform thread switching and   */
/* possibly to check for external events.  This routine is  */
/* very performance critical!  Most of the function calls   */
/* inside this macro definition turn into null statements   */
/* in production builds when debugger support is turned off */

#define RESCHEDULE {                            \
    INC_RESHED                                  \
    checkRescheduleValid();                     \
    if (isTimeToReschedule()) {                 \
        VMSAVE                                  \
        __checkDebugEvent()                     \
        reschedule();                           \
        VMRESTORE                               \
    }                                           \
    if (vmDebugReady && CurrentThread) {        \
      __getNextToken()                          \
      __doSingleStep()                          \
    } else                                      \
      token = *ip;                              \
}

#else

/* This routine/macro is called from inside the interpreter */
/* to check if it is time to perform thread switching and   */
/* possibly to check for external events.  This routine is  */
/* very performance critical!  Most of the function calls   */
/* inside this macro definition turn into null statements   */
/* in production builds when debugger support is turned off */

#define RESCHEDULE {                            \
    INC_RESHED                                  \
    checkRescheduleValid();                     \
    if (isTimeToReschedule()) {                 \
        VMSAVE                                  \
        reschedule();                           \
        VMRESTORE                               \
    }                                           \
}

#endif /* ENABLE_JAVA_DEBUGGER */

/*=========================================================================
 * BRANCHIF - Macro to cause a branch if a condition is true
 *=======================================================================*/

#if COMMONBRANCHING
#define BRANCHIF(cond) { if(cond) { goto branchPoint; } else { goto next3; } }
#else
#define BRANCHIF(cond) { ip += (cond) ? getShort(ip + 1) : 3; goto reschedulePoint; }
#endif

/*=========================================================================
 * NOTIMPLEMENTED - Macro to pad out the jump table as an option
 *=======================================================================*/

#if PADTABLE
#define NOTIMPLEMENTED(x) case x: { goto notImplemented; }
#else
#define NOTIMPLEMENTED(x) /**/
#endif

/*=========================================================================
 * CLEAR - Zero a variable for safety only
 *=======================================================================*/

#if INCLUDEDEBUGCODE
#define CLEAR(x) { (x) = 0; }
#else
#define CLEAR(x) /**/
#endif

/*=========================================================================
 * SAVEIP/RESTOREIP - Macros to spill and load the ip machine register
 *=======================================================================*/

#if IPISLOCAL
#define SAVEIP    ip_global = ip; CLEAR(ip);
#define RESTOREIP ip = ip_global; CLEAR(ip_global);
#else
#define SAVEIP    /**/
#define RESTOREIP /**/
#endif

/*=========================================================================
 * SAVEFP/RESTOREFP - Macros to spill and load the fp machine register
 *=======================================================================*/

#if FPISLOCAL
#define SAVEFP    fp_global = fp; CLEAR(fp);
#define RESTOREFP fp = fp_global; CLEAR(fp_global);
#else
#define SAVEFP    /**/
#define RESTOREFP /**/
#endif

/*=========================================================================
 * SAVESP/RESTORESP - Macros to spill and load the sp machine register
 *=======================================================================*/

#if SPISLOCAL
#define SAVESP    sp_global = sp; CLEAR(sp);
#define RESTORESP sp = sp_global; CLEAR(sp_global);
#else
#define SAVESP    /**/
#define RESTORESP /**/
#endif

/*=========================================================================
 * SAVELP/RESTORELP - Macros to spill and load the lp machine register
 *=======================================================================*/

#if LPISLOCAL
#define SAVELP    lp_global = lp; CLEAR(lp);
#define RESTORELP lp = lp_global; CLEAR(lp_global);
#else
#define SAVELP    /**/
#define RESTORELP /**/
#endif

/*=========================================================================
 * SAVECP/RESTORECP - Macros to spill and load the cp machine register
 *=======================================================================*/

#if CPISLOCAL
#define SAVECP    cp_global = cp; CLEAR(cp);
#define RESTORECP cp = cp_global; CLEAR(cp_global);
#else
#define SAVECP    /**/
#define RESTORECP /**/
#endif


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?