CacheFlush,ctiTrampoline, ctiVMThrowTrampoline & ctiOpThrowNotCaught
JS--Lexer-->Token--bison-->Node--emitBytecode-->ByteCode--JIT 编译---->NativeCode-->JIT 执行.
JS的执行是分段执行的,但每次都是把当前段的代码全部编译,这是与TraceMonkey不一样的地方。
these are the entry/leave functions which implemented in assembly for all ports. It
is faster this way. (Previously, the jit generated these functions, but the reviewers convinced us to do this way)
JIT has a fixed stack layout (see JITStubs.h : struct JITStackFrame). The cti trampolines setup and cleanup the necessary stack layout (since the JIT code assumes the stack layout has already been initialized)
cti = context threaded interpreter jit = just-in-time compiler Basically cti refers to C++ implementation of opcodes.
ctiTrampoline: wrapper (helper) function to call the JIT code from C++
ctiVMThrowTrampoline: wrapper (helper) function to call the cti_wmThrow (exception handling function) from the JIT.
ctiOpThrowNotCaught: return to C++ if an exception is unhandled by the JIT code. Kinda side exit.
> ctiTrampoline
从c、c++代码执行进入到JIT Generated Code.ctiTrampoline 功能:设置 stack frame, preserves registers, etc,JIT c、c++代码<span lang="ZH-CN" style="" color:#222222;"="">功能:查找需要被恢复执行的异常处理函数
To perform certain operations the JIT will call back into C code.
Usually the C callback can just return in a perfectly normal fashion
and continue execution once it has completed, however in the case that
an exception is thrown special handling is required to change the
control flow. The return address of the C callback is instead changed
to point to this, and this piece of code handles looking up the
exception handler at which execution will be resumed.
> ctiOpThrowNotCaught
异常未处理后需要的后续动作,中止JIT 执行。This is used to from within cti_op_throw, which implements the 'throw'
keyword in JavaScript. The cti_op_throw method will attempt to look
up a handler routine that catches the exception. However if the
exception is not caught it is necessary to force an early termination
of JIT execution. The cti_op_throw C callback always modifies its
return address, either to point to the code for the appropriate
exception handler to catch the exception, or to ctiOpThrowNotCaught if
no handler is found.
cti_##op:This is referring to the callbacks from JIT code defined in JITStubs.cpp.These methods have their signatures defined by the DEFINE_STUB_FUNCTION macros, which prefix cti_ to the function names.