mirror of
https://github.com/pdf2htmlEX/pdf2htmlEX.git
synced 2024-12-22 13:00:08 +00:00
2 lines
44 KiB
Plaintext
2 lines
44 KiB
Plaintext
<div class="pd w0 h0"><div id="pf8" class="pf" data-page-no="8"><div class="pc pc8"><img class="bi x32 y5 w1 h1d" alt="" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAd4AAACpCAIAAAAKrMtZAAAACXBIWXMAABYlAAAWJQFJUiTwAAAB/ElEQVR42u3dsQ2AMBRDQcz+G//CzECBSOBuAmSkpyhN0vZYVZKVP88ywENOEwBIMwDSDCDNAEgzgDQDIM0A0gyANAMgzQDSDIA0A0gzANIMIM0ASDOANAMgzQBIM8BmPDEHsFqW49nWHVkGvs2FBoA0AyDNANIMgDQDSDMA0gwgzQBIMwDSDCDNAEgzgDQDIM0A0gyANANIMwDSDIA0A0gzANIMIM0ASDOANAMgzQBIM4A0AyDNANIMgDQDSDMA0gwgzQBIMwDSDCDNAEgzgDQDIM0A0gyANAMgzQDSDIA0A0gzANIMIM0ASDOANAMgzQBIM4A0AyDNANIMgDQDSDMA0gyANANIMwDSDCDNAEgzgDQDIM0A0gyANAMgzQDSDIA0A0gzANIMIM0ASDMA0gwgzQBIM4A0AyDNANIMgDQDSDMA0gyANANIMwDSDCDNAEgzgDQDIM0ASDOANAMgzQDSDIA0A0gzANIMIM0ASDMA0gwgzQBIM4A0AyDNANIMgDQDIM0A0gyANANIMwDSDCDNAEgzgDQDIM0ASDOANAMgzQDSDIA0A0gzANIMgDQDSDMA0gwgzQBIM4A0AyDNANIMgDQDIM0A0gyANANIMwDSDCDNAEgzgDSbAECab5gZf8gy8ENpawUAp2YApBlAmgGQZgBpBkCaAQDgTRdc4iIf/WoXWAAAAABJRU5ErkJggg=="/><div class="t m0 x2f hc y5b ff1 fs3 fc0 sc0 ls0 ws0">5.1<span class="_ _9"> </span>Optimizations</div><div class="t m0 x2f h5 y1e2 ff2 fs3 fc0 sc0 ls0 ws0">Because<span class="_ _d"> </span>traces<span class="_ _d"> </span>are<span class="_ _8"> </span>in<span class="_ _d"> </span>SSA<span class="_ _d"> </span>form<span class="_ _d"> </span>and<span class="_ _d"> </span>hav<span class="_ _2"></span>e<span class="_ _d"> </span>no<span class="_ _8"> </span>join<span class="_ _d"> </span>points<span class="_ _d"> </span>or<span class="_ _d"> </span><span class="fff">φ</span>-</div><div class="t m0 x2f h5 y1e3 ff2 fs3 fc0 sc0 ls0 ws0">nodes,<span class="_ _d"> </span>certain<span class="_ _d"> </span>optimizations<span class="_ _d"> </span>are<span class="_ _d"> </span>easy<span class="_ _d"> </span>to<span class="_ _8"> </span>implement.<span class="_ _d"> </span>In<span class="_ _d"> </span>order<span class="_ _d"> </span>to</div><div class="t m0 x2f h5 y1e4 ff2 fs3 fc0 sc0 ls0 ws0">get<span class="_ _3"> </span>good<span class="_ _5"> </span>startup<span class="_ _3"> </span>performance,<span class="_ _3"> </span>the<span class="_ _3"> </span>optimizations<span class="_ _5"> </span>must<span class="_ _3"> </span>run<span class="_ _3"> </span>quickly<span class="_ _b"></span>,</div><div class="t m0 x2f h5 y1e5 ff2 fs3 fc0 sc0 ls0 ws0">so<span class="_ _d"> </span>we<span class="_ _d"> </span>chose<span class="_ _d"> </span>a<span class="_ _d"> </span>small<span class="_ _d"> </span>set<span class="_ _d"> </span>of<span class="_ _8"> </span>optimizations.<span class="_ _d"> </span>W<span class="_ _2"></span>e<span class="_ _8"> </span>implemented<span class="_ _d"> </span>the</div><div class="t m0 x2f h5 y1e6 ff2 fs3 fc0 sc0 ls0 ws0">optimizations<span class="_ _3"> </span>as<span class="_ _5"> </span>pipelined<span class="_ _5"> </span>filters<span class="_ _3"> </span>so<span class="_ _5"> </span>that<span class="_ _3"> </span>the<span class="_ _2"></span>y<span class="_ _5"> </span>can<span class="_ _3"> </span>be<span class="_ _5"> </span>turned<span class="_ _3"> </span>on<span class="_ _5"> </span>and</div><div class="t m0 x2f h5 y3 ff2 fs3 fc0 sc0 ls0 ws0">off<span class="_ _3"> </span>independently<span class="_ _b"></span>,<span class="_ _3"> </span>and<span class="_ _3"> </span>yet<span class="_ _3"> </span>all<span class="_ _3"> </span>run<span class="_ _3"> </span>in<span class="_ _3"> </span>just<span class="_ _3"> </span>two<span class="_ _3"> </span>loop<span class="_ _3"> </span>passes<span class="_ _3"> </span>ov<span class="_ _2"></span>er<span class="_ _3"> </span>the</div><div class="t m0 x2f h5 y1e7 ff2 fs3 fc0 sc0 ls0 ws0">trace:<span class="_ _5"> </span>one<span class="_ _5"> </span>forward<span class="_ _5"> </span>and<span class="_ _3"> </span>one<span class="_ _5"> </span>backw<span class="_ _2"></span>ard.</div><div class="t m0 x34 h5 y1e8 ff2 fs3 fc0 sc0 ls0 ws0">Every<span class="_ _6"> </span>time<span class="_ _6"> </span>the<span class="_ _6"> </span>trace<span class="_ _6"> </span>recorder<span class="_ _6"> </span>emits<span class="_ _6"> </span>a<span class="_ _8"> </span>LIR<span class="_ _6"> </span>instruction,<span class="_ _6"> </span>the<span class="_ _6"> </span>in-</div><div class="t m0 x2f h5 y6 ff2 fs3 fc0 sc0 ls0 ws0">struction<span class="_ _d"> </span>is<span class="_ _8"> </span>immediately<span class="_ _d"> </span>passed<span class="_ _d"> </span>to<span class="_ _d"> </span>the<span class="_ _8"> </span>first<span class="_ _d"> </span>filter<span class="_ _d"> </span>in<span class="_ _d"> </span>the<span class="_ _8"> </span>forward</div><div class="t m0 x2f h5 y1e9 ff2 fs3 fc0 sc0 ls0 ws0">pipeline.<span class="_ _6"> </span>Thus,<span class="_ _8"> </span>forward<span class="_ _6"> </span>filter<span class="_ _8"> </span>optimizations<span class="_ _8"> </span>are<span class="_ _8"> </span>performed<span class="_ _6"> </span>as<span class="_ _8"> </span>the</div><div class="t m0 x2f h5 y1ea ff2 fs3 fc0 sc0 ls0 ws0">trace<span class="_ _3"> </span>is<span class="_ _3"> </span>recorded.<span class="_ _5"> </span>Each<span class="_ _3"> </span>filter<span class="_ _3"> </span>may<span class="_ _5"> </span>pass<span class="_ _3"> </span>each<span class="_ _3"> </span>instruction<span class="_ _3"> </span>to<span class="_ _5"> </span>the<span class="_ _3"> </span>next</div><div class="t m0 x2f h5 y1eb ff2 fs3 fc0 sc0 ls0 ws0">filter<span class="_ _6"> </span>unchanged,<span class="_ _3"> </span>write<span class="_ _6"> </span>a<span class="_ _3"> </span>different<span class="_ _6"> </span>instruction<span class="_ _3"> </span>to<span class="_ _6"> </span>the<span class="_ _6"> </span>ne<span class="_ _2"></span>xt<span class="_ _3"> </span>filter,<span class="_ _3"> </span>or</div><div class="t m0 x2f h5 y1bd ff2 fs3 fc0 sc0 ls0 ws0">write<span class="_ _3"> </span>no<span class="_ _3"> </span>instruction<span class="_ _3"> </span>at<span class="_ _3"> </span>all.<span class="_ _3"> </span>For<span class="_ _3"> </span>e<span class="_ _2"></span>xample,<span class="_ _3"> </span>the<span class="_ _3"> </span>constant<span class="_ _3"> </span>folding<span class="_ _3"> </span>filter</div><div class="t m0 x2f h5 y1be ff2 fs3 fc0 sc0 ls0 ws0">can<span class="_ _3"> </span>replace<span class="_ _3"> </span>a<span class="_ _3"> </span>multiply<span class="_ _3"> </span>instruction<span class="_ _3"> </span>like<span class="_ _3"> </span><span class="fff">v</span></div><div class="t m0 x9f h8 yd ff8 fs4 fc0 sc0 ls0 ws0">13</div><div class="t m0 xa0 h7 y1be ff14 fs3 fc0 sc0 ls0 ws0">:=<span class="_ _8"> </span><span class="fff">mul </span>3<span class="fff">,<span class="_ _5"> </span></span>1000<span class="_ _5"> </span><span class="ff2">with<span class="_ _6"> </span>a</span></div><div class="t m0 x2f h5 y1bf ff2 fs3 fc0 sc0 ls0 ws0">constant<span class="_ _5"> </span>instruction<span class="_ _5"> </span><span class="fff">v</span></div><div class="t m0 x64 h8 y1ec ff8 fs4 fc0 sc0 ls0 ws0">13</div><div class="t m0 xa1 h7 y1bf ff14 fs3 fc0 sc0 ls0 ws0">=<span class="_ _3"> </span>3000<span class="ff2">.</span></div><div class="t m0 x34 h5 y1c0 ff2 fs3 fc0 sc0 ls0 ws0">W<span class="_ _b"></span>e<span class="_ _5"> </span>currently<span class="_ _3"> </span>apply<span class="_ _5"> </span>four<span class="_ _5"> </span>forward<span class="_ _5"> </span>filters:</div><div class="t m0 x36 h4 y6d ff3 fs2 fc0 sc0 ls0 ws0">•</div><div class="t m0 x37 h5 y1ed ff2 fs3 fc0 sc0 ls0 ws0">On<span class="_ _6"> </span>ISAs<span class="_ _8"> </span>without<span class="_ _8"> </span>floating-point<span class="_ _6"> </span>instructions,<span class="_ _8"> </span>a<span class="_ _8"> </span>soft-float<span class="_ _6"> </span>filter</div><div class="t m0 x37 h5 y113 ff2 fs3 fc0 sc0 ls0 ws0">con<span class="_ _2"></span>verts<span class="_ _5"> </span>floating-point<span class="_ _5"> </span>LIR<span class="_ _5"> </span>instructions<span class="_ _5"> </span>to<span class="_ _5"> </span>sequences<span class="_ _5"> </span>of<span class="_ _3"> </span>inte<span class="_ _2"></span>ger</div><div class="t m0 x37 h5 y114 ff2 fs3 fc0 sc0 ls0 ws0">instructions.</div><div class="t m0 x36 h4 y1ee ff3 fs2 fc0 sc0 ls0 ws0">•</div><div class="t m0 x37 h5 y1ef ff2 fs3 fc0 sc0 ls0 ws0">CSE<span class="_ _5"> </span>(constant<span class="_ _5"> </span>subexpression<span class="_ _5"> </span>elimination),</div><div class="t m0 x36 h4 ye1 ff3 fs2 fc0 sc0 ls0 ws0">•</div><div class="t m0 x37 h5 y1f0 ff2 fs3 fc0 sc0 ls0 ws0">expression<span class="_ _5"> </span>simplification,<span class="_ _3"> </span>including<span class="_ _5"> </span>constant<span class="_ _5"> </span>folding<span class="_ _3"> </span>and<span class="_ _5"> </span>a<span class="_ _5"> </span>few</div><div class="t m0 x37 h7 y1f1 ff2 fs3 fc0 sc0 ls0 ws0">algebraic<span class="_ _5"> </span>identities<span class="_ _5"> </span>(e.g.,<span class="_ _3"> </span><span class="fff">a<span class="_ _7"> </span><span class="ff6">−<span class="_ _5"> </span></span>a<span class="_ _3"> </span><span class="ff14">=<span class="_ _3"> </span>0</span></span>),<span class="_ _5"> </span>and</div><div class="t m0 x36 h4 y1f2 ff3 fs2 fc0 sc0 ls0 ws0">•</div><div class="t m0 x37 h5 y1f3 ff2 fs3 fc0 sc0 ls0 ws0">source<span class="_ _1"> </span>language<span class="_ _1"> </span>semantic-specific<span class="_ _e"> </span>e<span class="_ _2"></span>xpression<span class="_ _1"> </span>simplification,</div><div class="t m0 x37 h5 y1f4 ff2 fs3 fc0 sc0 ls0 ws0">primarily<span class="_ _5"> </span>algebraic<span class="_ _5"> </span>identities<span class="_ _5"> </span>that<span class="_ _7"> </span>allow<span class="_ _5"> </span><span class="fse">D<span class="_ _4"></span>O<span class="_ _4"></span>U<span class="_ _4"></span>B<span class="_ _4"></span>L<span class="_ _4"></span>E<span class="_ _5"> </span></span>to<span class="_ _5"> </span>be<span class="_ _5"> </span>replaced</div><div class="t m0 x37 h5 y1f5 ff2 fs3 fc0 sc0 ls0 ws0">with<span class="_ _3"> </span><span class="fse">I<span class="_ _4"></span>N<span class="_ _4"></span>T</span>.<span class="_ _3"> </span>F<span class="_ _2"></span>or<span class="_ _3"> </span>e<span class="_ _2"></span>xample,<span class="_ _3"> </span>LIR<span class="_ _5"> </span>that<span class="_ _3"> </span>con<span class="_ _2"></span>v<span class="_ _2"></span>erts<span class="_ _5"> </span>an<span class="_ _3"> </span><span class="fse">I<span class="_ _4"></span>N<span class="_ _4"></span>T<span class="_ _3"> </span></span>to<span class="_ _3"> </span>a<span class="_ _3"> </span><span class="fse">D<span class="_ _4"></span>O<span class="_ _4"></span>UB<span class="_ _4"></span>L<span class="_ _4"></span>E</span></div><div class="t m0 x37 h5 y1f6 ff2 fs3 fc0 sc0 ls0 ws0">and<span class="_ _5"> </span>then<span class="_ _5"> </span>back<span class="_ _3"> </span>ag<span class="_ _2"></span>ain<span class="_ _5"> </span>would<span class="_ _5"> </span>be<span class="_ _5"> </span>removed<span class="_ _5"> </span>by<span class="_ _5"> </span>this<span class="_ _5"> </span>filter<span class="_ _2"></span>.</div><div class="t m0 x34 h5 y1f7 ff2 fs3 fc0 sc0 ls0 ws0">When<span class="_ _3"> </span>trace<span class="_ _3"> </span>recording<span class="_ _3"> </span>is<span class="_ _3"> </span>completed,<span class="_ _3"> </span>nanojit<span class="_ _6"> </span>runs<span class="_ _3"> </span>the<span class="_ _3"> </span>backward</div><div class="t m0 x2f h5 y1f8 ff2 fs3 fc0 sc0 ls0 ws0">optimization<span class="_ _6"> </span>filters.<span class="_ _3"> </span>These<span class="_ _6"> </span>are<span class="_ _6"> </span>used<span class="_ _3"> </span>for<span class="_ _6"> </span>optimizations<span class="_ _6"> </span>that<span class="_ _3"> </span>require</div><div class="t m0 x2f h5 y1f9 ff2 fs3 fc0 sc0 ls0 ws0">backward<span class="_ _8"> </span>program<span class="_ _8"> </span>analysis.<span class="_ _d"> </span>When<span class="_ _6"> </span>running<span class="_ _d"> </span>the<span class="_ _8"> </span>backward<span class="_ _8"> </span>filters,</div><div class="t m0 x2f h5 y1fa ff2 fs3 fc0 sc0 ls0 ws0">nanojit<span class="_ _5"> </span>reads<span class="_ _7"> </span>one<span class="_ _5"> </span>LIR<span class="_ _5"> </span>instruction<span class="_ _7"> </span>at<span class="_ _5"> </span>a<span class="_ _5"> </span>time,<span class="_ _7"> </span>and<span class="_ _5"> </span>the<span class="_ _5"> </span>reads<span class="_ _7"> </span>are<span class="_ _5"> </span>passed</div><div class="t m0 x2f h5 y1fb ff2 fs3 fc0 sc0 ls0 ws0">through<span class="_ _5"> </span>the<span class="_ _5"> </span>pipeline.</div><div class="t m0 x34 h5 y1fc ff2 fs3 fc0 sc0 ls0 ws0">W<span class="_ _b"></span>e<span class="_ _5"> </span>currently<span class="_ _3"> </span>apply<span class="_ _5"> </span>three<span class="_ _5"> </span>backward<span class="_ _5"> </span>filters:</div><div class="t m0 x36 h4 y1fd ff3 fs2 fc0 sc0 ls0 ws0">•</div><div class="t m0 x37 h5 yef ff2 fs3 fc0 sc0 ls0 ws0">Dead<span class="_ _5"> </span>data-stack<span class="_ _5"> </span>store<span class="_ _7"> </span>elimination.<span class="_ _5"> </span>The<span class="_ _5"> </span>LIR<span class="_ _5"> </span>trace<span class="_ _7"> </span>encodes<span class="_ _5"> </span>many</div><div class="t m0 x37 h5 yf0 ff2 fs3 fc0 sc0 ls0 ws0">stores<span class="_ _3"> </span>to<span class="_ _5"> </span>locations<span class="_ _3"> </span>in<span class="_ _5"> </span>the<span class="_ _3"> </span>interpreter<span class="_ _3"> </span>stack.<span class="_ _5"> </span>But<span class="_ _3"> </span>these<span class="_ _5"> </span>values<span class="_ _5"> </span>are</div><div class="t m0 x37 h5 yf1 ff2 fs3 fc0 sc0 ls0 ws0">nev<span class="_ _2"></span>er<span class="_ _3"> </span>read<span class="_ _6"> </span>back<span class="_ _6"> </span>before<span class="_ _6"> </span>e<span class="_ _2"></span>xiting<span class="_ _6"> </span>the<span class="_ _3"> </span>trace<span class="_ _6"> </span>(by<span class="_ _6"> </span>the<span class="_ _3"> </span>interpreter<span class="_ _6"> </span>or</div><div class="t m0 x37 h5 yf2 ff2 fs3 fc0 sc0 ls0 ws0">another<span class="_ _d"> </span>trace).<span class="_ _8"> </span>Thus,<span class="_ _d"> </span>stores<span class="_ _8"> </span>to<span class="_ _d"> </span>the<span class="_ _d"> </span>stack<span class="_ _8"> </span>that<span class="_ _d"> </span>are<span class="_ _8"> </span>overwritten</div><div class="t m0 x37 h5 yf3 ff2 fs3 fc0 sc0 ls0 ws0">before<span class="_ _6"> </span>the<span class="_ _8"> </span>next<span class="_ _6"> </span>exit<span class="_ _8"> </span>are<span class="_ _6"> </span>dead.<span class="_ _8"> </span>Stores<span class="_ _8"> </span>to<span class="_ _6"> </span>locations<span class="_ _8"> </span>that<span class="_ _8"> </span>are<span class="_ _6"> </span>off</div><div class="t m0 x37 h5 y1fe ff2 fs3 fc0 sc0 ls0 ws0">the<span class="_ _5"> </span>top<span class="_ _5"> </span>of<span class="_ _3"> </span>the<span class="_ _5"> </span>interpreter<span class="_ _5"> </span>stack<span class="_ _5"> </span>at<span class="_ _5"> </span>future<span class="_ _5"> </span>exits<span class="_ _5"> </span>are<span class="_ _5"> </span>also<span class="_ _3"> </span>dead.</div><div class="t m0 x36 h4 y1ff ff3 fs2 fc0 sc0 ls0 ws0">•</div><div class="t m0 x37 h5 y200 ff2 fs3 fc0 sc0 ls0 ws0">Dead<span class="_ _5"> </span>call-stack<span class="_ _5"> </span>store<span class="_ _7"> </span>elimination.<span class="_ _5"> </span>This<span class="_ _5"> </span>is<span class="_ _7"> </span>the<span class="_ _5"> </span>same<span class="_ _5"> </span>optimization</div><div class="t m0 x37 h5 y201 ff2 fs3 fc0 sc0 ls0 ws0">as<span class="_ _3"> </span>abo<span class="_ _2"></span>ve,<span class="_ _3"> </span>e<span class="_ _2"></span>xcept<span class="_ _3"> </span>applied<span class="_ _5"> </span>to<span class="_ _3"> </span>the<span class="_ _3"> </span>interpreter’<span class="_ _2"></span>s<span class="_ _5"> </span>call<span class="_ _3"> </span>stack<span class="_ _3"> </span>used<span class="_ _3"> </span>for</div><div class="t m0 x37 h5 y202 ff2 fs3 fc0 sc0 ls0 ws0">function<span class="_ _5"> </span>call<span class="_ _5"> </span>inlining.</div><div class="t m0 x36 h4 y48 ff3 fs2 fc0 sc0 ls0 ws0">•</div><div class="t m0 x37 h5 y12d ff2 fs3 fc0 sc0 ls0 ws0">Dead<span class="_ _e"> </span>code<span class="_ _e"> </span>elimination.<span class="_ _e"> </span>This<span class="_ _e"> </span>eliminates<span class="_ _e"> </span>an<span class="_ _2"></span>y<span class="_ _e"> </span>operation<span class="_ _e"> </span>that</div><div class="t m0 x37 h5 y27 ff2 fs3 fc0 sc0 ls0 ws0">stores<span class="_ _5"> </span>to<span class="_ _5"> </span>a<span class="_ _3"> </span>v<span class="_ _2"></span>alue<span class="_ _5"> </span>that<span class="_ _5"> </span>is<span class="_ _5"> </span>nev<span class="_ _2"></span>er<span class="_ _5"> </span>used.</div><div class="t m0 x34 h5 y203 ff2 fs3 fc0 sc0 ls0 ws0">After<span class="_ _d"> </span>a<span class="_ _1"> </span>LIR<span class="_ _d"> </span>instruction<span class="_ _d"> </span>is<span class="_ _d"> </span>successfully<span class="_ _1"> </span>read<span class="_ _d"> </span>(“pulled”)<span class="_ _d"> </span>from</div><div class="t m0 x2f h5 y204 ff2 fs3 fc0 sc0 ls0 ws0">the<span class="_ _3"> </span>backward<span class="_ _3"> </span>filter<span class="_ _3"> </span>pipeline,<span class="_ _6"> </span>nanojit’<span class="_ _b"></span>s<span class="_ _6"> </span>code<span class="_ _3"> </span>generator<span class="_ _3"> </span>emits<span class="_ _3"> </span>native</div><div class="t m0 x2f h5 y1dc ff2 fs3 fc0 sc0 ls0 ws0">machine<span class="_ _5"> </span>instruction(s)<span class="_ _5"> </span>for<span class="_ _3"> </span>it.</div><div class="t m0 x2f hc yfc ff1 fs3 fc0 sc0 ls0 ws0">5.2<span class="_ _9"> </span>Register<span class="_ _5"> </span>Allocation</div><div class="t m0 x2f h5 y205 ff2 fs3 fc0 sc0 ls0 ws0">W<span class="_ _b"></span>e<span class="_ _1"> </span>use<span class="_ _1"> </span>a<span class="_ _1"> </span>simple<span class="_ _d"> </span>greedy<span class="_ _1"> </span>register<span class="_ _1"> </span>allocator<span class="_ _d"> </span>that<span class="_ _1"> </span>makes<span class="_ _1"> </span>a<span class="_ _d"> </span>single</div><div class="t m0 x2f h5 y94 ff2 fs3 fc0 sc0 ls0 ws0">backward<span class="_ _6"> </span>pass<span class="_ _6"> </span>ov<span class="_ _2"></span>er<span class="_ _6"> </span>the<span class="_ _6"> </span>trace<span class="_ _6"> </span>(it<span class="_ _6"> </span>is<span class="_ _8"> </span>integrated<span class="_ _6"> </span>with<span class="_ _6"> </span>the<span class="_ _6"> </span>code<span class="_ _6"> </span>gen-</div><div class="t m0 x2f h5 y95 ff2 fs3 fc0 sc0 ls0 ws0">erator).<span class="_ _6"> </span>By<span class="_ _8"> </span>the<span class="_ _6"> </span>time<span class="_ _8"> </span>the<span class="_ _6"> </span>allocator<span class="_ _8"> </span>has<span class="_ _6"> </span>reached<span class="_ _8"> </span>an<span class="_ _6"> </span>instruction<span class="_ _8"> </span>like</div><div class="t m0 x2f h5 y96 fff fs3 fc0 sc0 ls0 ws0">v</div><div class="t m0 x36 h8 y206 ff8 fs4 fc0 sc0 ls0 ws0">3</div><div class="t m0 x34 h7 y96 ff14 fs3 fc0 sc0 ls0 ws0">=<span class="_ _3"> </span><span class="fff">add<span class="_ _3"> </span>v</span></div><div class="t m0 xa2 h8 y206 ff8 fs4 fc0 sc0 ls0 ws0">1</div><div class="t m0 x4c h5 y96 fff fs3 fc0 sc0 ls0 ws0">,<span class="_ _7"> </span>v</div><div class="t m0 x94 h8 y206 ff8 fs4 fc0 sc0 ls0 ws0">2</div><div class="t m0 xa3 h5 y96 ff2 fs3 fc0 sc0 ls0 ws0">,<span class="_ _3"> </span>it<span class="_ _5"> </span>has<span class="_ _5"> </span>already<span class="_ _3"> </span>assigned<span class="_ _5"> </span>a<span class="_ _3"> </span>register<span class="_ _5"> </span>to<span class="_ _3"> </span><span class="fff">v</span></div><div class="t m0 x5 h8 y206 ff8 fs4 fc0 sc0 ls0 ws0">3</div><div class="t m0 xa4 h5 y96 ff2 fs3 fc0 sc0 ls0 ws0">.<span class="_ _3"> </span>If<span class="_ _5"> </span><span class="fff">v</span></div><div class="t m0 xa5 h8 y206 ff8 fs4 fc0 sc0 ls0 ws0">1</div><div class="t m0 xa6 h5 y96 ff2 fs3 fc0 sc0 ls0 ws0">and</div><div class="t m0 x2f h5 y97 fff fs3 fc0 sc0 ls0 ws0">v</div><div class="t m0 x36 h8 y207 ff8 fs4 fc0 sc0 ls0 ws0">2</div><div class="t m0 x9b h5 y97 ff2 fs3 fc0 sc0 ls0 ws0">hav<span class="_ _2"></span>e<span class="_ _5"> </span>not<span class="_ _5"> </span>yet<span class="_ _3"> </span>been<span class="_ _5"> </span>assigned<span class="_ _5"> </span>registers,<span class="_ _5"> </span>the<span class="_ _5"> </span>allocator<span class="_ _5"> </span>assigns<span class="_ _3"> </span>a<span class="_ _5"> </span>free</div><div class="t m0 x2f h5 y98 ff2 fs3 fc0 sc0 ls0 ws0">register<span class="_ _5"> </span>to<span class="_ _5"> </span>each.<span class="_ _5"> </span>If<span class="_ _5"> </span>there<span class="_ _5"> </span>are<span class="_ _5"> </span>no<span class="_ _5"> </span>free<span class="_ _5"> </span>re<span class="_ _2"></span>gisters,<span class="_ _5"> </span>a<span class="_ _5"> </span>value<span class="_ _5"> </span>is<span class="_ _5"> </span>selected<span class="_ _5"> </span>for</div><div class="t m0 x2f h5 y99 ff2 fs3 fc0 sc0 ls0 ws0">spilling.<span class="_ _3"> </span>W<span class="_ _b"></span>e<span class="_ _3"> </span>use<span class="_ _3"> </span>a<span class="_ _3"> </span>class<span class="_ _3"> </span>heuristic<span class="_ _3"> </span>that<span class="_ _3"> </span>sel<span class="_ _2"></span>ects<span class="_ _3"> </span>the<span class="_ _3"> </span>“oldest”<span class="_ _3"> </span>re<span class="_ _2"></span>gister<span class="_ _2"></span>-</div><div class="t m0 x2f h5 y9a ff2 fs3 fc0 sc0 ls0 ws0">carried<span class="_ _5"> </span>value<span class="_ _5"> </span>(6).</div><div class="t m0 x34 h5 y9b ff2 fs3 fc0 sc0 ls0 ws0">The<span class="_ _5"> </span>heuristic<span class="_ _5"> </span>considers<span class="_ _3"> </span>the<span class="_ _5"> </span>set<span class="_ _5"> </span><span class="fff">R<span class="_ _5"> </span></span>of<span class="_ _3"> </span>v<span class="_ _2"></span>alues<span class="_ _5"> </span><span class="fff">v<span class="_ _3"> </span></span>in<span class="_ _5"> </span>re<span class="_ _2"></span>gisters<span class="_ _5"> </span>imme-</div><div class="t m0 x2f h5 y9c ff2 fs3 fc0 sc0 ls0 ws0">diately<span class="_ _3"> </span>after<span class="_ _3"> </span>the<span class="_ _5"> </span>current<span class="_ _3"> </span>instruction<span class="_ _3"> </span>for<span class="_ _3"> </span>spilling.<span class="_ _5"> </span>Let<span class="_ _3"> </span><span class="fff">v</span></div><div class="t m0 x2c h1b y33 ff10 fs4 fc0 sc0 ls0 ws0">m</div><div class="t m0 xa4 h5 y9c ff2 fs3 fc0 sc0 ls0 ws0">be<span class="_ _3"> </span>the<span class="_ _3"> </span>last</div><div class="t m0 x2f h5 y9d ff2 fs3 fc0 sc0 ls0 ws0">instruction<span class="_ _5"> </span>before<span class="_ _3"> </span>the<span class="_ _5"> </span>current<span class="_ _5"> </span>where<span class="_ _5"> </span>each<span class="_ _3"> </span><span class="fff">v<span class="_ _3"> </span></span>is<span class="_ _5"> </span>referred<span class="_ _5"> </span>to.<span class="_ _5"> </span>Then<span class="_ _3"> </span>the</div><div class="t m0 x8 h5 y208 ff2 fs3 fc0 sc0 ls0 ws0">T<span class="_ _b"></span>ag<span class="_ _22"> </span>JS<span class="_ _5"> </span>T<span class="_ _2"></span>ype<span class="_ _26"> </span>Description</div><div class="t m0 x8 h5 y209 ff2 fs3 fc0 sc0 ls0 ws0">xx1<span class="_ _22"> </span>number<span class="_ _27"> </span>31-bit<span class="_ _5"> </span>integer<span class="_ _5"> </span>representation</div><div class="t m0 x8 h5 y20a ff2 fs3 fc0 sc0 ls0 ws0">000<span class="_ _22"> </span>object<span class="_ _24"> </span>pointer<span class="_ _5"> </span>to<span class="_ _5"> </span>JSObject<span class="_ _3"> </span>handle</div><div class="t m0 x8 h5 y20b ff2 fs3 fc0 sc0 ls0 ws0">010<span class="_ _22"> </span>number<span class="_ _27"> </span>pointer<span class="_ _5"> </span>to<span class="_ _5"> </span>double<span class="_ _3"> </span>handle</div><div class="t m0 x8 h5 y20c ff2 fs3 fc0 sc0 ls0 ws0">100<span class="_ _22"> </span>string<span class="_ _28"> </span>pointer<span class="_ _5"> </span>to<span class="_ _5"> </span>JSString<span class="_ _3"> </span>handle</div><div class="t m0 x8 h5 y20d ff2 fs3 fc0 sc0 ls0 ws0">110<span class="_ _22"> </span>boolean<span class="_ _26"> </span>enumeration<span class="_ _5"> </span>for<span class="_ _5"> </span>null,<span class="_ _3"> </span>undefined,<span class="_ _5"> </span>true,<span class="_ _5"> </span>false</div><div class="t m0 xa7 h5 y20e ff2 fs3 fc0 sc0 ls0 ws0">null,<span class="_ _5"> </span>or</div><div class="t m0 xa7 h5 y20f ff2 fs3 fc0 sc0 ls0 ws0">undefined</div><div class="t m0 x32 hc y210 ff1 fs3 fc0 sc0 ls0 ws0">Figure<span class="_ _6"> </span>9.<span class="_ _1"> </span>T<span class="_ _b"></span>agged<span class="_ _6"> </span>values<span class="_ _6"> </span>in<span class="_ _6"> </span>the<span class="_ _6"> </span>SpiderMonkey<span class="_ _3"> </span>JS<span class="_ _6"> </span>interpreter<span class="_ _b"></span>.</div><div class="t m0 x32 h5 y211 ff2 fs3 fc0 sc0 ls0 ws0">T<span class="_ _b"></span>esting<span class="_ _3"> </span>tags,<span class="_ _3"> </span>unboxing<span class="_ _5"> </span>(extracting<span class="_ _5"> </span>the<span class="_ _3"> </span>untagged<span class="_ _5"> </span>value)<span class="_ _3"> </span>and<span class="_ _5"> </span>boxing</div><div class="t m0 x32 h5 y212 ff2 fs3 fc0 sc0 ls0 ws0">(creating<span class="_ _3"> </span>tagged<span class="_ _5"> </span>values)<span class="_ _5"> </span>are<span class="_ _3"> </span>significant<span class="_ _5"> </span>costs.<span class="_ _3"> </span>A<span class="_ _b"></span>voiding<span class="_ _3"> </span>these<span class="_ _5"> </span>costs</div><div class="t m0 x32 h5 y213 ff2 fs3 fc0 sc0 ls0 ws0">is<span class="_ _5"> </span>a<span class="_ _5"> </span>key<span class="_ _5"> </span>benefit<span class="_ _5"> </span>of<span class="_ _5"> </span>tracing.</div><div class="t m0 x32 h5 y1bf ff2 fs3 fc0 sc0 ls0 ws0">heuristic<span class="_ _6"> </span>selects<span class="_ _3"> </span><span class="fff">v<span class="_ _8"> </span></span>with<span class="_ _6"> </span>minimum<span class="_ _3"> </span><span class="fff">v</span></div><div class="t m0 xa8 h1b y1ec ff10 fs4 fc0 sc0 ls0 ws0">m</div><div class="t m0 xa9 h5 y1bf ff2 fs3 fc0 sc0 ls0 ws0">.<span class="_ _6"> </span>The<span class="_ _3"> </span>motiv<span class="_ _2"></span>ation<span class="_ _3"> </span>is<span class="_ _6"> </span>that<span class="_ _6"> </span>this</div><div class="t m0 x32 h5 y1c0 ff2 fs3 fc0 sc0 ls0 ws0">frees<span class="_ _5"> </span>up<span class="_ _5"> </span>a<span class="_ _3"> </span>re<span class="_ _2"></span>gister<span class="_ _5"> </span>for<span class="_ _5"> </span>as<span class="_ _5"> </span>long<span class="_ _5"> </span>as<span class="_ _3"> </span>possible<span class="_ _5"> </span>gi<span class="_ _2"></span>v<span class="_ _2"></span>en<span class="_ _5"> </span>a<span class="_ _5"> </span>single<span class="_ _5"> </span>spill.</div><div class="t m0 x33 h5 y214 ff2 fs3 fc0 sc0 ls0 ws0">If<span class="_ _8"> </span>we<span class="_ _d"> </span>need<span class="_ _8"> </span>to<span class="_ _d"> </span>spill<span class="_ _8"> </span>a<span class="_ _d"> </span>v<span class="_ _2"></span>alue<span class="_ _8"> </span><span class="fff">v</span></div><div class="t m0 x75 h1b y215 ff10 fs4 fc0 sc0 ls0 ws0">s</div><div class="t m0 xa8 h5 y214 ff2 fs3 fc0 sc0 ls0 ws0">at<span class="_ _8"> </span>this<span class="_ _d"> </span>point,<span class="_ _8"> </span>we<span class="_ _d"> </span>generate<span class="_ _8"> </span>the</div><div class="t m0 x32 h5 y216 ff2 fs3 fc0 sc0 ls0 ws0">restore<span class="_ _d"> </span>code<span class="_ _d"> </span>just<span class="_ _d"> </span>after<span class="_ _d"> </span>the<span class="_ _d"> </span>code<span class="_ _d"> </span>for<span class="_ _d"> </span>the<span class="_ _d"> </span>current<span class="_ _d"> </span>instruction.<span class="_ _d"> </span>The</div><div class="t m0 x32 h5 y217 ff2 fs3 fc0 sc0 ls0 ws0">corresponding<span class="_ _5"> </span>spill<span class="_ _5"> </span>code<span class="_ _5"> </span>is<span class="_ _5"> </span>generated<span class="_ _5"> </span>just<span class="_ _5"> </span>after<span class="_ _5"> </span>the<span class="_ _5"> </span>last<span class="_ _5"> </span>point<span class="_ _5"> </span>where</div><div class="t m0 x32 h5 y1c2 fff fs3 fc0 sc0 ls0 ws0">v</div><div class="t m0 xaa h1b y218 ff10 fs4 fc0 sc0 ls0 ws0">s</div><div class="t m0 xab h5 y1c2 ff2 fs3 fc0 sc0 ls0 ws0">was<span class="_ _5"> </span>used.<span class="_ _5"> </span>The<span class="_ _7"> </span>register<span class="_ _5"> </span>that<span class="_ _5"> </span>was<span class="_ _5"> </span>assigned<span class="_ _7"> </span>to<span class="_ _5"> </span><span class="fff">v</span></div><div class="t m0 xc h1b y218 ff10 fs4 fc0 sc0 ls0 ws0">s</div><div class="t m0 x7b h5 y1c2 ff2 fs3 fc0 sc0 ls0 ws0">is<span class="_ _5"> </span>marked<span class="_ _5"> </span>free<span class="_ _7"> </span>for</div><div class="t m0 x32 h5 y219 ff2 fs3 fc0 sc0 ls0 ws0">the<span class="_ _6"> </span>preceding<span class="_ _6"> </span>code,<span class="_ _6"> </span>because<span class="_ _6"> </span>that<span class="_ _6"> </span>register<span class="_ _3"> </span>can<span class="_ _6"> </span>now<span class="_ _6"> </span>be<span class="_ _6"> </span>used<span class="_ _6"> </span>freely</div><div class="t m0 x32 h5 y21a ff2 fs3 fc0 sc0 ls0 ws0">without<span class="_ _5"> </span>affecting<span class="_ _5"> </span>the<span class="_ _5"> </span>following<span class="_ _5"> </span>code</div><div class="t m0 x32 h9 y21b ff1 fs1 fc0 sc0 ls0 ws0">6.<span class="_ _a"> </span>Implementation</div><div class="t m0 x32 h5 y21c ff2 fs3 fc0 sc0 ls0 ws0">T<span class="_ _b"></span>o<span class="_ _d"> </span>demonstrate<span class="_ _d"> </span>the<span class="_ _d"> </span>effecti<span class="_ _2"></span>v<span class="_ _2"></span>eness<span class="_ _d"> </span>of<span class="_ _d"> </span>our<span class="_ _d"> </span>approach,<span class="_ _8"> </span>we<span class="_ _d"> </span>have<span class="_ _d"> </span>im-</div><div class="t m0 x32 h5 y21d ff2 fs3 fc0 sc0 ls0 ws0">plemented<span class="_ _3"> </span>a<span class="_ _3"> </span>trace-based<span class="_ _3"> </span>dynamic<span class="_ _6"> </span>compiler<span class="_ _3"> </span>for<span class="_ _3"> </span>the<span class="_ _3"> </span>SpiderMonkey</div><div class="t m0 x32 h5 y21e ff2 fs3 fc0 sc0 ls0 ws0">Jav<span class="_ _2"></span>aScript<span class="_ _8"> </span>V<span class="_ _2"></span>irtual<span class="_ _8"> </span>Machine<span class="_ _d"> </span>(4).<span class="_ _d"> </span>SpiderMonk<span class="_ _2"></span>ey<span class="_ _8"> </span>is<span class="_ _d"> </span>the<span class="_ _d"> </span>Ja<span class="_ _2"></span>v<span class="_ _2"></span>aScript</div><div class="t m0 x32 h5 y21f ff2 fs3 fc0 sc0 ls0 ws0">VM<span class="_ _3"> </span>embedded<span class="_ _5"> </span>in<span class="_ _3"> </span>Mozilla’<span class="_ _2"></span>s<span class="_ _5"> </span>Firefox<span class="_ _3"> </span>open-source<span class="_ _3"> </span>web<span class="_ _3"> </span>bro<span class="_ _2"></span>wser<span class="_ _5"> </span>(2),</div><div class="t m0 x32 h5 y220 ff2 fs3 fc0 sc0 ls0 ws0">which<span class="_ _5"> </span>is<span class="_ _7"> </span>used<span class="_ _5"> </span>by<span class="_ _5"> </span>more<span class="_ _7"> </span>than<span class="_ _5"> </span>200<span class="_ _5"> </span>million<span class="_ _7"> </span>users<span class="_ _5"> </span>world-wide.<span class="_ _5"> </span>The<span class="_ _7"> </span>core</div><div class="t m0 x32 h5 y221 ff2 fs3 fc0 sc0 ls0 ws0">of<span class="_ _5"> </span>SpiderMonkey<span class="_ _5"> </span>is<span class="_ _5"> </span>a<span class="_ _5"> </span>bytecode<span class="_ _5"> </span>interpreter<span class="_ _3"> </span>implemented<span class="_ _5"> </span>in<span class="_ _5"> </span>C++.</div><div class="t m0 x33 h5 y222 ff2 fs3 fc0 sc0 ls0 ws0">In<span class="_ _6"> </span>SpiderMonke<span class="_ _2"></span>y<span class="_ _b"></span>,<span class="_ _6"> </span>all<span class="_ _6"> </span>Ja<span class="_ _2"></span>vaScript<span class="_ _3"> </span>values<span class="_ _3"> </span>are<span class="_ _6"> </span>represented<span class="_ _3"> </span>by<span class="_ _6"> </span>the</div><div class="t m0 x32 h5 y223 ff2 fs3 fc0 sc0 ls0 ws0">type<span class="_ _3"> </span><span class="ff7">jsval<span class="_ _2"></span><span class="ff2">.<span class="_ _3"> </span>A<span class="_ _5"> </span><span class="ff7">jsval<span class="_ _3"> </span></span>is<span class="_ _5"> </span>machine<span class="_ _3"> </span>w<span class="_ _2"></span>ord<span class="_ _3"> </span>in<span class="_ _5"> </span>which<span class="_ _3"> </span>up<span class="_ _5"> </span>to<span class="_ _3"> </span>the<span class="_ _5"> </span>3<span class="_ _3"> </span>of<span class="_ _5"> </span>the</span></span></div><div class="t m0 x32 h5 y224 ff2 fs3 fc0 sc0 ls0 ws0">least<span class="_ _5"> </span>significant<span class="_ _3"> </span>bits<span class="_ _5"> </span>are<span class="_ _5"> </span>a<span class="_ _5"> </span>type<span class="_ _5"> </span>tag,<span class="_ _3"> </span>and<span class="_ _5"> </span>the<span class="_ _5"> </span>remaining<span class="_ _5"> </span>bits<span class="_ _3"> </span>are<span class="_ _5"> </span>data.</div><div class="t m0 x32 h5 y225 ff2 fs3 fc0 sc0 ls0 ws0">See<span class="_ _5"> </span>Figure<span class="_ _3"> </span>6<span class="_ _5"> </span>for<span class="_ _3"> </span>details.<span class="_ _5"> </span>All<span class="_ _3"> </span>pointers<span class="_ _5"> </span>contained<span class="_ _5"> </span>in<span class="_ _3"> </span><span class="ff7">jsvals<span class="_ _5"> </span></span>point<span class="_ _3"> </span>to</div><div class="t m0 x32 h5 y226 ff2 fs3 fc0 sc0 ls0 ws0">GC-controlled<span class="_ _5"> </span>blocks<span class="_ _5"> </span>aligned<span class="_ _3"> </span>on<span class="_ _5"> </span>8-byte<span class="_ _5"> </span>boundaries.</div><div class="t m0 x33 h5 y227 ff2 fs3 fc0 sc0 ls0 ws0">Jav<span class="_ _2"></span>aScript<span class="_ _5"> </span><span class="ffa">object<span class="_ _5"> </span></span>v<span class="_ _2"></span>alues<span class="_ _5"> </span>are<span class="_ _5"> </span>mappings<span class="_ _5"> </span>of<span class="_ _5"> </span>string-v<span class="_ _2"></span>alued<span class="_ _5"> </span>property</div><div class="t m0 x32 h5 y228 ff2 fs3 fc0 sc0 ls0 ws0">names<span class="_ _5"> </span>to<span class="_ _5"> </span>arbitrary<span class="_ _5"> </span>values.<span class="_ _5"> </span>The<span class="_ _2"></span>y<span class="_ _5"> </span>are<span class="_ _5"> </span>represented<span class="_ _5"> </span>in<span class="_ _5"> </span>one<span class="_ _5"> </span>of<span class="_ _5"> </span>two<span class="_ _5"> </span>ways</div><div class="t m0 x32 h5 y229 ff2 fs3 fc0 sc0 ls0 ws0">in<span class="_ _3"> </span>SpiderMonkey<span class="_ _b"></span>.<span class="_ _3"> </span>Most<span class="_ _3"> </span>objects<span class="_ _3"> </span>are<span class="_ _3"> </span>represented<span class="_ _3"> </span>by<span class="_ _3"> </span>a<span class="_ _3"> </span>shared<span class="_ _3"> </span>struc-</div><div class="t m0 x32 h5 y22a ff2 fs3 fc0 sc0 ls0 ws0">tural<span class="_ _5"> </span>description,<span class="_ _7"> </span>called<span class="_ _5"> </span>the<span class="_ _5"> </span><span class="ffa">object<span class="_ _7"> </span>shape</span>,<span class="_ _5"> </span>that<span class="_ _5"> </span>maps<span class="_ _5"> </span>property<span class="_ _7"> </span>names</div><div class="t m0 x32 h5 y22b ff2 fs3 fc0 sc0 ls0 ws0">to<span class="_ _3"> </span>array<span class="_ _3"> </span>indexes<span class="_ _3"> </span>using<span class="_ _3"> </span>a<span class="_ _3"> </span>hash<span class="_ _6"> </span>table.<span class="_ _3"> </span>The<span class="_ _3"> </span>object<span class="_ _3"> </span>stores<span class="_ _3"> </span>a<span class="_ _6"> </span>pointer<span class="_ _3"> </span>to</div><div class="t m0 x32 h5 y22c ff2 fs3 fc0 sc0 ls0 ws0">the<span class="_ _6"> </span>shape<span class="_ _6"> </span>and<span class="_ _6"> </span>the<span class="_ _8"> </span>array<span class="_ _6"> </span>of<span class="_ _6"> </span>its<span class="_ _6"> </span>own<span class="_ _6"> </span>property<span class="_ _6"> </span>values.<span class="_ _6"> </span>Objects<span class="_ _6"> </span>with</div><div class="t m0 x32 h5 y22d ff2 fs3 fc0 sc0 ls0 ws0">large,<span class="_ _3"> </span>unique<span class="_ _5"> </span>sets<span class="_ _3"> </span>of<span class="_ _3"> </span>property<span class="_ _3"> </span>names<span class="_ _5"> </span>store<span class="_ _3"> </span>their<span class="_ _3"> </span>properties<span class="_ _3"> </span>directly</div><div class="t m0 x32 h5 y22e ff2 fs3 fc0 sc0 ls0 ws0">in<span class="_ _5"> </span>a<span class="_ _5"> </span>hash<span class="_ _3"> </span>table.</div><div class="t m0 x33 h5 y22f ff2 fs3 fc0 sc0 ls0 ws0">The<span class="_ _6"> </span>garbage<span class="_ _6"> </span>collector<span class="_ _8"> </span>is<span class="_ _6"> </span>an<span class="_ _8"> </span>exact,<span class="_ _6"> </span>non-generational,<span class="_ _6"> </span>stop-the-</div><div class="t m0 x32 h5 y230 ff2 fs3 fc0 sc0 ls0 ws0">world<span class="_ _5"> </span>mark-and-sweep<span class="_ _5"> </span>collector<span class="_ _2"></span>.</div><div class="t m0 x33 h5 y231 ff2 fs3 fc0 sc0 ls0 ws0">In<span class="_ _5"> </span>the<span class="_ _5"> </span>rest<span class="_ _7"> </span>of<span class="_ _5"> </span>this<span class="_ _5"> </span>section<span class="_ _5"> </span>we<span class="_ _7"> </span>discuss<span class="_ _5"> </span>key<span class="_ _5"> </span>areas<span class="_ _7"> </span>of<span class="_ _5"> </span>the<span class="_ _5"> </span>T<span class="_ _2"></span>raceMon-</div><div class="t m0 x32 h5 y232 ff2 fs3 fc0 sc0 ls0 ws0">key<span class="_ _5"> </span>implementation.</div><div class="t m0 x32 hc yf9 ff1 fs3 fc0 sc0 ls0 ws0">6.1<span class="_ _9"> </span>Calling<span class="_ _5"> </span>Compiled<span class="_ _5"> </span>T<span class="_ _2"></span>races</div><div class="t m0 x32 h5 y12e ff2 fs3 fc0 sc0 ls0 ws0">Compiled<span class="_ _3"> </span>traces<span class="_ _3"> </span>are<span class="_ _5"> </span>stored<span class="_ _3"> </span>in<span class="_ _3"> </span>a<span class="_ _3"> </span><span class="ffa">trace<span class="_ _5"> </span>cache</span>,<span class="_ _3"> </span>index<span class="_ _2"></span>ed<span class="_ _3"> </span>by<span class="_ _3"> </span>intepreter</div><div class="t m0 x32 h5 yd1 ff2 fs3 fc0 sc0 ls0 ws0">PC<span class="_ _e"> </span>and<span class="_ _e"> </span>type<span class="_ _e"> </span>map.<span class="_ _1"> </span>Traces<span class="_ _e"> </span>are<span class="_ _1"> </span>compiled<span class="_ _e"> </span>so<span class="_ _e"> </span>that<span class="_ _e"> </span>they<span class="_ _e"> </span>may<span class="_ _1"> </span>be</div><div class="t m0 x32 h5 yd2 ff2 fs3 fc0 sc0 ls0 ws0">called<span class="_ _3"> </span>as<span class="_ _5"> </span>functions<span class="_ _3"> </span>using<span class="_ _3"> </span>standard<span class="_ _5"> </span>nativ<span class="_ _2"></span>e<span class="_ _3"> </span>calling<span class="_ _5"> </span>con<span class="_ _2"></span>ventions<span class="_ _5"> </span>(e.g.,</div><div class="t m0 x32 h5 y205 ff7 fs3 fc0 sc0 ls0 ws0">FASTCALL<span class="_ _5"> </span><span class="ff2">on<span class="_ _5"> </span>x86).</span></div><div class="t m0 x33 h5 y94 ff2 fs3 fc0 sc0 ls0 ws0">The<span class="_ _6"> </span>interpreter<span class="_ _6"> </span>must<span class="_ _6"> </span>hit<span class="_ _6"> </span>a<span class="_ _6"> </span>loop<span class="_ _6"> </span>edge<span class="_ _6"> </span>and<span class="_ _6"> </span>enter<span class="_ _6"> </span>the<span class="_ _6"> </span>monitor<span class="_ _6"> </span>in</div><div class="t m0 x32 h5 y95 ff2 fs3 fc0 sc0 ls0 ws0">order<span class="_ _5"> </span>to<span class="_ _5"> </span>call<span class="_ _3"> </span>a<span class="_ _5"> </span>nati<span class="_ _2"></span>v<span class="_ _2"></span>e<span class="_ _5"> </span>trace<span class="_ _5"> </span>for<span class="_ _3"> </span>the<span class="_ _5"> </span>first<span class="_ _5"> </span>time.<span class="_ _5"> </span>The<span class="_ _5"> </span>monitor<span class="_ _5"> </span>computes</div><div class="t m0 x32 h5 y96 ff2 fs3 fc0 sc0 ls0 ws0">the<span class="_ _8"> </span>current<span class="_ _d"> </span>type<span class="_ _6"> </span>map,<span class="_ _d"> </span>checks<span class="_ _8"> </span>the<span class="_ _8"> </span>trace<span class="_ _d"> </span>cache<span class="_ _8"> </span>for<span class="_ _8"> </span>a<span class="_ _8"> </span>trace<span class="_ _d"> </span>for<span class="_ _8"> </span>the</div><div class="t m0 x32 h5 y97 ff2 fs3 fc0 sc0 ls0 ws0">current<span class="_ _5"> </span>PC<span class="_ _5"> </span>and<span class="_ _3"> </span>type<span class="_ _5"> </span>map,<span class="_ _5"> </span>and<span class="_ _5"> </span>if<span class="_ _5"> </span>it<span class="_ _5"> </span>finds<span class="_ _5"> </span>one,<span class="_ _3"> </span>e<span class="_ _2"></span>x<span class="_ _2"></span>ecutes<span class="_ _5"> </span>the<span class="_ _5"> </span>trace.</div><div class="t m0 x33 h5 y98 ff2 fs3 fc0 sc0 ls0 ws0">T<span class="_ _b"></span>o<span class="_ _d"> </span>e<span class="_ _2"></span>xecute<span class="_ _6"> </span>a<span class="_ _d"> </span>trace,<span class="_ _8"> </span>the<span class="_ _8"> </span>monitor<span class="_ _8"> </span>must<span class="_ _d"> </span>b<span class="_ _2"></span>uild<span class="_ _8"> </span>a<span class="_ _8"> </span>trace<span class="_ _d"> </span>acti<span class="_ _2"></span>v<span class="_ _2"></span>ation</div><div class="t m0 x32 h5 y99 ff2 fs3 fc0 sc0 ls0 ws0">record<span class="_ _6"> </span>containing<span class="_ _6"> </span>imported<span class="_ _6"> </span>local<span class="_ _6"> </span>and<span class="_ _6"> </span>global<span class="_ _3"> </span>variables,<span class="_ _6"> </span>temporary</div><div class="t m0 x32 h5 y9a ff2 fs3 fc0 sc0 ls0 ws0">stack<span class="_ _3"> </span>s<span class="_ _2"></span>pace,<span class="_ _5"> </span>and<span class="_ _3"> </span>space<span class="_ _5"> </span>for<span class="_ _3"> </span>ar<span class="_ _2"></span>guments<span class="_ _5"> </span>to<span class="_ _3"> </span>nati<span class="_ _2"></span>v<span class="_ _2"></span>e<span class="_ _5"> </span>calls.<span class="_ _3"> </span>The<span class="_ _5"> </span>local<span class="_ _3"> </span>and</div><div class="t m0 x32 h5 y9b ff2 fs3 fc0 sc0 ls0 ws0">global<span class="_ _5"> </span>values<span class="_ _5"> </span>are<span class="_ _3"> </span>then<span class="_ _5"> </span>copied<span class="_ _3"> </span>from<span class="_ _5"> </span>the<span class="_ _5"> </span>interpreter<span class="_ _3"> </span>state<span class="_ _5"> </span>to<span class="_ _3"> </span>the<span class="_ _5"> </span>trace</div><div class="t m0 x32 h5 y9c ff2 fs3 fc0 sc0 ls0 ws0">activ<span class="_ _2"></span>ation<span class="_ _5"> </span>record.<span class="_ _5"> </span>Then,<span class="_ _5"> </span>the<span class="_ _5"> </span>trace<span class="_ _5"> </span>is<span class="_ _5"> </span>called<span class="_ _5"> </span>like<span class="_ _5"> </span>a<span class="_ _5"> </span>normal<span class="_ _5"> </span>C<span class="_ _5"> </span>function</div><div class="t m0 x32 h5 y9d ff2 fs3 fc0 sc0 ls0 ws0">pointer<span class="_ _2"></span>.</div></div><div class="pi" data-data='{"ctm":[1.673203,0.000000,0.000000,1.673203,0.000000,0.000000]}'></div></div></div>
|