mirror of
https://github.com/pdf2htmlEX/pdf2htmlEX.git
synced 2024-12-22 13:00:08 +00:00
2 lines
51 KiB
Plaintext
2 lines
51 KiB
Plaintext
<div class="pd w0 h0"><div id="pf5" class="pf" data-page-no="5"><div class="pc pc5"><img class="bi x2f y141 w5 h11" alt="" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAO8AAAABCAIAAAC5XG4cAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAD0lEQVQoz2NgGAWjYLgAAALOAAHc7AMEAAAAAElFTkSuQmCC"/><div class="t m0 x2f h5 y5b ff2 fs3 fc0 sc0 ls0 ws0">resentations<span class="_ _8"> </span>are<span class="_ _8"> </span>assigned<span class="_ _6"> </span>an<span class="_ _8"> </span>integer<span class="_ _8"> </span>key<span class="_ _6"> </span>called<span class="_ _8"> </span>the<span class="_ _8"> </span><span class="ffa">object<span class="_ _8"> </span>shape</span>.</div><div class="t m0 x2f h5 y5c ff2 fs3 fc0 sc0 ls0 ws0">Thus,<span class="_ _5"> </span>the<span class="_ _5"> </span>guard<span class="_ _3"> </span>is<span class="_ _5"> </span>a<span class="_ _5"> </span>simple<span class="_ _5"> </span>equality<span class="_ _5"> </span>check<span class="_ _5"> </span>on<span class="_ _5"> </span>the<span class="_ _3"> </span>object<span class="_ _5"> </span>shape.</div><div class="t m0 x34 h5 y5d ff1 fs3 fc0 sc0 ls0 ws0">Representation<span class="_ _d"> </span>specialization:<span class="_ _d"> </span>numbers.<span class="_ _1"> </span><span class="ff2">Ja<span class="_ _2"></span>v<span class="_ _2"></span>aScript<span class="_ _d"> </span>has<span class="_ _d"> </span>no</span></div><div class="t m0 x2f h5 y5e ff2 fs3 fc0 sc0 ls0 ws0">integer<span class="_ _6"> </span>type,<span class="_ _6"> </span>only<span class="_ _8"> </span>a<span class="_ _8"> </span>Number<span class="_ _6"> </span>type<span class="_ _8"> </span>that<span class="_ _8"> </span>is<span class="_ _6"> </span>the<span class="_ _8"> </span>set<span class="_ _6"> </span>of<span class="_ _8"> </span>64-bit<span class="_ _8"> </span>IEEE-</div><div class="t m0 x2f h5 y5f ff2 fs3 fc0 sc0 ls0 ws0">754<span class="_ _1"> </span>floating-pointer<span class="_ _d"> </span>numbers<span class="_ _1"> </span>(“doubles”).<span class="_ _d"> </span>But<span class="_ _1"> </span>man<span class="_ _2"></span>y<span class="_ _d"> </span>JavaScript</div><div class="t m0 x2f h5 y60 ff2 fs3 fc0 sc0 ls0 ws0">operators,<span class="_ _5"> </span>in<span class="_ _3"> </span>particular<span class="_ _5"> </span>array<span class="_ _5"> </span>accesses<span class="_ _5"> </span>and<span class="_ _3"> </span>bitwise<span class="_ _5"> </span>operators,<span class="_ _5"> </span>really</div><div class="t m0 x2f h5 y61 ff2 fs3 fc0 sc0 ls0 ws0">operate<span class="_ _3"> </span>on<span class="_ _3"> </span>inte<span class="_ _2"></span>gers,<span class="_ _3"> </span>so<span class="_ _3"> </span>the<span class="_ _2"></span>y<span class="_ _3"> </span>first<span class="_ _3"> </span>con<span class="_ _2"></span>v<span class="_ _2"></span>ert<span class="_ _3"> </span>the<span class="_ _5"> </span>number<span class="_ _3"> </span>to<span class="_ _3"> </span>an<span class="_ _3"> </span>integer<span class="_ _2"></span>,</div><div class="t m0 x2f h5 y62 ff2 fs3 fc0 sc0 ls0 ws0">and<span class="_ _6"> </span>then<span class="_ _8"> </span>con<span class="_ _2"></span>vert<span class="_ _6"> </span>any<span class="_ _6"> </span>integer<span class="_ _6"> </span>result<span class="_ _6"> </span>back<span class="_ _8"> </span>to<span class="_ _8"> </span>a<span class="_ _6"> </span>double.</div><div class="t m0 x63 h8 y142 ff2 fs4 fc0 sc0 ls0 ws0">1</div><div class="t m0 x6 h5 y62 ff2 fs3 fc0 sc0 ls0 ws0">Clearly<span class="_ _2"></span>,<span class="_ _6"> </span>a</div><div class="t m0 x2f h5 y63 ff2 fs3 fc0 sc0 ls0 ws0">Jav<span class="_ _2"></span>aScript<span class="_ _5"> </span>VM<span class="_ _3"> </span>that<span class="_ _3"> </span>w<span class="_ _2"></span>ants<span class="_ _3"> </span>to<span class="_ _5"> </span>be<span class="_ _3"> </span>f<span class="_ _2"></span>ast<span class="_ _3"> </span>must<span class="_ _5"> </span>find<span class="_ _3"> </span>a<span class="_ _5"> </span>way<span class="_ _3"> </span>to<span class="_ _3"> </span>operate<span class="_ _5"> </span>on</div><div class="t m0 x2f h5 y143 ff2 fs3 fc0 sc0 ls0 ws0">integers<span class="_ _5"> </span>directly<span class="_ _5"> </span>and<span class="_ _5"> </span>avoid<span class="_ _5"> </span>these<span class="_ _5"> </span>con<span class="_ _2"></span>v<span class="_ _2"></span>ersions.</div><div class="t m0 x34 h5 y64 ff2 fs3 fc0 sc0 ls0 ws0">In<span class="_ _3"> </span>T<span class="_ _2"></span>raceMonkey<span class="_ _b"></span>,<span class="_ _3"> </span>we<span class="_ _3"> </span>support<span class="_ _3"> </span>two<span class="_ _3"> </span>representations<span class="_ _3"> </span>for<span class="_ _3"> </span>numbers:</div><div class="t m0 x2f h5 y66 ff2 fs3 fc0 sc0 ls0 ws0">integers<span class="_ _6"> </span>and<span class="_ _3"> </span>doubles.<span class="_ _6"> </span>The<span class="_ _6"> </span>interpreter<span class="_ _6"> </span>uses<span class="_ _6"> </span>integer<span class="_ _6"> </span>representations</div><div class="t m0 x2f h5 y67 ff2 fs3 fc0 sc0 ls0 ws0">as<span class="_ _5"> </span>much<span class="_ _5"> </span>as<span class="_ _7"> </span>it<span class="_ _5"> </span>can,<span class="_ _5"> </span>switching<span class="_ _5"> </span>for<span class="_ _5"> </span>results<span class="_ _7"> </span>that<span class="_ _5"> </span>can<span class="_ _5"> </span>only<span class="_ _5"> </span>be<span class="_ _5"> </span>represented</div><div class="t m0 x2f h5 y68 ff2 fs3 fc0 sc0 ls0 ws0">as<span class="_ _3"> </span>doubles.<span class="_ _3"> </span>When<span class="_ _5"> </span>a<span class="_ _3"> </span>trace<span class="_ _3"> </span>is<span class="_ _3"> </span>started,<span class="_ _5"> </span>some<span class="_ _3"> </span>values<span class="_ _3"> </span>may<span class="_ _5"> </span>be<span class="_ _3"> </span>imported</div><div class="t m0 x2f h5 y69 ff2 fs3 fc0 sc0 ls0 ws0">and<span class="_ _6"> </span>represented<span class="_ _8"> </span>as<span class="_ _6"> </span>integers.<span class="_ _6"> </span>Some<span class="_ _8"> </span>operations<span class="_ _6"> </span>on<span class="_ _6"> </span>integers<span class="_ _6"> </span>require</div><div class="t m0 x2f h5 y6a ff2 fs3 fc0 sc0 ls0 ws0">guards.<span class="_ _3"> </span>F<span class="_ _2"></span>or<span class="_ _3"> </span>example,<span class="_ _5"> </span>adding<span class="_ _3"> </span>two<span class="_ _3"> </span>inte<span class="_ _2"></span>gers<span class="_ _3"> </span>can<span class="_ _3"> </span>produce<span class="_ _5"> </span>a<span class="_ _3"> </span>value<span class="_ _3"> </span>too</div><div class="t m0 x2f h5 y6b ff2 fs3 fc0 sc0 ls0 ws0">large<span class="_ _5"> </span>for<span class="_ _5"> </span>the<span class="_ _5"> </span>integer<span class="_ _5"> </span>representation.</div><div class="t m0 x34 h5 y6c ff1 fs3 fc0 sc0 ls0 ws0">Function<span class="_ _8"> </span>inlining.<span class="_ _d"> </span><span class="ff2">LIR<span class="_ _8"> </span>traces<span class="_ _d"> </span>can<span class="_ _8"> </span>cross<span class="_ _d"> </span>function<span class="_ _8"> </span>boundaries</span></div><div class="t m0 x2f h5 y6d ff2 fs3 fc0 sc0 ls0 ws0">in<span class="_ _3"> </span>either<span class="_ _6"> </span>direction,<span class="_ _3"> </span>achieving<span class="_ _3"> </span>function<span class="_ _3"> </span>inlining.<span class="_ _6"> </span>Mov<span class="_ _2"></span>e<span class="_ _3"> </span>instructions</div><div class="t m0 x2f h5 y6e ff2 fs3 fc0 sc0 ls0 ws0">need<span class="_ _3"> </span>to<span class="_ _3"> </span>be<span class="_ _5"> </span>recorded<span class="_ _3"> </span>for<span class="_ _3"> </span>function<span class="_ _3"> </span>entry<span class="_ _3"> </span>and<span class="_ _5"> </span>exit<span class="_ _3"> </span>to<span class="_ _3"> </span>copy<span class="_ _5"> </span>arguments</div><div class="t m0 x2f h5 y6f ff2 fs3 fc0 sc0 ls0 ws0">in<span class="_ _5"> </span>and<span class="_ _5"> </span>return<span class="_ _5"> </span>v<span class="_ _2"></span>alues<span class="_ _7"> </span>out.<span class="_ _5"> </span>These<span class="_ _5"> </span>mov<span class="_ _2"></span>e<span class="_ _5"> </span>statements<span class="_ _5"> </span>are<span class="_ _7"> </span>then<span class="_ _5"> </span>optimized</div><div class="t m0 x2f h5 y70 ff2 fs3 fc0 sc0 ls0 ws0">away<span class="_ _3"> </span>by<span class="_ _3"> </span>the<span class="_ _3"> </span>compiler<span class="_ _3"> </span>using<span class="_ _3"> </span>cop<span class="_ _2"></span>y<span class="_ _3"> </span>propagation.<span class="_ _3"> </span>In<span class="_ _3"> </span>order<span class="_ _3"> </span>to<span class="_ _3"> </span>be<span class="_ _3"> </span>able</div><div class="t m0 x2f h5 y71 ff2 fs3 fc0 sc0 ls0 ws0">to<span class="_ _d"> </span>return<span class="_ _8"> </span>to<span class="_ _d"> </span>the<span class="_ _d"> </span>interpreter<span class="_ _2"></span>,<span class="_ _8"> </span>the<span class="_ _d"> </span>trace<span class="_ _8"> </span>must<span class="_ _d"> </span>also<span class="_ _d"> </span>generate<span class="_ _d"> </span>LIR<span class="_ _8"> </span>to</div><div class="t m0 x2f h5 y72 ff2 fs3 fc0 sc0 ls0 ws0">record<span class="_ _8"> </span>that<span class="_ _6"> </span>a<span class="_ _8"> </span>call<span class="_ _8"> </span>frame<span class="_ _8"> </span>has<span class="_ _8"> </span>been<span class="_ _8"> </span>entered<span class="_ _8"> </span>and<span class="_ _8"> </span>exited.<span class="_ _6"> </span>The<span class="_ _8"> </span>frame</div><div class="t m0 x2f h5 y74 ff2 fs3 fc0 sc0 ls0 ws0">entry<span class="_ _d"> </span>and<span class="_ _1"> </span>exit<span class="_ _d"> </span>LIR<span class="_ _1"> </span>sa<span class="_ _2"></span>v<span class="_ _2"></span>es<span class="_ _d"> </span>just<span class="_ _1"> </span>enough<span class="_ _d"> </span>information<span class="_ _1"> </span>to<span class="_ _d"> </span>allo<span class="_ _2"></span>w<span class="_ _1"> </span>the</div><div class="t m0 x2f h5 y75 ff2 fs3 fc0 sc0 ls0 ws0">intepreter<span class="_ _3"> </span>call<span class="_ _6"> </span>stack<span class="_ _3"> </span>to<span class="_ _3"> </span>be<span class="_ _6"> </span>restored<span class="_ _3"> </span>later<span class="_ _6"> </span>and<span class="_ _3"> </span>is<span class="_ _3"> </span>much<span class="_ _6"> </span>simpler<span class="_ _3"> </span>than</div><div class="t m0 x2f h5 y76 ff2 fs3 fc0 sc0 ls0 ws0">the<span class="_ _6"> </span>interpreter’<span class="_ _2"></span>s<span class="_ _6"> </span>standard<span class="_ _6"> </span>call<span class="_ _6"> </span>code.<span class="_ _6"> </span>If<span class="_ _6"> </span>the<span class="_ _8"> </span>function<span class="_ _6"> </span>being<span class="_ _6"> </span>entered</div><div class="t m0 x2f h5 y77 ff2 fs3 fc0 sc0 ls0 ws0">is<span class="_ _3"> </span>not<span class="_ _3"> </span>constant<span class="_ _6"> </span>(which<span class="_ _3"> </span>in<span class="_ _3"> </span>Jav<span class="_ _2"></span>aScript<span class="_ _3"> </span>includes<span class="_ _3"> </span>any<span class="_ _3"> </span>call<span class="_ _6"> </span>by<span class="_ _3"> </span>function</div><div class="t m0 x2f h5 y78 ff2 fs3 fc0 sc0 ls0 ws0">name),<span class="_ _3"> </span>the<span class="_ _3"> </span>recorder<span class="_ _3"> </span>must<span class="_ _3"> </span>also<span class="_ _3"> </span>emit<span class="_ _3"> </span>LIR<span class="_ _3"> </span>to<span class="_ _3"> </span>guard<span class="_ _5"> </span>that<span class="_ _3"> </span>the<span class="_ _3"> </span>function</div><div class="t m0 x2f h5 y79 ff2 fs3 fc0 sc0 ls0 ws0">is<span class="_ _5"> </span>the<span class="_ _5"> </span>same.</div><div class="t m0 x34 h5 y7a ff1 fs3 fc0 sc0 ls0 ws0">Guards<span class="_ _1"> </span>and<span class="_ _1"> </span>side<span class="_ _d"> </span>exits.<span class="_ _1"> </span><span class="ff2">Each<span class="_ _1"> </span>optimization<span class="_ _1"> </span>described<span class="_ _d"> </span>above</span></div><div class="t m0 x2f h5 y7b ff2 fs3 fc0 sc0 ls0 ws0">requires<span class="_ _d"> </span>one<span class="_ _8"> </span>or<span class="_ _d"> </span>more<span class="_ _8"> </span>guards<span class="_ _d"> </span>to<span class="_ _d"> </span>verify<span class="_ _8"> </span>the<span class="_ _d"> </span>assumptions<span class="_ _8"> </span>made<span class="_ _d"> </span>in</div><div class="t m0 x2f h5 y7c ff2 fs3 fc0 sc0 ls0 ws0">doing<span class="_ _5"> </span>the<span class="_ _3"> </span>optimization.<span class="_ _5"> </span>A<span class="_ _5"> </span>guard<span class="_ _3"> </span>is<span class="_ _5"> </span>just<span class="_ _5"> </span>a<span class="_ _3"> </span>group<span class="_ _5"> </span>of<span class="_ _5"> </span>LIR<span class="_ _5"> </span>instructions</div><div class="t m0 x2f h5 y7d ff2 fs3 fc0 sc0 ls0 ws0">that<span class="_ _8"> </span>performs<span class="_ _8"> </span>a<span class="_ _6"> </span>test<span class="_ _8"> </span>and<span class="_ _8"> </span>conditional<span class="_ _8"> </span>exit.<span class="_ _8"> </span>The<span class="_ _6"> </span>exit<span class="_ _8"> </span>branches<span class="_ _8"> </span>to<span class="_ _8"> </span>a</div><div class="t m0 x2f h5 y7e ffa fs3 fc0 sc0 ls0 ws0">side<span class="_ _6"> </span>exit<span class="ff2">,<span class="_ _6"> </span>a<span class="_ _8"> </span>small<span class="_ _6"> </span>off-trace<span class="_ _6"> </span>piece<span class="_ _8"> </span>of<span class="_ _6"> </span>LIR<span class="_ _8"> </span>that<span class="_ _6"> </span>returns<span class="_ _8"> </span>a<span class="_ _6"> </span>pointer<span class="_ _8"> </span>to</span></div><div class="t m0 x2f h5 y7f ff2 fs3 fc0 sc0 ls0 ws0">a<span class="_ _d"> </span>structure<span class="_ _8"> </span>that<span class="_ _d"> </span>describes<span class="_ _8"> </span>the<span class="_ _d"> </span>reason<span class="_ _8"> </span>for<span class="_ _d"> </span>the<span class="_ _d"> </span>e<span class="_ _2"></span>xit<span class="_ _8"> </span>along<span class="_ _d"> </span>with<span class="_ _d"> </span>the</div><div class="t m0 x2f h5 y80 ff2 fs3 fc0 sc0 ls0 ws0">interpreter<span class="_ _5"> </span>PC<span class="_ _5"> </span>at<span class="_ _5"> </span>the<span class="_ _5"> </span>exit<span class="_ _5"> </span>point<span class="_ _5"> </span>and<span class="_ _5"> </span>an<span class="_ _2"></span>y<span class="_ _5"> </span>other<span class="_ _5"> </span>data<span class="_ _5"> </span>needed<span class="_ _5"> </span>to<span class="_ _5"> </span>restore</div><div class="t m0 x2f h5 y81 ff2 fs3 fc0 sc0 ls0 ws0">the<span class="_ _5"> </span>interpreter’<span class="_ _2"></span>s<span class="_ _5"> </span>state<span class="_ _5"> </span>structures.</div><div class="t m0 x34 h5 y82 ff1 fs3 fc0 sc0 ls0 ws0">Aborts.<span class="_ _6"> </span><span class="ff2">Some<span class="_ _6"> </span>constructs<span class="_ _6"> </span>are<span class="_ _6"> </span>dif<span class="_ _2"></span>ficult<span class="_ _6"> </span>to<span class="_ _3"> </span>record<span class="_ _6"> </span>in<span class="_ _6"> </span>LIR<span class="_ _6"> </span>traces.</span></div><div class="t m0 x2f h5 y83 ff2 fs3 fc0 sc0 ls0 ws0">For<span class="_ _6"> </span>example,<span class="_ _6"> </span><span class="ff7">eval<span class="_ _8"> </span></span>or<span class="_ _6"> </span>calls<span class="_ _8"> </span>to<span class="_ _8"> </span>external<span class="_ _6"> </span>functions<span class="_ _8"> </span>can<span class="_ _6"> </span>change<span class="_ _8"> </span>the</div><div class="t m0 x2f h5 y84 ff2 fs3 fc0 sc0 ls0 ws0">program<span class="_ _d"> </span>state<span class="_ _d"> </span>in<span class="_ _8"> </span>unpredictable<span class="_ _d"> </span>ways,<span class="_ _d"> </span>making<span class="_ _d"> </span>it<span class="_ _8"> </span>difficult<span class="_ _d"> </span>for<span class="_ _8"> </span>the</div><div class="t m0 x2f h5 y85 ff2 fs3 fc0 sc0 ls0 ws0">tracer<span class="_ _6"> </span>to<span class="_ _6"> </span>kno<span class="_ _2"></span>w<span class="_ _3"> </span>the<span class="_ _6"> </span>current<span class="_ _6"> </span>type<span class="_ _6"> </span>map<span class="_ _6"> </span>in<span class="_ _3"> </span>order<span class="_ _6"> </span>to<span class="_ _6"> </span>continue<span class="_ _6"> </span>tracing.</div><div class="t m0 x2f h5 y86 ff2 fs3 fc0 sc0 ls0 ws0">A<span class="_ _3"> </span>tracing<span class="_ _5"> </span>implementation<span class="_ _3"> </span>can<span class="_ _5"> </span>also<span class="_ _3"> </span>ha<span class="_ _2"></span>v<span class="_ _2"></span>e<span class="_ _5"> </span>any<span class="_ _3"> </span>number<span class="_ _5"> </span>of<span class="_ _3"> </span>other<span class="_ _5"> </span>limi-</div><div class="t m0 x2f h5 y87 ff2 fs3 fc0 sc0 ls0 ws0">tations,<span class="_ _3"> </span>e.g.,a<span class="_ _5"> </span>small-memory<span class="_ _3"> </span>de<span class="_ _2"></span>vice<span class="_ _5"> </span>may<span class="_ _3"> </span>limit<span class="_ _5"> </span>the<span class="_ _3"> </span>length<span class="_ _5"> </span>of<span class="_ _5"> </span>traces.</div><div class="t m0 x2f h5 y88 ff2 fs3 fc0 sc0 ls0 ws0">When<span class="_ _3"> </span>any<span class="_ _3"> </span>situation<span class="_ _3"> </span>occurs<span class="_ _3"> </span>that<span class="_ _3"> </span>prevents<span class="_ _3"> </span>the<span class="_ _3"> </span>implementation<span class="_ _3"> </span>from</div><div class="t m0 x2f h5 y89 ff2 fs3 fc0 sc0 ls0 ws0">continuing<span class="_ _5"> </span>trace<span class="_ _7"> </span>recording,<span class="_ _5"> </span>the<span class="_ _5"> </span>implementation<span class="_ _7"> </span><span class="ffa">aborts<span class="_ _5"> </span></span>trace<span class="_ _7"> </span>record-</div><div class="t m0 x2f h5 y12f ff2 fs3 fc0 sc0 ls0 ws0">ing<span class="_ _5"> </span>and<span class="_ _5"> </span>returns<span class="_ _3"> </span>to<span class="_ _5"> </span>the<span class="_ _5"> </span>trace<span class="_ _5"> </span>monitor<span class="_ _2"></span>.</div><div class="t m0 x2f hc y144 ff1 fs3 fc0 sc0 ls0 ws0">3.2<span class="_ _9"> </span>T<span class="_ _b"></span>race<span class="_ _5"> </span>T<span class="_ _2"></span>r<span class="_ _2"></span>ees</div><div class="t m0 x2f h5 y28 ff2 fs3 fc0 sc0 ls0 ws0">Especially<span class="_ _6"> </span>simple<span class="_ _8"> </span>loops,<span class="_ _8"> </span>namely<span class="_ _6"> </span>those<span class="_ _8"> </span>where<span class="_ _8"> </span>control<span class="_ _6"> </span>flow<span class="_ _2"></span>,<span class="_ _6"> </span>v<span class="_ _2"></span>alue</div><div class="t m0 x2f h5 y145 ff2 fs3 fc0 sc0 ls0 ws0">types,<span class="_ _5"> </span>value<span class="_ _5"> </span>representations,<span class="_ _5"> </span>and<span class="_ _5"> </span>inlined<span class="_ _5"> </span>functions<span class="_ _5"> </span>are<span class="_ _5"> </span>all<span class="_ _5"> </span>in<span class="_ _2"></span>variant,</div><div class="t m0 x2f h5 y146 ff2 fs3 fc0 sc0 ls0 ws0">can<span class="_ _3"> </span>be<span class="_ _3"> </span>represented<span class="_ _3"> </span>by<span class="_ _3"> </span>a<span class="_ _6"> </span>single<span class="_ _3"> </span>trace.<span class="_ _3"> </span>But<span class="_ _3"> </span>most<span class="_ _3"> </span>loops<span class="_ _3"> </span>have<span class="_ _3"> </span>at<span class="_ _3"> </span>least</div><div class="t m0 x2f h5 y147 ff2 fs3 fc0 sc0 ls0 ws0">some<span class="_ _6"> </span>variation,<span class="_ _6"> </span>and<span class="_ _6"> </span>so<span class="_ _6"> </span>the<span class="_ _6"> </span>program<span class="_ _6"> </span>will<span class="_ _6"> </span>take<span class="_ _6"> </span>side<span class="_ _8"> </span>exits<span class="_ _6"> </span>from<span class="_ _6"> </span>the</div><div class="t m0 x2f h5 y148 ff2 fs3 fc0 sc0 ls0 ws0">main<span class="_ _6"> </span>trace.<span class="_ _3"> </span>When<span class="_ _6"> </span>a<span class="_ _6"> </span>side<span class="_ _6"> </span>exit<span class="_ _3"> </span>becomes<span class="_ _6"> </span>hot,<span class="_ _6"> </span>T<span class="_ _2"></span>raceMonk<span class="_ _2"></span>ey<span class="_ _3"> </span>starts<span class="_ _6"> </span>a</div><div class="t m0 x2f h5 y149 ff2 fs3 fc0 sc0 ls0 ws0">new<span class="_ _5"> </span><span class="ffa">branc<span class="_ _2"></span>h<span class="_ _5"> </span>trace<span class="_ _5"> </span><span class="ff2">from<span class="_ _3"> </span>that<span class="_ _5"> </span>point<span class="_ _5"> </span>and<span class="_ _5"> </span>patches<span class="_ _3"> </span>the<span class="_ _5"> </span>side<span class="_ _5"> </span>exit<span class="_ _5"> </span>to<span class="_ _5"> </span>jump</span></span></div><div class="t m0 x2f h5 y14a ff2 fs3 fc0 sc0 ls0 ws0">directly<span class="_ _5"> </span>to<span class="_ _5"> </span>that<span class="_ _5"> </span>trace.<span class="_ _5"> </span>In<span class="_ _5"> </span>this<span class="_ _5"> </span>w<span class="_ _2"></span>ay<span class="_ _b"></span>,<span class="_ _5"> </span>a<span class="_ _5"> </span>single<span class="_ _5"> </span>trace<span class="_ _5"> </span>expands<span class="_ _5"> </span>on<span class="_ _5"> </span>demand</div><div class="t m0 x2f h5 y14b ff2 fs3 fc0 sc0 ls0 ws0">to<span class="_ _5"> </span>a<span class="_ _5"> </span>single-entry<span class="_ _2"></span>,<span class="_ _5"> </span>multiple-exit<span class="_ _5"> </span><span class="ffa">trace<span class="_ _5"> </span>tr<span class="_ _2"></span>ee<span class="ff2">.</span></span></div><div class="t m0 x34 h5 y14c ff2 fs3 fc0 sc0 ls0 ws0">This<span class="_ _3"> </span>section<span class="_ _5"> </span>explains<span class="_ _3"> </span>ho<span class="_ _2"></span>w<span class="_ _5"> </span>trace<span class="_ _3"> </span>trees<span class="_ _3"> </span>are<span class="_ _5"> </span>formed<span class="_ _3"> </span>during<span class="_ _5"> </span>execu-</div><div class="t m0 x2f h5 y14d ff2 fs3 fc0 sc0 ls0 ws0">tion.<span class="_ _5"> </span>The<span class="_ _3"> </span>goal<span class="_ _5"> </span>is<span class="_ _3"> </span>to<span class="_ _5"> </span>form<span class="_ _3"> </span>trace<span class="_ _5"> </span>trees<span class="_ _5"> </span>during<span class="_ _3"> </span>e<span class="_ _2"></span>xecution<span class="_ _5"> </span>that<span class="_ _3"> </span>co<span class="_ _2"></span>v<span class="_ _2"></span>er<span class="_ _5"> </span>all</div><div class="t m0 x2f h5 y14e ff2 fs3 fc0 sc0 ls0 ws0">the<span class="_ _5"> </span>hot<span class="_ _5"> </span>paths<span class="_ _3"> </span>of<span class="_ _5"> </span>the<span class="_ _5"> </span>program.</div><div class="t m0 x2f h8 y58 ff2 fs4 fc0 sc0 ls0 ws0">1</div><div class="t m0 x36 h3 y14f ff2 fs2 fc0 sc0 ls0 ws0">Arrays<span class="_ _5"> </span>are<span class="_ _5"> </span>actually<span class="_ _7"> </span>worse<span class="_ _5"> </span>than<span class="_ _5"> </span>this:<span class="_ _7"> </span>if<span class="_ _5"> </span>the<span class="_ _5"> </span>inde<span class="_ _2"></span>x<span class="_ _5"> </span>v<span class="_ _2"></span>alue<span class="_ _7"> </span>is<span class="_ _5"> </span>a<span class="_ _5"> </span>number<span class="_ _2"></span>,<span class="_ _7"> </span>it<span class="_ _5"> </span>must</div><div class="t m0 x2f h3 y33 ff2 fs2 fc0 sc0 ls0 ws0">be<span class="_ _5"> </span>con<span class="_ _2"></span>v<span class="_ _2"></span>erted<span class="_ _5"> </span>from<span class="_ _5"> </span>a<span class="_ _7"> </span>double<span class="_ _5"> </span>to<span class="_ _5"> </span>a<span class="_ _7"> </span>string<span class="_ _5"> </span>for<span class="_ _5"> </span>the<span class="_ _5"> </span>property<span class="_ _7"> </span>access<span class="_ _5"> </span>operator<span class="_ _2"></span>,<span class="_ _5"> </span>and</div><div class="t m0 x2f h3 y9d ff2 fs2 fc0 sc0 ls0 ws0">then<span class="_ _5"> </span>to<span class="_ _5"> </span>an<span class="_ _7"> </span>integer<span class="_ _5"> </span>internally<span class="_ _5"> </span>to<span class="_ _7"> </span>the<span class="_ _5"> </span>array<span class="_ _5"> </span>implementation.</div><div class="t m0 x33 h5 y5b ff1 fs3 fc0 sc0 ls0 ws0">Starting<span class="_ _5"> </span>a<span class="_ _5"> </span>tr<span class="_ _2"></span>ee.<span class="_ _5"> </span><span class="ff2">T<span class="_ _2"></span>ree<span class="_ _5"> </span>trees<span class="_ _5"> </span>al<span class="_ _2"></span>w<span class="_ _2"></span>ays<span class="_ _5"> </span>start<span class="_ _5"> </span>at<span class="_ _5"> </span>loop<span class="_ _5"> </span>headers,<span class="_ _7"> </span>because</span></div><div class="t m0 x32 h5 y5c ff2 fs3 fc0 sc0 ls0 ws0">they<span class="_ _5"> </span>are<span class="_ _7"> </span>a<span class="_ _5"> </span>natural<span class="_ _5"> </span>place<span class="_ _5"> </span>to<span class="_ _5"> </span>look<span class="_ _7"> </span>for<span class="_ _5"> </span>hot<span class="_ _5"> </span>paths.<span class="_ _5"> </span>In<span class="_ _5"> </span>T<span class="_ _2"></span>raceMonk<span class="_ _2"></span>e<span class="_ _2"></span>y<span class="_ _2"></span>,<span class="_ _7"> </span>loop</div><div class="t m0 x32 h5 y5d ff2 fs3 fc0 sc0 ls0 ws0">headers<span class="_ _8"> </span>are<span class="_ _d"> </span>easy<span class="_ _8"> </span>to<span class="_ _8"> </span>detect–the<span class="_ _8"> </span>bytecode<span class="_ _d"> </span>compiler<span class="_ _8"> </span>ensures<span class="_ _8"> </span>that<span class="_ _d"> </span>a</div><div class="t m0 x32 h5 y5e ff2 fs3 fc0 sc0 ls0 ws0">bytecode<span class="_ _3"> </span>is<span class="_ _3"> </span>a<span class="_ _5"> </span>loop<span class="_ _3"> </span>header<span class="_ _3"> </span>if<span class="_ _2"></span>f<span class="_ _3"> </span>it<span class="_ _5"> </span>is<span class="_ _3"> </span>the<span class="_ _3"> </span>tar<span class="_ _2"></span>get<span class="_ _3"> </span>of<span class="_ _3"> </span>a<span class="_ _5"> </span>backward<span class="_ _3"> </span>branch.</div><div class="t m0 x32 h5 y5f ff2 fs3 fc0 sc0 ls0 ws0">T<span class="_ _2"></span>raceMonke<span class="_ _2"></span>y<span class="_ _5"> </span>starts<span class="_ _3"> </span>a<span class="_ _5"> </span>tree<span class="_ _3"> </span>when<span class="_ _5"> </span>a<span class="_ _5"> </span>given<span class="_ _5"> </span>loop<span class="_ _3"> </span>header<span class="_ _5"> </span>has<span class="_ _5"> </span>been<span class="_ _3"> </span>e<span class="_ _2"></span>xe-</div><div class="t m0 x32 h5 y60 ff2 fs3 fc0 sc0 ls0 ws0">cuted<span class="_ _3"> </span>a<span class="_ _5"> </span>certain<span class="_ _3"> </span>number<span class="_ _5"> </span>of<span class="_ _3"> </span>times<span class="_ _5"> </span>(2<span class="_ _3"> </span>in<span class="_ _5"> </span>the<span class="_ _3"> </span>current<span class="_ _5"> </span>implementation).</div><div class="t m0 x32 h5 y61 ff2 fs3 fc0 sc0 ls0 ws0">Starting<span class="_ _3"> </span>a<span class="_ _5"> </span>tree<span class="_ _3"> </span>just<span class="_ _3"> </span>means<span class="_ _5"> </span>starting<span class="_ _3"> </span>recording<span class="_ _3"> </span>a<span class="_ _5"> </span>trace<span class="_ _3"> </span>for<span class="_ _3"> </span>the<span class="_ _5"> </span>current</div><div class="t m0 x32 h5 y62 ff2 fs3 fc0 sc0 ls0 ws0">point<span class="_ _5"> </span>and<span class="_ _5"> </span>type<span class="_ _7"> </span>map<span class="_ _5"> </span>and<span class="_ _5"> </span>marking<span class="_ _5"> </span>the<span class="_ _7"> </span>trace<span class="_ _5"> </span>as<span class="_ _5"> </span>the<span class="_ _7"> </span>root<span class="_ _5"> </span>of<span class="_ _5"> </span>a<span class="_ _5"> </span>tree.<span class="_ _7"> </span>Each</div><div class="t m0 x32 h5 y63 ff2 fs3 fc0 sc0 ls0 ws0">tree<span class="_ _5"> </span>is<span class="_ _5"> </span>associated<span class="_ _5"> </span>with<span class="_ _5"> </span>a<span class="_ _5"> </span>loop<span class="_ _5"> </span>header<span class="_ _7"> </span>and<span class="_ _5"> </span>type<span class="_ _5"> </span>map,<span class="_ _5"> </span>so<span class="_ _5"> </span>there<span class="_ _5"> </span>may<span class="_ _5"> </span>be</div><div class="t m0 x32 h5 y7 ff2 fs3 fc0 sc0 ls0 ws0">sev<span class="_ _2"></span>eral<span class="_ _5"> </span>trees<span class="_ _5"> </span>for<span class="_ _5"> </span>a<span class="_ _3"> </span>gi<span class="_ _2"></span>v<span class="_ _2"></span>en<span class="_ _5"> </span>loop<span class="_ _5"> </span>header<span class="_ _2"></span>.</div><div class="t m0 x33 h5 y64 ff1 fs3 fc0 sc0 ls0 ws0">Closing<span class="_ _5"> </span>the<span class="_ _5"> </span>loop.<span class="_ _3"> </span><span class="ff2">T<span class="_ _b"></span>race<span class="_ _3"> </span>recording<span class="_ _5"> </span>can<span class="_ _5"> </span>end<span class="_ _5"> </span>in<span class="_ _5"> </span>sev<span class="_ _2"></span>eral<span class="_ _5"> </span>ways.</span></div><div class="t m0 x33 h5 y66 ff2 fs3 fc0 sc0 ls0 ws0">Ideally<span class="_ _2"></span>,<span class="_ _3"> </span>the<span class="_ _3"> </span>trace<span class="_ _3"> </span>reaches<span class="_ _3"> </span>the<span class="_ _3"> </span>loop<span class="_ _3"> </span>header<span class="_ _3"> </span>where<span class="_ _3"> </span>it<span class="_ _3"> </span>started<span class="_ _3"> </span>with</div><div class="t m0 x32 h5 y67 ff2 fs3 fc0 sc0 ls0 ws0">the<span class="_ _6"> </span>same<span class="_ _8"> </span>type<span class="_ _6"> </span>map<span class="_ _8"> </span>as<span class="_ _6"> </span>on<span class="_ _6"> </span>entry<span class="_ _2"></span>.<span class="_ _6"> </span>This<span class="_ _6"> </span>is<span class="_ _8"> </span>called<span class="_ _6"> </span>a<span class="_ _8"> </span><span class="ffa">type-stable<span class="_ _6"> </span></span>loop</div><div class="t m0 x32 h5 y68 ff2 fs3 fc0 sc0 ls0 ws0">iteration.<span class="_ _6"> </span>In<span class="_ _8"> </span>this<span class="_ _6"> </span>case,<span class="_ _8"> </span>the<span class="_ _6"> </span>end<span class="_ _8"> </span>of<span class="_ _8"> </span>the<span class="_ _6"> </span>trace<span class="_ _8"> </span>can<span class="_ _6"> </span>jump<span class="_ _8"> </span>right<span class="_ _6"> </span>to<span class="_ _8"> </span>the</div><div class="t m0 x32 h5 y69 ff2 fs3 fc0 sc0 ls0 ws0">beginning,<span class="_ _5"> </span>as<span class="_ _3"> </span>all<span class="_ _5"> </span>the<span class="_ _5"> </span>value<span class="_ _5"> </span>representations<span class="_ _3"> </span>are<span class="_ _5"> </span>exactly<span class="_ _5"> </span>as<span class="_ _3"> </span>needed<span class="_ _5"> </span>to</div><div class="t m0 x32 h5 y6a ff2 fs3 fc0 sc0 ls0 ws0">enter<span class="_ _3"> </span>the<span class="_ _3"> </span>trace.<span class="_ _3"> </span>The<span class="_ _5"> </span>jump<span class="_ _3"> </span>can<span class="_ _3"> </span>e<span class="_ _2"></span>ven<span class="_ _3"> </span>skip<span class="_ _3"> </span>the<span class="_ _5"> </span>usual<span class="_ _3"> </span>code<span class="_ _3"> </span>that<span class="_ _3"> </span>would</div><div class="t m0 x32 h5 y6b ff2 fs3 fc0 sc0 ls0 ws0">copy<span class="_ _5"> </span>out<span class="_ _3"> </span>the<span class="_ _3"> </span>state<span class="_ _5"> </span>at<span class="_ _3"> </span>the<span class="_ _5"> </span>end<span class="_ _3"> </span>of<span class="_ _5"> </span>the<span class="_ _3"> </span>trace<span class="_ _5"> </span>and<span class="_ _3"> </span>copy<span class="_ _5"> </span>it<span class="_ _3"> </span>back<span class="_ _5"> </span>in<span class="_ _3"> </span>to<span class="_ _3"> </span>the</div><div class="t m0 x32 h5 y6c ff2 fs3 fc0 sc0 ls0 ws0">trace<span class="_ _5"> </span>activ<span class="_ _2"></span>ation<span class="_ _5"> </span>record<span class="_ _5"> </span>to<span class="_ _5"> </span>enter<span class="_ _3"> </span>a<span class="_ _5"> </span>trace.</div><div class="t m0 x33 h5 y6d ff2 fs3 fc0 sc0 ls0 ws0">In<span class="_ _6"> </span>certain<span class="_ _8"> </span>cases<span class="_ _8"> </span>the<span class="_ _6"> </span>trace<span class="_ _8"> </span>might<span class="_ _6"> </span>reach<span class="_ _8"> </span>the<span class="_ _8"> </span>loop<span class="_ _6"> </span>header<span class="_ _8"> </span>with<span class="_ _6"> </span>a</div><div class="t m0 x32 h5 y6e ff2 fs3 fc0 sc0 ls0 ws0">different<span class="_ _5"> </span>type<span class="_ _5"> </span>map.<span class="_ _5"> </span>This<span class="_ _7"> </span>scenario<span class="_ _5"> </span>is<span class="_ _5"> </span>sometime<span class="_ _5"> </span>observed<span class="_ _5"> </span>for<span class="_ _5"> </span>the<span class="_ _5"> </span>first</div><div class="t m0 x32 h5 y6f ff2 fs3 fc0 sc0 ls0 ws0">iteration<span class="_ _5"> </span>of<span class="_ _7"> </span>a<span class="_ _5"> </span>loop.<span class="_ _5"> </span>Some<span class="_ _5"> </span>v<span class="_ _2"></span>ariables<span class="_ _7"> </span>inside<span class="_ _5"> </span>the<span class="_ _5"> </span>loop<span class="_ _7"> </span>might<span class="_ _5"> </span>initially<span class="_ _5"> </span>be</div><div class="t m0 x32 h5 y70 ffa fs3 fc0 sc0 ls0 ws0">undefined<span class="ff2">,<span class="_ _5"> </span>before<span class="_ _7"> </span>they<span class="_ _7"> </span>are<span class="_ _5"> </span>set<span class="_ _7"> </span>to<span class="_ _5"> </span>a<span class="_ _7"> </span>concrete<span class="_ _5"> </span>type<span class="_ _7"> </span>during<span class="_ _5"> </span>the<span class="_ _7"> </span>first<span class="_ _5"> </span>loop</span></div><div class="t m0 x32 h5 y71 ff2 fs3 fc0 sc0 ls0 ws0">iteration.<span class="_ _8"> </span>When<span class="_ _d"> </span>recording<span class="_ _8"> </span>such<span class="_ _d"> </span>an<span class="_ _8"> </span>iteration,<span class="_ _d"> </span>the<span class="_ _8"> </span>recorder<span class="_ _d"> </span>cannot</div><div class="t m0 x32 h5 y72 ff2 fs3 fc0 sc0 ls0 ws0">link<span class="_ _3"> </span>the<span class="_ _5"> </span>trace<span class="_ _3"> </span>back<span class="_ _5"> </span>to<span class="_ _3"> </span>its<span class="_ _5"> </span>own<span class="_ _5"> </span>loop<span class="_ _3"> </span>header<span class="_ _5"> </span>since<span class="_ _3"> </span>it<span class="_ _5"> </span>is<span class="_ _3"> </span><span class="ffa">type-unstable</span>.</div><div class="t m0 x32 h5 y74 ff2 fs3 fc0 sc0 ls0 ws0">Instead,<span class="_ _5"> </span>the<span class="_ _3"> </span>iteration<span class="_ _5"> </span>is<span class="_ _3"> </span>terminated<span class="_ _5"> </span>with<span class="_ _5"> </span>a<span class="_ _3"> </span>side<span class="_ _5"> </span>exit<span class="_ _5"> </span>that<span class="_ _5"> </span>will<span class="_ _3"> </span>al<span class="_ _2"></span>ways</div><div class="t m0 x32 h5 y75 ff2 fs3 fc0 sc0 ls0 ws0">fail<span class="_ _3"> </span>and<span class="_ _6"> </span>return<span class="_ _6"> </span>to<span class="_ _3"> </span>the<span class="_ _6"> </span>interpreter<span class="_ _2"></span>.<span class="_ _3"> </span>At<span class="_ _6"> </span>the<span class="_ _6"> </span>same<span class="_ _3"> </span>time<span class="_ _6"> </span>a<span class="_ _6"> </span>ne<span class="_ _2"></span>w<span class="_ _6"> </span>trace<span class="_ _3"> </span>is</div><div class="t m0 x32 h5 y76 ff2 fs3 fc0 sc0 ls0 ws0">recorded<span class="_ _6"> </span>with<span class="_ _8"> </span>the<span class="_ _6"> </span>new<span class="_ _6"> </span>type<span class="_ _6"> </span>map.<span class="_ _8"> </span>Every<span class="_ _6"> </span>time<span class="_ _6"> </span>an<span class="_ _6"> </span>additional<span class="_ _8"> </span>type-</div><div class="t m0 x32 h5 y77 ff2 fs3 fc0 sc0 ls0 ws0">unstable<span class="_ _5"> </span>trace<span class="_ _5"> </span>is<span class="_ _5"> </span>added<span class="_ _5"> </span>to<span class="_ _5"> </span>a<span class="_ _5"> </span>re<span class="_ _2"></span>gion,<span class="_ _5"> </span>its<span class="_ _5"> </span>e<span class="_ _2"></span>xit<span class="_ _5"> </span>type<span class="_ _5"> </span>map<span class="_ _5"> </span>is<span class="_ _5"> </span>compared<span class="_ _5"> </span>to</div><div class="t m0 x32 h5 y78 ff2 fs3 fc0 sc0 ls0 ws0">the<span class="_ _3"> </span>entry<span class="_ _3"> </span>map<span class="_ _3"> </span>of<span class="_ _3"> </span>all<span class="_ _3"> </span>existing<span class="_ _3"> </span>traces<span class="_ _3"> </span>in<span class="_ _3"> </span>case<span class="_ _3"> </span>they<span class="_ _3"> </span>complement<span class="_ _3"> </span>each</div><div class="t m0 x32 h5 y79 ff2 fs3 fc0 sc0 ls0 ws0">other<span class="_ _2"></span>.<span class="_ _3"> </span>W<span class="_ _2"></span>ith<span class="_ _3"> </span>this<span class="_ _3"> </span>approach<span class="_ _3"> </span>we<span class="_ _3"> </span>are<span class="_ _3"> </span>able<span class="_ _6"> </span>to<span class="_ _3"> </span>cov<span class="_ _2"></span>er<span class="_ _3"> </span>type-unstable<span class="_ _3"> </span>loop</div><div class="t m0 x32 h5 y7a ff2 fs3 fc0 sc0 ls0 ws0">iterations<span class="_ _5"> </span>as<span class="_ _5"> </span>long<span class="_ _3"> </span>the<span class="_ _2"></span>y<span class="_ _5"> </span>e<span class="_ _2"></span>ventually<span class="_ _5"> </span>form<span class="_ _5"> </span>a<span class="_ _5"> </span>stable<span class="_ _5"> </span>equilibrium.</div><div class="t m0 x33 h5 y7b ff2 fs3 fc0 sc0 ls0 ws0">Finally<span class="_ _2"></span>,<span class="_ _3"> </span>the<span class="_ _3"> </span>trace<span class="_ _6"> </span>might<span class="_ _6"> </span>e<span class="_ _2"></span>xit<span class="_ _3"> </span>the<span class="_ _6"> </span>loop<span class="_ _6"> </span>before<span class="_ _3"> </span>reaching<span class="_ _6"> </span>the<span class="_ _3"> </span>loop</div><div class="t m0 x32 h5 y7c ff2 fs3 fc0 sc0 ls0 ws0">header<span class="_ _2"></span>,<span class="_ _5"> </span>for<span class="_ _5"> </span>example<span class="_ _5"> </span>because<span class="_ _5"> </span>e<span class="_ _2"></span>xecution<span class="_ _5"> </span>reaches<span class="_ _5"> </span>a<span class="_ _5"> </span><span class="ff7">break<span class="_ _5"> </span></span>or<span class="_ _5"> </span><span class="ff7">return</span></div><div class="t m0 x32 h5 y7d ff2 fs3 fc0 sc0 ls0 ws0">statement.<span class="_ _3"> </span>In<span class="_ _3"> </span>this<span class="_ _3"> </span>case,<span class="_ _3"> </span>the<span class="_ _5"> </span>VM<span class="_ _3"> </span>simply<span class="_ _3"> </span>ends<span class="_ _3"> </span>the<span class="_ _3"> </span>trace<span class="_ _3"> </span>with<span class="_ _3"> </span>an<span class="_ _3"> </span>e<span class="_ _2"></span>xit</div><div class="t m0 x32 h5 y7e ff2 fs3 fc0 sc0 ls0 ws0">to<span class="_ _5"> </span>the<span class="_ _5"> </span>trace<span class="_ _3"> </span>monitor<span class="_ _b"></span>.</div><div class="t m0 x33 h5 y7f ff2 fs3 fc0 sc0 ls0 ws0">As<span class="_ _6"> </span>mentioned<span class="_ _6"> </span>previously<span class="_ _b"></span>,<span class="_ _6"> </span>we<span class="_ _6"> </span>may<span class="_ _6"> </span>speculativ<span class="_ _2"></span>ely<span class="_ _6"> </span>chose<span class="_ _6"> </span>to<span class="_ _6"> </span>rep-</div><div class="t m0 x32 h5 y80 ff2 fs3 fc0 sc0 ls0 ws0">resent<span class="_ _3"> </span>certain<span class="_ _5"> </span>Number-typed<span class="_ _3"> </span>v<span class="_ _2"></span>alues<span class="_ _3"> </span>as<span class="_ _5"> </span>integers<span class="_ _3"> </span>on<span class="_ _5"> </span>trace.<span class="_ _3"> </span>W<span class="_ _b"></span>e<span class="_ _3"> </span>do<span class="_ _3"> </span>so</div><div class="t m0 x32 h5 y81 ff2 fs3 fc0 sc0 ls0 ws0">when<span class="_ _6"> </span>we<span class="_ _3"> </span>observe<span class="_ _6"> </span>that<span class="_ _3"> </span>Number-typed<span class="_ _3"> </span>variables<span class="_ _6"> </span>contain<span class="_ _3"> </span>an<span class="_ _6"> </span>integer</div><div class="t m0 x32 h5 y82 ff2 fs3 fc0 sc0 ls0 ws0">value<span class="_ _3"> </span>at<span class="_ _5"> </span>trace<span class="_ _3"> </span>entry<span class="_ _2"></span>.<span class="_ _5"> </span>If<span class="_ _3"> </span>during<span class="_ _3"> </span>trace<span class="_ _3"> </span>recording<span class="_ _3"> </span>the<span class="_ _5"> </span>variable<span class="_ _3"> </span>is<span class="_ _3"> </span>une<span class="_ _2"></span>x-</div><div class="t m0 x32 h5 y83 ff2 fs3 fc0 sc0 ls0 ws0">pectedly<span class="_ _3"> </span>assigned<span class="_ _6"> </span>a<span class="_ _3"> </span>non-integer<span class="_ _3"> </span>value,<span class="_ _3"> </span>we<span class="_ _3"> </span>have<span class="_ _3"> </span>to<span class="_ _3"> </span>widen<span class="_ _3"> </span>the<span class="_ _6"> </span>type</div><div class="t m0 x32 h5 y84 ff2 fs3 fc0 sc0 ls0 ws0">of<span class="_ _5"> </span>the<span class="_ _5"> </span>variable<span class="_ _5"> </span>to<span class="_ _5"> </span>a<span class="_ _3"> </span>double.<span class="_ _5"> </span>As<span class="_ _5"> </span>a<span class="_ _5"> </span>result,<span class="_ _5"> </span>the<span class="_ _3"> </span>recorded<span class="_ _5"> </span>trace<span class="_ _5"> </span>becomes</div><div class="t m0 x32 h5 y85 ff2 fs3 fc0 sc0 ls0 ws0">inherently<span class="_ _8"> </span>type-unstable<span class="_ _d"> </span>since<span class="_ _8"> </span>it<span class="_ _8"> </span>starts<span class="_ _8"> </span>with<span class="_ _d"> </span>an<span class="_ _8"> </span>integer<span class="_ _8"> </span>value<span class="_ _6"> </span>but</div><div class="t m0 x32 h5 y86 ff2 fs3 fc0 sc0 ls0 ws0">ends<span class="_ _3"> </span>with<span class="_ _3"> </span>a<span class="_ _5"> </span>double<span class="_ _3"> </span>v<span class="_ _2"></span>alue.<span class="_ _3"> </span>This<span class="_ _5"> </span>represents<span class="_ _3"> </span>a<span class="_ _3"> </span>mis-speculation,<span class="_ _3"> </span>since</div><div class="t m0 x32 h5 y87 ff2 fs3 fc0 sc0 ls0 ws0">at<span class="_ _5"> </span>trace<span class="_ _5"> </span>entry<span class="_ _5"> </span>we<span class="_ _5"> </span>specialized<span class="_ _3"> </span>the<span class="_ _5"> </span>Number<span class="_ _2"></span>-typed<span class="_ _5"> </span>v<span class="_ _2"></span>alue<span class="_ _5"> </span>to<span class="_ _5"> </span>an<span class="_ _5"> </span>integer<span class="_ _2"></span>,</div><div class="t m0 x32 h5 y88 ff2 fs3 fc0 sc0 ls0 ws0">assuming<span class="_ _5"> </span>that<span class="_ _7"> </span>at<span class="_ _5"> </span>the<span class="_ _5"> </span>loop<span class="_ _7"> </span>edge<span class="_ _5"> </span>we<span class="_ _5"> </span>w<span class="_ _2"></span>ould<span class="_ _7"> </span>again<span class="_ _5"> </span>find<span class="_ _5"> </span>an<span class="_ _7"> </span>integer<span class="_ _5"> </span>v<span class="_ _2"></span>alue</div><div class="t m0 x32 h5 y89 ff2 fs3 fc0 sc0 ls0 ws0">in<span class="_ _5"> </span>the<span class="_ _3"> </span>v<span class="_ _2"></span>ariable,<span class="_ _5"> </span>allo<span class="_ _2"></span>wing<span class="_ _5"> </span>us<span class="_ _5"> </span>to<span class="_ _3"> </span>close<span class="_ _5"> </span>the<span class="_ _5"> </span>loop.<span class="_ _5"> </span>T<span class="_ _2"></span>o<span class="_ _5"> </span>a<span class="_ _2"></span>v<span class="_ _2"></span>oid<span class="_ _5"> </span>future<span class="_ _3"> </span>spec-</div><div class="t m0 x32 h5 y12f ff2 fs3 fc0 sc0 ls0 ws0">ulativ<span class="_ _2"></span>e<span class="_ _3"> </span>failures<span class="_ _3"> </span>in<span class="_ _2"></span>v<span class="_ _2"></span>olving<span class="_ _3"> </span>this<span class="_ _3"> </span>v<span class="_ _2"></span>ariable,<span class="_ _3"> </span>and<span class="_ _3"> </span>to<span class="_ _3"> </span>obtain<span class="_ _3"> </span>a<span class="_ _3"> </span>type-stable</div><div class="t m0 x32 h5 y130 ff2 fs3 fc0 sc0 ls0 ws0">trace<span class="_ _5"> </span>we<span class="_ _5"> </span>note<span class="_ _5"> </span>the<span class="_ _7"> </span>fact<span class="_ _5"> </span>that<span class="_ _5"> </span>the<span class="_ _5"> </span>v<span class="_ _2"></span>ariable<span class="_ _5"> </span>in<span class="_ _7"> </span>question<span class="_ _5"> </span>as<span class="_ _5"> </span>been<span class="_ _5"> </span>observ<span class="_ _2"></span>ed</div><div class="t m0 x32 h5 y131 ff2 fs3 fc0 sc0 ls0 ws0">to<span class="_ _5"> </span>sometimes<span class="_ _3"> </span>hold<span class="_ _5"> </span>non-integer<span class="_ _5"> </span>values<span class="_ _5"> </span>in<span class="_ _3"> </span>an<span class="_ _5"> </span>advisory<span class="_ _5"> </span>data<span class="_ _3"> </span>structure</div><div class="t m0 x32 h5 y132 ff2 fs3 fc0 sc0 ls0 ws0">which<span class="_ _5"> </span>we<span class="_ _5"> </span>call<span class="_ _3"> </span>the<span class="_ _5"> </span>“oracle”.</div><div class="t m0 x33 h5 y133 ff2 fs3 fc0 sc0 ls0 ws0">When<span class="_ _3"> </span>compiling<span class="_ _3"> </span>loops,<span class="_ _3"> </span>we<span class="_ _5"> </span>consult<span class="_ _3"> </span>the<span class="_ _3"> </span>oracle<span class="_ _3"> </span>before<span class="_ _3"> </span>specializ-</div><div class="t m0 x32 h5 y134 ff2 fs3 fc0 sc0 ls0 ws0">ing<span class="_ _6"> </span>values<span class="_ _3"> </span>to<span class="_ _8"> </span>integers.<span class="_ _6"> </span>Speculation<span class="_ _6"> </span>to<span class="_ _2"></span>wards<span class="_ _6"> </span>inte<span class="_ _2"></span>gers<span class="_ _6"> </span>is<span class="_ _6"> </span>performed</div><div class="t m0 x32 h5 y135 ff2 fs3 fc0 sc0 ls0 ws0">only<span class="_ _6"> </span>if<span class="_ _6"> </span>no<span class="_ _6"> </span>adverse<span class="_ _6"> </span>information<span class="_ _8"> </span>is<span class="_ _6"> </span>known<span class="_ _6"> </span>to<span class="_ _6"> </span>the<span class="_ _6"> </span>oracle<span class="_ _6"> </span>about<span class="_ _6"> </span>that</div><div class="t m0 x32 h5 y136 ff2 fs3 fc0 sc0 ls0 ws0">particular<span class="_ _3"> </span>v<span class="_ _2"></span>ariable.<span class="_ _3"> </span>Whene<span class="_ _2"></span>ver<span class="_ _3"> </span>we<span class="_ _5"> </span>accidentally<span class="_ _3"> </span>compile<span class="_ _3"> </span>a<span class="_ _3"> </span>loop<span class="_ _3"> </span>that</div><div class="t m0 x32 h5 y137 ff2 fs3 fc0 sc0 ls0 ws0">is<span class="_ _8"> </span>type-unstable<span class="_ _8"> </span>due<span class="_ _8"> </span>to<span class="_ _8"> </span>mis-speculation<span class="_ _8"> </span>of<span class="_ _8"> </span>a<span class="_ _8"> </span>Number-typed<span class="_ _6"> </span>vari-</div><div class="t m0 x32 h5 y138 ff2 fs3 fc0 sc0 ls0 ws0">able,<span class="_ _3"> </span>we<span class="_ _6"> </span>immediately<span class="_ _6"> </span>trigger<span class="_ _3"> </span>the<span class="_ _6"> </span>recording<span class="_ _3"> </span>of<span class="_ _6"> </span>a<span class="_ _3"> </span>new<span class="_ _3"> </span>trace,<span class="_ _6"> </span>which</div><div class="t m0 x32 h5 y139 ff2 fs3 fc0 sc0 ls0 ws0">based<span class="_ _5"> </span>on<span class="_ _3"> </span>the<span class="_ _5"> </span>no<span class="_ _2"></span>w<span class="_ _5"> </span>updated<span class="_ _5"> </span>oracle<span class="_ _3"> </span>information<span class="_ _5"> </span>will<span class="_ _5"> </span>start<span class="_ _5"> </span>with<span class="_ _5"> </span>a<span class="_ _3"> </span>dou-</div><div class="t m0 x32 h5 y13a ff2 fs3 fc0 sc0 ls0 ws0">ble<span class="_ _5"> </span>value<span class="_ _5"> </span>and<span class="_ _5"> </span>thus<span class="_ _5"> </span>become<span class="_ _5"> </span>type<span class="_ _3"> </span>stable.</div><div class="t m0 x33 h5 y13b ff1 fs3 fc0 sc0 ls0 ws0">Extending<span class="_ _d"> </span>a<span class="_ _8"> </span>tree.<span class="_ _d"> </span><span class="ff2">Side<span class="_ _8"> </span>exits<span class="_ _d"> </span>lead<span class="_ _d"> </span>to<span class="_ _8"> </span>different<span class="_ _d"> </span>paths<span class="_ _8"> </span>through</span></div><div class="t m0 x32 h5 y13c ff2 fs3 fc0 sc0 ls0 ws0">the<span class="_ _3"> </span>loop,<span class="_ _3"> </span>or<span class="_ _3"> </span>paths<span class="_ _3"> </span>with<span class="_ _3"> </span>dif<span class="_ _2"></span>ferent<span class="_ _3"> </span>types<span class="_ _3"> </span>or<span class="_ _5"> </span>representations.<span class="_ _3"> </span>Thus,<span class="_ _3"> </span>to</div><div class="t m0 x32 h5 y13d ff2 fs3 fc0 sc0 ls0 ws0">completely<span class="_ _5"> </span>co<span class="_ _2"></span>ver<span class="_ _5"> </span>the<span class="_ _7"> </span>loop,<span class="_ _5"> </span>the<span class="_ _5"> </span>VM<span class="_ _7"> </span>must<span class="_ _5"> </span>record<span class="_ _5"> </span>traces<span class="_ _7"> </span>starting<span class="_ _5"> </span>at<span class="_ _5"> </span>all</div><div class="t m0 x32 h5 y13e ff2 fs3 fc0 sc0 ls0 ws0">side<span class="_ _5"> </span>exits.<span class="_ _3"> </span>These<span class="_ _5"> </span>traces<span class="_ _5"> </span>are<span class="_ _3"> </span>recorded<span class="_ _5"> </span>much<span class="_ _5"> </span>like<span class="_ _3"> </span>root<span class="_ _5"> </span>traces:<span class="_ _5"> </span>there<span class="_ _3"> </span>is</div><div class="t m0 x32 h5 y13f ff2 fs3 fc0 sc0 ls0 ws0">a<span class="_ _5"> </span>counter<span class="_ _7"> </span>for<span class="_ _5"> </span>each<span class="_ _5"> </span>side<span class="_ _5"> </span>e<span class="_ _2"></span>xit,<span class="_ _7"> </span>and<span class="_ _5"> </span>when<span class="_ _5"> </span>the<span class="_ _7"> </span>counter<span class="_ _5"> </span>reaches<span class="_ _5"> </span>a<span class="_ _5"> </span>hotness</div><div class="t m0 x32 h5 y140 ff2 fs3 fc0 sc0 ls0 ws0">threshold,<span class="_ _3"> </span>recording<span class="_ _5"> </span>starts.<span class="_ _3"> </span>Recording<span class="_ _3"> </span>stops<span class="_ _3"> </span>e<span class="_ _2"></span>xactly<span class="_ _3"> </span>as<span class="_ _5"> </span>for<span class="_ _3"> </span>the<span class="_ _3"> </span>root</div><div class="t m0 x32 h5 y150 ff2 fs3 fc0 sc0 ls0 ws0">trace,<span class="_ _5"> </span>using<span class="_ _5"> </span>the<span class="_ _3"> </span>loop<span class="_ _5"> </span>header<span class="_ _5"> </span>of<span class="_ _5"> </span>the<span class="_ _5"> </span>root<span class="_ _5"> </span>trace<span class="_ _5"> </span>as<span class="_ _3"> </span>the<span class="_ _5"> </span>tar<span class="_ _2"></span>get<span class="_ _5"> </span>to<span class="_ _5"> </span>reach.</div></div><div class="pi" data-data='{"ctm":[1.673203,0.000000,0.000000,1.673203,0.000000,0.000000]}'></div></div></div>
|