Created
June 20, 2017 19:35
-
-
Save JosephTremoulet/cc728b7db5b511487d5a75acd91e0e84 to your computer and use it in GitHub Desktop.
Example code showing finally cloning (asm, no cloning)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Assembly listing for method Test:Update(byref,byref) | |
; Emitting BLENDED_CODE for X64 CPU with SSE2 | |
; optimized code | |
; rbp based frame | |
; fully interruptible | |
; Final local variable assignments | |
; | |
; V00 arg0 [V00,T00] ( 4, 4 ) byref -> rcx | |
; V01 arg1 [V01,T01] ( 4, 4 ) byref -> [rbp+0x18] do-not-enreg[H] | |
; V02 OutArgs [V02 ] ( 1, 1 ) lclBlk (32) [rsp+0x00] | |
; V03 PSPSym [V03 ] ( 1, 1 ) long -> [rbp-0x10] do-not-enreg[X] addr-exposed | |
; | |
; Lcl frame size = 48 | |
G_M62690_IG01: | |
55 push rbp ; set up call frame | |
4883EC30 sub rsp, 48 | |
488D6C2430 lea rbp, [rsp+30H] | |
488965F0 mov qword ptr [rbp-10H], rsp | |
48895518 mov bword ptr [rbp+18H], rdx ; store pointer to `right` in frame | |
G_M62690_IG02: | |
8B01 mov eax, dword ptr [rcx] | |
83C001 add eax, 1 ; compute `left + 1` | |
7004 jo SHORT G_M62690_IG03 ; raise exception on overflow | |
8901 mov dword ptr [rcx], eax ; store new value to `left` | |
EB06 jmp SHORT G_M62690_IG04 | |
G_M62690_IG03: | |
E8CEF3AB5F call CORINFO_HELP_OVERFLOW | |
CC int3 | |
G_M62690_IG04: | |
488BCC mov rcx, rsp | |
E807000000 call G_M62690_IG07 ; non-excpetion path: call finally handler | |
G_M62690_IG05: | |
90 nop | |
G_M62690_IG06: | |
488D6500 lea rsp, [rbp] ; tear down call frame | |
5D pop rbp | |
C3 ret ; return | |
;; Code above is all of method `Update` except for the `finally` clause | |
;; Code below is all the `finally` clause of method `Update` | |
G_M62690_IG07: | |
55 push rbp ; set up a new frame for the `finally` handler | |
4883EC30 sub rsp, 48 | |
488B6920 mov rbp, qword ptr [rcx+32] ; find the original frame for the `Update` method | |
48896C2420 mov qword ptr [rsp+20H], rbp | |
488D6D30 lea rbp, [rbp+30H] | |
G_M62690_IG08: | |
488B4518 mov rax, bword ptr [rbp+18H] ; load pointer to `right` from parent frame | |
830001 add dword ptr [rax], 1 ; increment `right` | |
G_M62690_IG09: | |
4883C430 add rsp, 48 ; tear down handler frame | |
5D pop rbp | |
C3 ret ; return (to either exception dispatch code or `Update`) | |
; Total bytes of code 81, prolog size 18 for method Test:Update(byref,byref) | |
; ============================================================ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment