tamarin中interpter的一点分析

本文深入解析了AVMPLUS字节码指令的优化策略,包括线程化处理、不同编译器环境下的指令标签定义、以及针对不同场景的指令执行方式。通过分析AVMPLUS在不同条件下的指令实现细节,揭示了其如何在提高代码执行效率的同时,保持代码的清晰性和可维护性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

#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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值