SpiderMonkey is the JavaScript VM embedded in Mozilla firefox . TraceMonkey is a scheme in SpiderMonkey to turn some JavaScript hot code to native instructions in order to make it run fast. It was been developed by Andreas Gal etc in mozilla and the paper about it was published on PLDI,2009. The paper was named :Trace-based Just-in-Time Type Specialization for Dynamic Languages.
TraceMonkey simply identifies loop back edges and do the optimization only on loops. every loop back edge is a potential trace point.The loop becomes hot on its second iteration,so TraceMonkey records the code along the trace in a low-level compiler intermediate representation LIR(In Nanojit, LIR is the source language for compilation to machine code. LIR stands for low-level intermediate representation.) .TraceMonkey stops recording when execution returns to the loop header or exits the loop.After recording is finished,TraceMonkey compiles the trace to native code using the recorded type information for optimization.These code can be entered if the interpreter PC and the types of values match those observed when trace recording was started. Continue reading »
近期评论