JIT编译以及执行的相关函数:
//Baseline
if (jit::IsBaselineEnabled(cx)) {
//Enter Baseline at branch
jit::MethodStatus status = jit::CanEnterBaselineAtBranch(cx, REGS.fp(), false);
if (status == jit::Method_Compiled) {
jit::EnterBaselineAtBranch(cx, REGS.fp(), REGS.pc);
}
//Enter Baseline method
jit::MethodStatus status = jit::CanEnterBaselineMethod(cx, state);
if (status == jit::Method_Compiled) {
jit::JitExecStatus status = jit::EnterBaselineMethod(cx, state);
}
}
//Ion
if (!createSingleton && jit::IsIonEnabled(cx)) {
jit::MethodStatus status = jit::CanEnter(cx, state.ref());
if (status == jit::Method_Compiled) {
jit::JitExecStatus exec = jit::IonCannon(cx, state.ref());
}
}
在RunScript()以及它调用的Interpret()里面都会执行以上逻辑。RunScript调用树如图: