Tamarin Execution Flow

Tamarin Central's architecture seems relativley straightfoward. Tamarin directly executes ActionScript ByteCode instead of converting it to another intermediate representation. You can read all of the opcodes and their definitions in the AVM2 Overview. The overview is a bit out of date as a few opcodes have been added such as finddef. Tamarin predetermines if a function should be compiled or interpreted with a flag in the MethodInfo object. If the SUGGEST_INTERP bit is set, a method is interpreted, otherwise it is compiled into native code. So far, it seems that Tamarin compiles all methods other than the init methods. The init methods are set to be interpreted during ABC parsing:


// suggest that we don't jit the $init methods

When a method is called, if it is to be interpreted, the ABC is verified and is directly executed. Tamarin contains a direct threaded interpreter for GCC and a standard switch loop for Windows. If a method is slated for compilation, the ABC is translated to LIR during the verification stage. ABC is translated into LIR one opcode at a time. The LIR is passed into an NanoJit and compiled. The location of the native code is stored in the MethodInfo instance. The compiled code is then executed.
MethodInfo::verifyEnter(MethodEnv* env, int argc, uint32* ap)
MethodInfo* f = env->method;
f->verify(env->toplevel()); // convert to LIR and Compile

return f->impl32()(env, argc, ap); // impl32 points the address of the JIT code