BT /F33 8.9664 Tf 54 713.7733 Td[(v0)-525(:=)-525(ld)-525(state[748])-2625(//)-525(load)-525(primes)-525(from)-525(the)-525(trace)-525(activation)-525(record)]TJ 28.2438 -9.9626 Td[(st)-525(sp[0],)-525(v0)-3150(//)-525(store)-525(primes)-525(to)-525(interpreter)-525(stack)]TJ -28.2438 -9.9626 Td[(v1)-525(:=)-525(ld)-525(state[764])-2625(//)-525(load)-525(k)-525(from)-525(the)-525(trace)-525(activation)-525(record)]TJ 0 -9.9627 Td[(v2)-525(:=)-525(i2f\050v1\051)-5775(//)-525(convert)-525(k)-525(from)-525(int)-525(to)-525(double)]TJ 28.2438 -9.9626 Td[(st)-525(sp[8],)-525(v1)-3150(//)-525(store)-525(k)-525(to)-525(interpreter)-525(stack)]TJ 0 -9.9627 Td[(st)-525(sp[16],)-525(0)-3150(//)-525(store)-525(false)-525(to)-525(interpreter)-525(stack)]TJ -28.2438 -9.9626 Td[(v3)-525(:=)-525(ld)-525(v0[4])-5250(//)-525(load)-525(class)-525(word)-525(for)-525(primes)]TJ 0 -9.9626 Td[(v4)-525(:=)-525(and)-525(v3,)-525(-4)-4200(//)-525(mask)-525(out)-525(object)-525(class)-525(tag)-525(for)-525(primes)]TJ 0 -9.9627 Td[(v5)-525(:=)-525(eq)-525(v4,)-525(Array)-3150(//)-525(test)-525(whether)-525(primes)-525(is)-525(an)-525(array)]TJ 28.2438 -9.9626 Td[(xf)-525(v5)-6825(//)-525(side)-525(exit)-525(if)-525(v5)-525(is)-525(false)]TJ -28.2438 -9.9627 Td[(v6)-525(:=)-525(js_Array_set\050v0,)-525(v2,)-525(false\051)-1050(//)-525(call)-525(function)-525(to)-525(set)-525(array)-525(element)]TJ 0 -9.9626 Td[(v7)-525(:=)-525(eq)-525(v6,)-525(0)-5250(//)-525(test)-525(return)-525(value)-525(from)-525(call)]TJ 28.2438 -9.9626 Td[(xt)-525(v7)-6825(//)-525(side)-525(exit)-525(if)-525(js_Array_set)-525(returns)-525(false.)]TJ ET 1 0 0 1 54 580.9414 cm q []0 d 0 J 0.3288 w 0 0.1644 m 502.1171 0.1644 l S Q 1 0 0 1 -54 -580.9414 cm BT /F41 8.9664 Tf 54 570.7786 Td[(Figur)18(e)-350(3.)-500(LIR)-349(snippet)-350(f)25(or)-349(sample)-350(pr)18(ogram.)]TJ/F42 8.9664 Tf 173.1706 0 Td[(This)-350(is)-349(the)-350(LIR)-349(recorded)-350(for)-349(line)-350(5)-350(of)-349(the)-350(sample)-349(program)-350(in)-349(Figure)-350(1.)-350(The)-349(LIR)-350(encodes)]TJ -173.1706 -9.9626 Td[(the)-328(semantics)-328(in)-328(SSA)-328(form)-328(using)-327(temporary)-328(v)25(ariables.)-328(The)-328(LIR)-328(also)-328(encodes)-328(all)-328(the)-328(stores)-328(that)-328(the)-327(interpreter)-328(w)10(ould)-328(do)-328(to)-328(its)-328(data)-328(stack.)]TJ 0 -9.9627 Td[(Sometimes)-255(these)-256(stores)-255(can)-256(be)-255(optimized)-256(a)15(w)10(ay)-255(as)-255(the)-256(stack)-255(locations)-256(are)-255(li)25(v)15(e)-256(only)-255(on)-256(e)15(xits)-255(to)-255(the)-256(interpreter)55(.)-255(Finally)65(,)-256(the)-255(LIR)-256(records)-255(guards)]TJ 0 -9.9626 Td[(and)-250(side)-250(e)15(xits)-250(to)-250(v)15(erify)-250(the)-250(assumptions)-250(made)-250(in)-250(this)-250(recording:)-250(that)]TJ/F33 8.9664 Tf 244.2951 0 Td[(primes)]TJ/F42 8.9664 Tf 30.4854 0 Td[(is)-250(an)-250(array)-250(and)-250(that)-250(the)-250(call)-250(to)-250(set)-250(its)-250(element)-250(succeeds.)]TJ/F33 8.9664 Tf -274.7805 -26.1519 Td[(mov)-525(edx,)-525(ebx\050748\051)-3150(//)-525(load)-525(primes)-525(from)-525(the)-525(trace)-525(activation)-525(record)]TJ 0 -9.9627 Td[(mov)-525(edi\0500\051,)-525(edx)-4200(//)-525(\050*\051)-525(store)-525(primes)-525(to)-525(interpreter)-525(stack)]TJ 0 -9.9626 Td[(mov)-525(esi,)-525(ebx\050764\051)-3150(//)-525(load)-525(k)-525(from)-525(the)-525(trace)-525(activation)-525(record)]TJ 0 -9.9627 Td[(mov)-525(edi\0508\051,)-525(esi)-4200(//)-525(\050*\051)-525(store)-525(k)-525(to)-525(interpreter)-525(stack)]TJ 0 -9.9626 Td[(mov)-525(edi\05016\051,)-525(0)-4725(//)-525(\050*\051)-525(store)-525(false)-525(to)-525(interpreter)-525(stack)]TJ 0 -9.9626 Td[(mov)-525(eax,)-525(edx\0504\051)-4200(//)-525(\050*\051)-525(load)-525(object)-525(class)-525(word)-525(for)-525(primes)]TJ 0 -9.9627 Td[(and)-525(eax,)-525(-4)-6300(//)-525(\050*\051)-525(mask)-525(out)-525(object)-525(class)-525(tag)-525(for)-525(primes)]TJ 0 -9.9626 Td[(cmp)-525(eax,)-525(Array)-4725(//)-525(\050*\051)-525(test)-525(whether)-525(primes)-525(is)-525(an)-525(array)]TJ 0 -9.9627 Td[(jne)-525(side_exit_1)-4200(//)-525(\050*\051)-525(side)-525(exit)-525(if)-525(primes)-525(is)-525(not)-525(an)-525(array)]TJ 0 -9.9626 Td[(sub)-525(esp,)-525(8)-6825(//)-525(bump)-525(stack)-525(for)-525(call)-525(alignment)-525(convention)]TJ 0 -9.9626 Td[(push)-525(false)-6825(//)-525(push)-525(last)-525(argument)-525(for)-525(call)]TJ 0 -9.9627 Td[(push)-525(esi)-7875(//)-525(push)-525(first)-525(argument)-525(for)-525(call)]TJ 0 -9.9626 Td[(call)-525(js_Array_set)-3150(//)-525(call)-525(function)-525(to)-525(set)-525(array)-525(element)]TJ 0 -9.9627 Td[(add)-525(esp,)-525(8)-6825(//)-525(clean)-525(up)-525(extra)-525(stack)-525(space)]TJ 0 -9.9626 Td[(mov)-525(ecx,)-525(ebx)-5775(//)-525(\050*\051)-525(created)-525(by)-525(register)-525(allocator)]TJ 0 -9.9626 Td[(test)-525(eax,)-525(eax)-5250(//)-525(\050*\051)-525(test)-525(return)-525(value)-525(of)-525(js_Array_set)]TJ 0 -9.9627 Td[(je)-525(side_exit_2)-4725(//)-525(\050*\051)-525(side)-525(exit)-525(if)-525(call)-525(failed)]TJ 0 -9.9626 Td[(...)]TJ 0 -9.9627 Td[(side_exit_1:)]TJ 0 -9.9626 Td[(mov)-525(ecx,)-525(ebp\050-4\051)-3675(//)-525(restore)-525(ecx)]TJ 0 -9.9626 Td[(mov)-525(esp,)-525(ebp)-5775(//)-525(restore)-525(esp)]TJ 0 -9.9627 Td[(jmp)-525(epilog)-6825(//)-525(jump)-525(to)-525(ret)-525(statement)]TJ ET 1 0 0 1 54 292.2431 cm q []0 d 0 J 0.3288 w 0 0.1644 m 502.1171 0.1644 l S Q 1 0 0 1 -54 -292.2431 cm BT /F41 8.9664 Tf 54 282.0803 Td[(Figur)18(e)-224(4.)-500(x86)-224(snippet)-223(f)25(or)-224(sample)-224(pr)18(ogram.)]TJ/F42 8.9664 Tf 163.9137 0 Td[(This)-224(is)-224(the)-223(x86)-224(code)-224(compiled)-224(from)-224(the)-224(LIR)-223(snippet)-224(in)-224(Figure)-224(3.)-224(Most)-224(LIR)-223(instructions)-224(compile)]TJ -163.9137 -9.9627 Td[(to)-308(a)-307(single)-308(x86)-307(instruction.)-308(Instructions)-307(mark)10(ed)-308(with)]TJ/F33 8.9664 Tf 193.5674 0 Td[(\050*\051)]TJ/F42 8.9664 Tf 16.8795 0 Td[(w)10(ould)-308(be)-307(omitted)-308(by)-307(an)-308(idealized)-307(compiler)-308(that)-307(kne)25(w)-308(that)-307(none)-308(of)-307(the)-308(side)-307(e)15(xits)]TJ -210.4469 -9.9626 Td[(w)10(ould)-263(e)25(v)15(er)-263(be)-263(tak)10(en.)-263(The)-263(17)-263(instructions)-263(generated)-263(by)-263(the)-263(compiler)-263(compare)-263(f)10(a)20(v)20(orably)-263(with)-263(the)-263(100+)-263(instructions)-263(that)-263(the)-263(interpreter)-263(w)10(ould)]TJ 0 -9.9627 Td[(e)15(x)15(ecute)-250(for)-250(the)-250(same)-250(code)-250(snippet,)-250(including)-250(4)-250(indirect)-250(jumps.)]TJ/F41 8.9664 Tf 11.9552 -29.8365 Td[(i=2.)]TJ/F42 8.9664 Tf 17.8463 0 Td[(This)-392(is)-393(the)-392(\002rst)-392(iteration)-393(of)-392(the)-392(outer)-393(loop.)-392(The)-393(loop)-392(on)]TJ -29.8015 -9.9626 Td[(lines)-265(4-5)-265(becomes)-264(hot)-265(on)-265(its)-265(second)-264(iteration,)-265(so)-265(T)35(raceMonk)10(e)15(y)-265(en-)]TJ 0 -9.9627 Td[(ters)-359(recording)-359(mode)-360(on)-359(line)-359(4.)-359(In)-359(recording)-360(m)1(ode,)-360(T)35(raceMonk)10(e)15(y)]TJ 0 -9.9626 Td[(records)-257(the)-257(code)-258(along)-257(the)-257(trace)-257(in)-257(a)-257(lo)25(w-le)25(v)15(el)-258(compiler)-257(intermedi-)]TJ 0 -9.9627 Td[(ate)-258(representation)-257(we)-258(call)]TJ/F46 8.9664 Tf 93.8904 0 Td[(LIR)]TJ/F42 8.9664 Tf 13.4495 0 Td[(.)-258(The)-257(LIR)-258(trace)-257(encodes)-258(all)-258(the)-257(oper)20(-)]TJ -107.3399 -9.9626 Td[(ations)-266(performed)-265(and)-266(the)-266(types)-265(of)-266(all)-266(operands.)-266(The)-265(LIR)-266(trace)-266(also)]TJ 0 -9.9626 Td[(encodes)]TJ/F46 8.9664 Tf 31.4698 0 Td[(guar)37(ds)]TJ/F42 8.9664 Tf 24.5767 0 Td[(,)-289(which)-289(are)-288(checks)-289(that)-289(v)15(erify)-289(that)-288(the)-289(control)-289(\003o)25(w)]TJ -56.0465 -9.9627 Td[(and)-370(types)-369(are)-370(identical)-370(to)-369(those)-370(observ)15(ed)-369(during)-370(trace)-370(recording.)]TJ 0 -9.9626 Td[(Thus,)-306(on)-306(later)-306(e)15(x)15(ecutions,)-307(if)-306(and)-306(only)-306(if)-306(all)-306(guards)-306(are)-307(passed,)-306(the)]TJ 0 -9.9627 Td[(trace)-250(has)-250(the)-250(required)-250(program)-250(semantics.)]TJ 11.9552 -9.9626 Td[(T)35(raceMonk)10(e)15(y)-442(stops)-442(recording)-443(when)-442(e)15(x)15(ecution)-442(returns)-442(to)-442(the)]TJ -11.9552 -9.9626 Td[(loop)-282(header)-282(or)-282(e)15(xits)-282(the)-281(loop.)-282(In)-282(this)-282(case,)-282(e)15(x)15(ecution)-282(returns)-282(to)-282(the)]TJ 0 -9.9627 Td[(loop)-250(header)-250(on)-250(line)-250(4.)]TJ 11.9552 -9.9626 Td[(After)-276(recording)-275(is)-276(\002nished,)-275(T)35(raceMonk)10(e)15(y)-276(compiles)-275(the)-276(trace)-275(to)]TJ -11.9552 -9.9627 Td[(nati)25(v)15(e)-321(code)-322(using)-321(the)-322(recorded)-321(type)-322(information)-321(for)-322(optimization.)]TJ 0 -9.9626 Td[(The)-439(result)-439(is)-439(a)-439(nati)25(v)15(e)-439(code)-439(fragment)-439(that)-439(can)-439(be)-440(entered)-439(if)-439(the)]TJ 263.0137 149.4396 Td[(interpreter)-282(PC)-282(and)-283(the)-282(types)-282(of)-283(v)25(alues)-282(match)-282(those)-282(observ)15(ed)-283(when)]TJ 0 -9.9626 Td[(trace)-392(recording)-393(w)10(as)-392(started.)-392(The)-392(\002rst)-393(trace)-392(in)-392(our)-392(e)15(xample,)]TJ/F29 8.9664 Tf 223.6818 0 Td[(T)]TJ/F28 5.9776 Tf 5.376 -0.9963 Td[(45)]TJ/F42 8.9664 Tf 7.804 0.9963 Td[(,)]TJ -236.8618 -9.9627 Td[(co)15(v)15(ers)-238(lines)-239(4)-238(and)-238(5.)-238(This)-239(trace)-238(can)-238(be)-239(entered)-238(if)-238(the)-239(PC)-238(is)-238(at)-238(line)-239(4,)]TJ/F33 8.9664 Tf 0 -9.9626 Td[(i)]TJ/F42 8.9664 Tf 6.774 0 Td[(and)]TJ/F33 8.9664 Tf 15.0142 0 Td[(k)]TJ/F42 8.9664 Tf 6.774 0 Td[(are)-230(inte)15(gers,)-231(and)]TJ/F33 8.9664 Tf 60.5897 0 Td[(primes)]TJ/F42 8.9664 Tf 30.3105 0 Td[(is)-230(an)-231(object.)-230(After)-231(compiling)]TJ/F29 8.9664 Tf 104.2194 0 Td[(T)]TJ/F28 5.9776 Tf 5.376 -0.9963 Td[(45)]TJ/F42 8.9664 Tf 7.804 0.9963 Td[(,)]TJ -236.8618 -9.9627 Td[(T)35(raceMonk)10(e)15(y)-250(returns)-250(to)-250(the)-250(interpreter)-250(and)-250(loops)-250(back)-250(to)-250(line)-250(1.)]TJ/F41 8.9664 Tf 11.9552 -9.9626 Td[(i=3.)]TJ/F42 8.9664 Tf 17.3136 0 Td[(No)25(w)-333(the)-333(loop)-333(header)-333(at)-333(line)-333(1)-333(has)-333(become)-333(hot,)-332(so)-333(T)35(race-)]TJ -29.2688 -9.9626 Td[(Monk)10(e)15(y)-390(starts)-391(recording.)-390(When)-391(recording)-390(reaches)-391(line)-390(4,)-391(T)35(race-)]TJ 0 -9.9627 Td[(Monk)10(e)15(y)-307(observ)15(es)-307(that)-308(it)-307(has)-307(reached)-307(an)-308(inner)-307(loop)-307(header)-307(that)-308(al-)]TJ 0 -9.9626 Td[(ready)-332(has)-331(a)-332(compiled)-331(trace,)-332(so)-331(T)35(raceMonk)10(e)15(y)-332(attempts)-332(to)-331(nest)-332(the)]TJ 0 -9.9627 Td[(inner)-255(loop)-254(inside)-255(the)-254(current)-255(trace.)-255(The)-254(\002rst)-255(step)-254(is)-255(to)-255(ca)1(ll)-255(the)-255(inner)]TJ 0 -9.9626 Td[(trace)-209(as)-209(a)-208(subroutine.)-209(This)-209(e)15(x)15(ecutes)-209(the)-209(loop)-208(on)-209(line)-209(4)-209(to)-209(completion)]TJ 0 -9.9626 Td[(and)-255(then)-256(returns)-255(to)-255(the)-256(recorder)55(.)-255(T)35(raceMonk)10(e)15(y)-256(v)15(eri\002es)-255(that)-255(the)-256(call)]TJ 0 -9.9627 Td[(w)10(as)-232(successful)-232(and)-232(then)-232(records)-233(the)-232(call)-232(to)-232(the)-232(inner)-232(trace)-232(as)-233(part)-232(of)]TJ 0 -9.9626 Td[(the)-279(current)-279(trace.)-279(Recor)1(ding)-279(continues)-279(until)-279(e)15(x)15(ecution)-279(reaches)-279(line)]TJ 0 -9.9627 Td[(1,)-320(and)-321(at)-320(which)-321(point)-320(T)35(raceMonk)10(e)15(y)-320(\002nishes)-321(and)-320(compiles)-320(a)-321(trace)]TJ 0 -9.9626 Td[(for)-250(the)-250(outer)-250(loop,)]TJ/F29 8.9664 Tf 66.9873 0 Td[(T)]TJ/F28 5.9776 Tf 5.376 -0.9962 Td[(16)]TJ/F42 8.9664 Tf 7.804 0.9962 Td[(.)]TJ ET