tamarin中interpter的一点分析

来源:互联网 发布:韦德历届总决赛数据 编辑:程序博客网 时间:2024/06/05 00:49
#ifdef AVMPLUS_WORD_CODE

#  if defined AVMPLUS_DIRECT_THREADED //可以直接线程化
#    if defined GNUC_THREADING  // linux下的宏
#      define INSTR(op)       L_##op:  VERBOSE;    放置虚拟指令标签
#      define NEXT            goto *(*pc++)
#    elif defined MSVC_X86_REWRITE_THREADING //switch和标签相结合
#      define INSTR(op)       case WOP_##op: L_ ## op: VERBOSE;
#      define NEXT            continue
#    elif defined MSVC_X86_ASM_THREADING //直接分发,要对abc码预处理
#      define INSTR(op)       L_ ## op: VERBOSE;
#      define NEXT __asm { \
                __asm mov ebx, pc \ //pc指向的是指令的地址
                __asm mov eax, [ebx] \
                __asm add ebx, 4 \
                __asm mov pc, ebx \
                __asm jmp eax \
           }
#    endif // threading discipline
#  else // AVMPLUS_DIRECT_THREADED
#    define INSTR(op)       case WOP_##op: VERBOSE;
#    define NEXT            continue
#  endif
        
#  define U30ARG            (*pc++)
#  define U8ARG             (*pc++)
#  define S24ARG            (intptr_t)(*pc++)
#  ifdef DEBUGGER
     // expc is visible outside this function, so make sure it's correct.
     // It's probably possible to adjust it on demand outside the function too,
     // because code that accesses it will have access to "info" and can
     // perform the adjustment.
#    define SAVE_EXPC         expc = pc-1-info->word_code_start()
#    define SAVE_EXPC_S24     expc = pc-2-info->word_code_start()
#  else
     // Adjusted on demand in the CATCH clause.  Reduces size of interpreter function
     // by 2.5KB of object code (x86 / gcc4.0 / -O3).
#    define SAVE_EXPC         expc = (intptr_t)pc
#    define SAVE_EXPC_S24     expc = (intptr_t)(pc-1)
#  endif

#else // !AVMPLUS_WORD_CODE

#  define INSTR(op) case OP_##op: VERBOSE;

#  define NEXT              continue
#  define U30ARG            (tmp_pc=pc, tmp_u30 = uint32_t(readU30(tmp_pc)), pc = tmp_pc, tmp_u30)
#  define U8ARG             (*pc++)
#  define S24ARG            (pc+=3, readS24(pc-3))
#  define SAVE_EXPC            expc = pc-1-codeStart
#  define SAVE_EXPC_S24     expc = pc-4-codeStart

#endif // AVMPLUS_WORD_CODE
原创粉丝点击