145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgPROC_FRAME sample 245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org db 048h; emit a REX prefix, to enable hot-patching 345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgpush rbp 445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org[pushreg rbp] 545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgsub rsp, 040h 645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org[allocstack 040h] 745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orglea rbp, [rsp+020h] 845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org[setframe rbp, 020h] 945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgmovdqa [rbp], xmm7 1045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org[savexmm128 xmm7, 020h];the offset is from the base of the frame 1145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org;not the scaled offset of the frame 1245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgmov [rbp+018h], rsi 1345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org[savereg rsi, 018h] 1445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgmov [rsp+010h], rdi 1545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org[savereg rdi, 010h]; you can still use RSP as the base of the frame 1645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org; or any other register you choose 1745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgEND_PROLOGUE 1845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 1945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org; you can modify the stack pointer outside of the prologue (similar to alloca) 2045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org; because we have a frame pointer. 2145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org; if we didn't have a frame pointer, this would be illegal 2245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org; if we didn't make this modification, 2345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org; there would be no need for a frame pointer 2445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 2545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgsub rsp, 060h 2645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 2745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org; we can unwind from the following AV because of the frame pointer 2845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 2945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgmov rax, 0 3045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgmov rax, [rax] ; AV! 3145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 3245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org; restore the registers that weren't saved with a push 3345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org; this isn't part of the official epilog, as described in section 2.5 3445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 3545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgmovdqa xmm7, [rbp] 3645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgmov rsi, [rbp+018h] 3745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgmov rdi, [rbp-010h] 3845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 3945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org; Here's the official epilog 4045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 4145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orglea rsp, [rbp-020h] 4245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgpop rbp 4345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgret 4445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgENDPROC_FRAME 4545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgstruc kFrame 4645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org.Fill resq 1 ; fill to 8 mod 16 4745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org.SavedRdi resq 1 ; saved register RDI 4845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org.SavedRsi resq 1 ; saved register RSI 4945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgendstruc 5045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 5145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgstruc sampleFrame 5245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org.Fill resq 1 ; fill to 8 mod 16 5345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org.SavedRdi resq 1 ; Saved Register RDI 5445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org.SavedRsi resq 1 ; Saved Register RSI 5545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgendstruc 5645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 5745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgPROC_FRAME sample2 5845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgalloc_stack sampleFrame_size 5945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgsave_reg rdi, sampleFrame.SavedRdi 6045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgsave_reg rsi, sampleFrame.SavedRsi 6145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgEND_PROLOGUE 6245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 6345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org; function body 6445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 6545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgmov rsi, [rsp+sampleFrame.SavedRsi] 6645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgmov rdi, [rsp+sampleFrame.SavedRdi] 6745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 6845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org; Here's the official epilog 6945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 7045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgadd rsp, sampleFrame_size 7145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgret 7245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgENDPROC_FRAME 7345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 74