우선 간단한 다음과 같은 메서드를 작성하고,
릴리즈 모드에서 어떤 모습일까 궁금해 디스어셈블리 창을 열었습니다.
public void func()
{
if (list != null)
{
for (int i = 0; i < list.Count; i++)
{
list[i] = list[i] + 20;
}
}
}
다음과 같습니다. (이게 전체가 아닌 일부분입니다.)
public void func()
{
if (list != null)
00007FFD4040B5A0 sub rsp,28h
00007FFD4040B5A4 mov rax,qword ptr [rcx+8]
00007FFD4040B5A8 test rax,rax
00007FFD4040B5AB je ConsoleApp1.MyTest.func()+04Eh (07FFD4040B5EEh)
{
for (int i = 0; i < list.Count; i++)
00007FFD4040B5AD xor edx,edx
for (int i = 0; i < list.Count; i++)
00007FFD4040B5AF mov rcx,rax
00007FFD4040B5B2 mov ecx,dword ptr [rcx+10h]
00007FFD4040B5B5 test ecx,ecx
00007FFD4040B5B7 jle ConsoleApp1.MyTest.func()+04Eh (07FFD4040B5EEh)
{
list[i] = list[i] + 20;
00007FFD4040B5B9 mov r8,rax
00007FFD4040B5BC mov r9,rax
00007FFD4040B5BF cmp edx,ecx
00007FFD4040B5C1 jae ConsoleApp1.MyTest.func()+053h (07FFD4040B5F3h)
00007FFD4040B5C3 mov r9,qword ptr [r9+8]
00007FFD4040B5C7 mov r10,r9
00007FFD4040B5CA mov r11d,dword ptr [r10+8]
00007FFD4040B5CE cmp edx,r11d
00007FFD4040B5D1 jae ConsoleApp1.MyTest.func()+059h (07FFD4040B5F9h)
00007FFD4040B5D3 movsxd r11,edx
00007FFD4040B5D6 mov r10d,dword ptr [r10+r114+10h]
00007FFD4040B5DB add r10d,14h
00007FFD4040B5DF mov dword ptr [r9+r114+10h],r10d
00007FFD4040B5E4 inc dword ptr [r8+14h]
for (int i = 0; i < list.Count; i++)
00007FFD4040B5E8 inc edx
00007FFD4040B5EA cmp edx,ecx
00007FFD4040B5EC jl ConsoleApp1.MyTest.func()+019h (07FFD4040B5B9h)
00007FFD4040B5EE add rsp,28h
00007FFD4040B5F2 ret
00007FFD4040B5F3 call CLRStub[MethodDescPrestub]@7ffd4040b328 (07FFD4040B328h)
00007FFD4040B5F8 int 3
00007FFD4040B5F9 call 00007FFDA009F410
00007FFD4040B5FE int 3
00007FFD4040B5FF add byte ptr [rcx],bl
00007FFD4040B601 add al,1
00007FFD4040B603 add byte ptr [rdx+rax2],al
00007FFD4040B606 add byte ptr [rax],al
00007FFD4040B608 add byte ptr [rax],al
00007FFD4040B60A add byte ptr [rax],al
00007FFD4040B60C add byte ptr [rax],al
00007FFD4040B60E add byte ptr [rax],al
00007FFD4040B610 add al,byte ptr [rax]
00007FFD4040B612 add byte ptr [rax],al
00007FFD4040B614 add byte ptr [rax],al
00007FFD4040B616 add byte ptr [rax],al
00007FFD4040B618 call 00007FFD9FF7AB00
00007FFD4040B61D pop rsi
00007FFD4040B61E add byte ptr [rbx],al
00007FFD4040B620 call 00007FFD9FF7AB00
00007FFD4040B625 pop rsi
00007FFD4040B626 add eax,dword ptr [rdx]
00007FFD4040B628 call 00007FFD9FF7AB00
00007FFD4040B62D pop rsi
00007FFD4040B62E ?? ???
for (int i = 0; i < list.Count; i++)
00007FFD4040B62F add eax,ebp
00007FFD4040B631 retf
00007FFD4040B632 hlt
00007FFD4040B633 mov dh,5Fh
00007FFD4040B635 pop rsi
00007FFD4040B636 or dword ptr [rax],eax
00007FFD4040B638 add byte ptr [rsi],cl
00007FFD4040B63A push rsp
00007FFD4040B63B std
00007FFD4040B63D jg CLRStub[MethodDescPrestub]@7ffd4040b63f (07FFD4040B63Fh)
00007FFD4040B63F add al,ch
00007FFD4040B641 mov ebx,5E5FB6F4h
00007FFD4040B646 add byte ptr [rax],bh
00007FFD4040B648 call 00007FFD9FF7AB00
00007FFD4040B64D pop rsi
00007FFD4040B64E add dh,byte ptr [rdi]
00007FFD4040B650 call 00007FFD9FF7AB00
00007FFD4040B655 pop rsi
00007FFD4040B656 add al,36h
00007FFD4040B658 call 00007FFD9FF7AB00
00007FFD4040B65D pop rsi
00007FFD4040B65E ?? ???
for (int i = 0; i < list.Count; i++)
00007FFD4040B65F xor eax,0B6F49BE8h
00007FFD4040B664 pop rdi
00007FFD4040B665 pop rsi
00007FFD4040B666 or byte ptr [rax+rbp8],dh
00007FFD4040B669 xchg eax,ebx
00007FFD4040B66A hlt
00007FFD4040B66B mov dh,5Fh
00007FFD4040B66D pop rsi
00007FFD4040B66E or dh,byte ptr [rbx]
00007FFD4040B670 call 00007FFD9FF7AB00
00007FFD4040B675 pop rsi
00007FFD4040B676 or al,32h
00007FFD4040B678 call 00007FFD9FF7AB00
00007FFD4040B67D pop rsi
00007FFD4040B67E ?? ???
for (int i = 0; i < list.Count; i++)
00007FFD4040B67F xor eax,ebp
00007FFD4040B681 jnp CLRStub[MethodDescPrestub]@7ffd4040b677 (07FFD4040B677h)
00007FFD4040B683 mov dh,5Fh
00007FFD4040B685 pop rsi
00007FFD4040B686 adc byte ptr [rax],dh
00007FFD4040B688 call 00007FFD9FF7AB00
00007FFD4040B68D pop rsi
00007FFD4040B68E adc ch,byte ptr [rdi]
00007FFD4040B690 call 00007FFD9FF7AB00
00007FFD4040B695 pop rsi
00007FFD4040B696 adc al,2Eh
00007FFD4040B698 call 00007FFD9FF7AB00
00007FFD4040B69D pop rsi
00007FFD4040B69E ?? ???
for (int i = 0; i < list.Count; i++)
00007FFD4040B69F sub eax,0B6F45BE8h
00007FFD4040B6A4 pop rdi
00007FFD4040B6A5 pop rsi
00007FFD4040B6A6 sbb byte ptr [rax+rbp8],ch
00007FFD4040B6A9 push rbx
00007FFD4040B6AA hlt
00007FFD4040B6AB mov dh,5Fh
00007FFD4040B6AD pop rsi
00007FFD4040B6AE sbb ch,byte ptr [rbx]
00007FFD4040B6B0 call 00007FFD9FF7AB00
00007FFD4040B6B5 pop rsi
00007FFD4040B6B6 sbb al,2Ah
00007FFD4040B6B8 call 00007FFD9FF7AB00
00007FFD4040B6BD pop rsi
00007FFD4040B6BE ?? ???
for (int i = 0; i < list.Count; i++)
00007FFD4040B6BF sub eax,ebp
00007FFD4040B6C1 cmp esi,esp
00007FFD4040B6C3 mov dh,5Fh
00007FFD4040B6C5 pop rsi
00007FFD4040B6C6 and byte ptr [rax],ch
00007FFD4040B6C8 call 00007FFD9FF7AB00
00007FFD4040B6CD pop rsi
00007FFD4040B6CE and ah,byte ptr [rdi]
00007FFD4040B6D0 call 00007FFD9FF7AB00
00007FFD4040B6D5 pop rsi
00007FFD4040B6D6 and al,26h
00007FFD4040B6D8 call 00007FFD9FF7AB00
00007FFD4040B6DD pop rsi
00007FFD4040B6DE and eax,0B6F41BE8h
00007FFD4040B6E4 pop rdi
00007FFD4040B6E5 pop rsi
00007FFD4040B6E6 sub byte ptr [rax+rbp8],ah
00007FFD4040B6E9 adc esi,esp
00007FFD4040B6EB mov dh,5Fh
00007FFD4040B6ED pop rsi
00007FFD4040B6EE sub ah,byte ptr [rbx]
00007FFD4040B6F0 call 00007FFD9FF7AB00
00007FFD4040B6F5 pop rsi
00007FFD4040B6F6 sub al,22h
00007FFD4040B6F8 call 00007FFD9FF7AB00
00007FFD4040B6FD pop rsi
00007FFD4040B6FE and eax,ebp
00007FFD4040B701 sti
00007FFD4040B702 rep mov dh,5Fh
00007FFD4040B705 pop rsi
00007FFD4040B706 xor byte ptr [rax],ah
00007FFD4040B708 call 00007FFD9FF7AB00
00007FFD4040B70D pop rsi
00007FFD4040B70E xor bl,byte ptr [rdi]
00007FFD4040B710 call 00007FFD9FF7AB00
00007FFD4040B715 pop rsi
00007FFD4040B716 xor al,1Eh
00007FFD4040B718 call 00007FFD9FF7AB00
00007FFD4040B71D pop rsi
00007FFD4040B71E sbb eax,0B6F3DBE8h
00007FFD4040B724 pop rdi
00007FFD4040B725 pop rsi
00007FFD4040B726 cmp byte ptr [rax+rbp*8],bl
00007FFD4040B729 sal ebx,cl
00007FFD4040B72B mov dh,5Fh
00007FFD4040B72D pop rsi
00007FFD4040B72E cmp bl,byte ptr [rbx]
00007FFD4040B730 call 00007FFD9FF7AB00
00007FFD4040B735 pop rsi
00007FFD4040B736 cmp al,1Ah
00007FFD4040B738 call 00007FFD9FF7AB00
00007FFD4040B73D pop rsi
00007FFD4040B73E sbb eax,ebp
00007FFD4040B741 mov ebx,5E5FB6F3h
00007FFD4040B746 sbb al,bpl
00007FFD4040B749 mov bl,0F3h
00007FFD4040B74B mov dh,5Fh
00007FFD4040B74D pop rsi
00007FFD4040B74E ?? ???
00007FFD4040B74F ?? ???
for (int i = 0; i < list.Count; i++)
00007FFD4040B750 call 00007FFD9FF7AB00
00007FFD4040B755 pop rsi
00007FFD4040B756 ?? ???
00007FFD4040B757 ?? ???
for (int i = 0; i < list.Count; i++)
00007FFD4040B758 call 00007FFD9FF7AB00
00007FFD4040B75D pop rsi
00007FFD4040B75E adc eax,0B6F39BE8h
00007FFD4040B764 pop rdi
00007FFD4040B765 pop rsi
00007FFD4040B766 adc al,0E8h
00007FFD4040B769 xchg eax,ebx
00007FFD4040B76A rep mov dh,5Fh
00007FFD4040B76D pop rsi
00007FFD4040B76E adc rbp,rax
00007FFD4040B771 mov esi,ebx
00007FFD4040B773 mov dh,5Fh
00007FFD4040B775 pop rsi
00007FFD4040B776 adc r13b,al
00007FFD4040B779 xor ebx,0FFFFFFB6h
00007FFD4040B77C pop rdi
00007FFD4040B77D pop rsi
00007FFD4040B77E adc rax,r13
00007FFD4040B781 jnp CLRStub[MethodDescPrestub]@7ffd4040b776 (07FFD4040B776h)
00007FFD4040B783 mov dh,5Fh
00007FFD4040B785 pop rsi
00007FFD4040B786 push rax
00007FFD4040B787 adc al,ch
00007FFD4040B789 jae CLRStub[MethodDescPrestub]@7ffd4040b77e (07FFD4040B77Eh)
00007FFD4040B78B mov dh,5Fh
00007FFD4040B78D pop rsi
00007FFD4040B78E push rdx
00007FFD4040B78F psubsb mm5,mmword ptr [rbx-0Dh]
00007FFD4040B793 mov dh,5Fh
00007FFD4040B795 pop rsi
00007FFD4040B796 push rsp
00007FFD4040B797 ?? ???
for (int i = 0; i < list.Count; i++)
00007FFD4040B798 call 00007FFD9FF7AB00
00007FFD4040B79D pop rsi
00007FFD4040B79E push rsi
00007FFD4040B79F or eax,0B6F35BE8h
00007FFD4040B7A4 pop rdi
00007FFD4040B7A5 pop rsi
00007FFD4040B7A6 pop rax
00007FFD4040B7A7 or al,0E8h
00007FFD4040B7A9 push rbx
00007FFD4040B7AA rep mov dh,5Fh
00007FFD4040B7AD pop rsi
00007FFD4040B7AE pop rdx
00007FFD4040B7AF or ebp,eax
00007FFD4040B7B1 ?? ???
for (int i = 0; i < list.Count; i++)
00007FFD4040B7B2 rep mov dh,5Fh
00007FFD4040B7B5 pop rsi
00007FFD4040B7B6 pop rsp
00007FFD4040B7B7 or ch,al
00007FFD4040B7B9 ?? ???
for (int i = 0; i < list.Count; i++)
00007FFD4040B7BA rep mov dh,5Fh
00007FFD4040B7BD pop rsi
00007FFD4040B7BE pop rsi
00007FFD4040B7BF or eax,ebp
00007FFD4040B7C1 cmp esi,ebx
00007FFD4040B7C3 mov dh,5Fh
00007FFD4040B7C5 pop rsi
00007FFD4040B7C6 ?? ???
for (int i = 0; i < list.Count; i++)
00007FFD4040B7C7 or al,ch
00007FFD4040B7C9 xor esi,ebx
00007FFD4040B7CB mov dh,5Fh
00007FFD4040B7CD pop rsi
00007FFD4040B7CE ?? ???
00007FFD4040B7CF ?? ???
for (int i = 0; i < list.Count; i++)
00007FFD4040B7D0 call 00007FFD9FF7AB00
00007FFD4040B7D5 pop rsi
00007FFD4040B7D6 ?? ???
00007FFD4040B7D7 ?? ???
이런 식으로, for 문에 대한 디스어셈블리 코드가 반복적으로 나타나는데… 이게 뭘까요?
루프 언롤링 일까요…?
10000000개의 원소를 넣었는데도 언롤링을 하나요…?