Wednesday, March 18, 2009

C# JIT

I was speaking the other day about the C# JIT and how it sucks sometimes... well, heres some real code to prove the point...

            m_ArrayAccess[0].m_Pos.Y = 2.0f;
00000022 lea edx,[ecx+8]
00000025 cmp byte ptr [edx],al
00000027 mov dword ptr [edx+4],40000000h
m_ArrayAccess[0].m_Pos.Z = 3.0f;
0000002e lea edx,[ecx+8]
00000031 cmp ecx,dword ptr [edx]
00000033 cmp byte ptr [edx],al
00000035 mov dword ptr [edx+8],40400000h
m_ArrayAccess[0].m_Pos.W = 4.25f;
0000003c lea edx,[ecx+8]
0000003f cmp ecx,dword ptr [edx]
00000041 cmp byte ptr [edx],al
00000043 mov dword ptr [edx+0Ch],40880000h


As you can see it not only continually reloads the base address of the array+type, but appears to insert pointless CMP instructions all over the place. The only reason I can figure for this is to attempt to prefetch the destination; however since its about to access it on the next instruction, this is pointless - Not only that but since its sequential chances are its in the cache alrady! And even is by some mirricle that it DID matter, why the hell is it doing it TWICE!!!



Man I find that annoying....

No comments:

Post a Comment